-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
109 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion
2
assets/examples/phil_10.svg → docs/assets/examples/phil_blue_10.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Development | ||
|
||
To run your local copy of Contourer for development follow these steps | ||
|
||
## Install | ||
|
||
Clone repository | ||
|
||
```sh | ||
$ git clone https://github.com/stickerum/contourer | ||
$ cd contourer | ||
``` | ||
|
||
Install Node.js dependencies | ||
|
||
```sh | ||
$ npm i | ||
``` | ||
|
||
## Run Contourer | ||
|
||
To process image with Contourer pass path to this image | ||
|
||
```sh | ||
$ npm start <path-to-file> | ||
``` | ||
|
||
## Pack binaries | ||
|
||
Create binary files to use Contourer on production by the following script. | ||
|
||
```sh | ||
$ npm run pack | ||
``` | ||
|
||
Binaries for Linux, macOS and Windows will be created in `build` directory. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# How it works | ||
|
||
Step by step explanation of Contourer's work. | ||
|
||
## Get a source image | ||
|
||
![](assets/how-it-works/step-0.svg) | ||
|
||
## Create a shade | ||
|
||
Paint black each non transparent pixel | ||
|
||
![](assets/how-it-works/step-1.svg) | ||
|
||
## Find a contour | ||
|
||
For each black pixel we check his 8 adjacent pixels. If one of them is transparent then target pixel is on the contour of image. | ||
|
||
![](assets/how-it-works/step-2.svg) | ||
|
||
## Extend the shade | ||
|
||
Each contour's pixel should be «enlarged» to the margin size. We do this to create contour that places with a distance to image. | ||
|
||
![](assets/how-it-works/step-3.svg) | ||
|
||
## Color it black | ||
|
||
Actually we don't draw this red contour. This step is for better understanding the process. | ||
|
||
![](assets/how-it-works/step-4.svg) | ||
|
||
## Trace a shade | ||
|
||
Now we have a shade that should be traced. At the end of this step Potrace will return a vectorized copy of this shape. We use modified version of [node-potrace](https://github.com/stickerum/node-potrace) so we able to set up color for shape's stroke. | ||
|
||
![](assets/how-it-works/step-5.svg) | ||
|
||
## Remove filling | ||
|
||
Returned vectorized shape doesn't have any filling. It also was done for understanding. | ||
|
||
![](assets/how-it-works/step-6.svg) | ||
|
||
## Сombine with an original image | ||
|
||
The last step is combine svg contour and image to one file. To do this we encode source image to base64 and add it to svg code. | ||
|
||
![](assets/how-it-works/step-7.svg) |