README.md 3.48 KB
Newer Older
Julian Frosch's avatar
Julian Frosch committed
1
2
# BezLinApp for node.js and electron
This is an application written with node.js and electron that tries to do a piecewise linear approximation on Bezier curves in a given SVG-file.
3
4
5

## How to start
Before starting, npm is required.
6
7
8
9
10
11
Furthermore, the npm-package *electron-prebuilt* is required. Installing it will take some time, as it contains some data...
So ensure that you have a rather good connection. Run
```
sudo npm install electron-prebuilt -g
```
and electron will be installed!
12

13
In order to test the program, clone the repo, cd into it's directory and run
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
```
npm install
```

This will download the dependencies and create a folder *node_modules/* with their data.
Next you can run
```
npm start
```
or
```
electron .
```
to start the application!

Julian Frosch's avatar
Julian Frosch committed
29
## Using the app
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
After starting, you will see a window. You can just drag'n'drop the SVG that should be approximated and the PNG (the heatmap) anywhere into the window.
The "console" at the bottom will give you feedback about the files. Note that you can also drag multiple files of each type into the window.
However, only the last one will be used for approximation.

You can adjust the desired path-lengths with the two steppers above the run button. The program will calculate corresponding values between min/max for the grayscale-amount in your heatmap.
If no heatmap is provided, the whole SVG will be approximated with maximum precision!

With everything set up, you can click the run button and let the work begin! When finished, the program will write two files into the folder where you dragged your initial files from:
* <svg-filename>_approximated.txt: only contains all linepoints of the paths (comma-separated, one path per line).
* <svg-filename>_approximated.svg: an SVG containing the approximated paths. Actually it is the "original" SVG, only the path's data-attributes are completely replaced by lines.

## Installing via electron-packager
For convenience, you can also pack this program into a single app containing the electron-framework and Google's V8-engine, so it can be run on any computer without the need to have electron or even node.js installed. You can pack it for the Linux, Windows and Darwin platform from whichever OS you may run (although it is recommended to pack it from the corresponding OS, as some modules may be compiled differently...).

For this, you need to install the electron-packager:
```
sudo npm install electron-packager -g
```

Then, cd into the program's directory and pack it! For a full functionality description, you can just
```
electron-packager
```
as this will show the help-text.

An example for building the app for Linux and Windows on the x64-arch:
```
electron-packager ./ BezLinApp --platform=linux,win32 --arch=x64 --version=0.36.3
```
Note:
* For the platform, you can submit a comma-separated list, or even put *all* for all platforms
* The version-parameter specifies the electron-version to build the app with. If in doubt, use your current version (take a look under /usr/lib/node_modules/electron-prebuilt/package.json).
* For some reason, the icon didn't work for me with this method... the icon-parameter (see options) didn't work either. Also, you need different filetypes for the different platforms.
* Windows has some serious issues with the pathname-length. Don't ask me, it's 2016 and I don't know how a modern OS can still have this problem. If you want to try it, take a look under "asar-archives" in the electron-API. With this, you can pack parts of your app into a one-file-archive and tackle this problem...