gradients
tigercoding56 opened this issue · comments
i have a image with gradients , is it possible to add support to them ( they are in svg standart)
Hi,
This is a good question, I'm aware of the gradients in SVG and I thought about supporting them. But the shape finding algorithm is based on solid colors now. Changing this would make ImageTracer very complex.
Workaround: if you have an algorithm to find the gradients, you can replace them with a solid color before tracing, trace, then add the gradients back at the rendering phase.
I recommend reading the tosvgcolorstr
function at Line 1015 , then you can probably patch it like this (I haven't tested this) :
ImageTracer.tosvgcolorstr = function(c, options){
return 'fill="'+ my_gradient_here() +'" stroke="'+ my_gradient_here() +'" stroke-width="'+options.strokewidth+'" opacity="'+c.a/255.0+'" ';
};
Can this be a solution for gradients?
I hope this helped. Feel free to reopen the Issue if you have further questions.