svgdotjs / svg.js

The lightweight library for manipulating and animating SVG
https://svgjs.dev
Other
11.01k stars 1.07k forks source link

Linear gradient problem #1184

Closed qzoushi closed 3 years ago

qzoushi commented 3 years ago

After I created the linear gradient in svg.js, it didn't work on the element, and I configured the color cutoff for the linear gradient, but I didn't find the stop in the code

Fuzzyma commented 3 years ago

Try this: https://svgjs.com/docs/3.0/shape-elements/#gradient-constructor

qzoushi commented 3 years ago

试试这个:https : //svgjs.com/docs/3.0/shape-elements/#gradient-constructor Using the official API (add) will not work, while using at to add linear gradients will work

Fuzzyma commented 3 years ago

What does not work? Example please!

qzoushi commented 3 years ago

什么不起作用?请举个例子!

this is not work var gradient = draw.gradient('linear', function(add) { add.stop(0, '#333') add.stop(1, '#fff') })

this is work var gradient = draw.gradient('linear', function(add) { add.at(0, '#333') add.at(1, '#fff') })

Fuzzyma commented 3 years ago

are you using the latest version svg.js v3?