-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create colored svg in c++ code. #5
Conversation
…l paths group on c++ side. Compile wasm using c++ compiler.
Wow, this looks amazing. Thanks |
Addendum: since your build script also appends the |
Thanks! That sounds great. :) Could You first check does it not cause any problems with Your existing SVG code? If Yes I will fix it asap. I guess it is not as simple as we think to just modularize. I think, following documentation and examples from StackOverflow it seems like a modularization creates a module that needs to be instantiated and used like is in src/potrace.js file. |
I have played a bit with this, but fail to get super convincing results: Your PR:
Current client-side implementation:The current SVGcode output with the default settings is this: Posterization in SVGcodeWhen you paste This allows you to see what the app is doing internally (top: input image, bottom: posterized input image): Posterization happens on all four channels (r, g, b, a) independently, essentially as in this CodePen demo. Do the results of the demo look entirely different for you? Maybe it's a problem on my side? |
And to get that black color You need to use |
Now quant level has the same behavior as the step value from SVGcode, but it is one value for all channels. The value should be between <1;255> |
I cannot really reproduce the results from your screenshots. If I run the following code from the demo, I get the image below, which has a lot more white holes than your screenshots: potrace(blob, {
turdsize: 2,
turnpolicy: 4,
alphamax: 1,
opticurve: 1,
opttolerance: 0.2,
pathonly: false,
extractColors: true,
posterizeLevel: 6,
posterizationAlgorithm: 0, // 0 - simple, 1 - interpolation
} A couple of review remarks:
A meta level remark:
|
I can feel Your confusion. esm-potrace-wasm/demo/index.html Line 14 in b2644d0
To <svg id="div1" style="background-color:black"></svg> On div is white background so transparent is white there :) Please try with parameters posterizationAlgorithm = 1 and posterizeLevel = 5 Algorithm 0: It is just simple quantization method - floor(color/level)*level+ level/2 Algorithm 1: It is also simple algorithm but require more instruction
I have both because sometimes I do not need great visualization effect - example when trying to vecorize text and do not need to care about clear white or black color but speed is required. For first. For second. |
Thank you very much for this contribution! |
The porpouse was to speedup colored svg by using c++ code.