-
Notifications
You must be signed in to change notification settings - Fork 11
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
Linear gradient matrix math #22
Comments
The matrix transforms from graphic coordinate-space
When, For your matrix, a path node at
So To recover the original
To pick one out of the infinite options, set
The first line gives
Adding
So
If |
Ah, the key fact I was missing is that there's an infinite number of pairs, good point. I hadn't thought that all the way through. |
If both and b are zero then the equations above simplify to |
I get that from:
which collapses to
I think you're talking about
The math gets hand-wavy, but I'd say that while |
Can we make it invalid for the matrix to be non-invertible? :-) |
Possibly, but then you get questions of floating point approximations. If |
I guess differing on the precise pixels is less bad than differing on whether to show anything at all, true... I think at a minimum we should describe what to do for such cases, though. Presumably we should render a solid color, but which one? (For linear I guess we pick through and find which color |
For now if the radial gradient matrix is non-invertible i'm just setting a, d, b, and e to 0.0 and if the linear gradient matrix non-invertible I'm just setting x1,y1 to -1e9 and x2,y2 to +1e9 (the skia "infinities"). This makes the linear gradients show the 0.5 color and the radial gradients go black, at least on the current test files if we pretend their matrices are non-invertable. |
For radial, if the four primary matrix elements are zero, the gradient offset would uniformly be At least, that's self-consistent 'mathematically'. It's arguable whether that makes sense 'intuitively'. |
I'm loathe to implement a bunch of code just to figure out what the equivalent flat-color from all the stops at that particular position is, given that it's only to handle what is basically an error, but I agree that that seems like vaguely the "most correct" answer. |
The appendix says that the linear gradient matrix can have d=0 and e=0. However, that means that the matrix in question is not invertible, so it's not clear to me what the expected effect actually is.
For example, suppose your matrix is:
How do you go from that to the x1,y1, x2,y2 pair that describes the linear matrix?
The text was updated successfully, but these errors were encountered: