Skip to content
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

Why do linear gradients need three points to define? #278

Closed
justvanrossum opened this issue Apr 25, 2021 · 5 comments
Closed

Why do linear gradients need three points to define? #278

justvanrossum opened this issue Apr 25, 2021 · 5 comments

Comments

@justvanrossum
Copy link

2D worlds that define linear gradients with two points:

  • SVG
  • Skia
  • Cairo
  • Cocoa

2D worlds that define linear gradients with three points:

  • COLRv1

I tried to go through the issues to find an answer, and the best I could find was #55, but it doesn't explain why this was closed apart from a f2f conversation.

@horasio
Copy link

horasio commented Apr 25, 2021

It seems to be to help the artist position the gradient precisely by decoupling start and end point from the direction of the gradient. (The code to compute an equivalent two-points version is simple.)

@justvanrossum
Copy link
Author

I can vaguely understand how this is useful for a designer, but this is not a source format, and the information is redundant for rendering. Do gradients behave differently under transformations when defined this way? I don't think so, but if that were the case I could see the point.

@justvanrossum
Copy link
Author

Thinking more: perhaps it has a similar function as the centerX and centerY values for PaintVarRotate? As in: redundant for static rendering, but indispensible when varying/animating things?

@justvanrossum
Copy link
Author

@behdad confirmed that variability is indeed a factor in this design, and showed me an enlightning use case:

  • imagine a rectangle with a linear gradient from the top left point to the top right point, but skewed so the "left" gradient color end line goes towards the bottom right. Without the third point, it's hard (impossible?) to make this rectangle variable.

I'm satisfied with this explanation and I'm happy to close, unless you decide that this needs mentioning in the spec, and want to keep it open as a reminder.

@drott
Copy link
Collaborator

drott commented Apr 28, 2021

See also #94 and #55.

@drott drott closed this as completed Apr 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants