jmathanim icon indicating copy to clipboard operation
jmathanim copied to clipboard

JMLinearGradient & JMRadialGradient not working properly

Open rensx opened this issue 1 year ago • 4 comments

Only show one of the colors(stop color) added.

rensx avatar Jul 21 '23 04:07 rensx

https://github.com/davidgutierrezrubio/jmathanim/assets/46339813/0e79a2af-60ab-4f25-a38e-93fe59da740a

u1f628

rensx avatar Jul 21 '23 04:07 rensx

Are you trying to import a SVG with gradients? Unfortunately, JMathAnim, cannot yet import some SVG features as gradients. I will mark to include this feature in the next version.

davidgutierrezrubio avatar Jul 21 '23 11:07 davidgutierrezrubio

Thank you for your quick response. The problem is the coordinates system: the cx,cy,r(or x1 x2 y1 y2) can't transformed as the shape. new JMRadialGradient(cx, cy, r)->new JMRadialGradient(cx', cy', r'). I don't know cx', cy',r'.

rensx avatar Jul 21 '23 12:07 rensx

When defining a JMRadialGradient (or linear) by default the flag relativeToShape is set to false, which means that gradient coordinartes are computed relative to screen not shape. If you wan to change this behaviour, use the method .setRelativeToShape(true) to the created gradient.

Anyway, to be able to import this svg, JMathAnim still needs to implement proper parsing of SVG <radialGradient> and <linearGradient> tags and also the tags where you can define named style elements.

davidgutierrezrubio avatar Jul 30 '23 11:07 davidgutierrezrubio