-
Notifications
You must be signed in to change notification settings - Fork 64
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
PSD export svg <linearGradient> get the wrong result #136
Comments
I don't know that much about SVG but maybe you can't put opacity and color stops like this, check if you get good result with just color stops first. If you provide screenshots of both gradients I could maybe figure something more about the issue. |
It seems that angle in SVG goes clockwise but it goes counter-clockwise in Photoshop, so you need to negate it. You need to merge the stops so you only have one list, each stop with both color and opacity. If the location of color and opacity stops is the same then you just merge them into on stop, but if you have opacity stop without matching color stop you need to interpolate correct color for it by calculating it based on nearest color stops. |
Could you give me an example of how to perform the calculation? |
You need to find 2 closes points to the one you need to calculate then then just do linear interpolation of all values. function lerp(v0, v1, t) {
return v0 + t * (v1 - v0);
}
var prevColorStop = ...
var nextColorStop = ...
var opacityStop = ...
var t = (opacityStop.location - prevColorStop.location) / (nextColorStop.location - prevColorStop.location);
var r = lerp(prevColorStop.r, nextColorStop.r, t);
var g = lerp(prevColorStop.g, nextColorStop.g, t);
var b = lerp(prevColorStop.b, nextColorStop.b, t);
... |
thank you so mush, I get it ~ |
hello, could you tell me how to concat svg gradient data ?
The text was updated successfully, but these errors were encountered: