-
Notifications
You must be signed in to change notification settings - Fork 681
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
[css-easing] The midpoint
easing function
#3935
Comments
In general, I like the idea of defining an easing function equivalent to the curve created by color hints. It would be convenient when defining animations and transitions, for the same reasons that it is simple and intuitive in gradients. For reference, an easing function defined as
y would always equal 0.5 when x equals H. I'm not sure about the name I like the idea of restricting the parameters to abstract values between 0 and 1 to avoid confusion with percentage lengths in gradients or percentage time selectors in animation keyframes. And it's consistent with the The complication with the fix-up algorithm is unfortunate, but I like your solution of restricting that interaction to the current color hint syntax, so that in general easing functions could be added to gradients in future without affecting positions. |
Interpolation hints are regular color stops. I'm unsure why you say that they "affect color stop positioning". Are authors complaining about the positioning algorithm? Why would you add easing functions to gradients? Doing cubics will cause artifacts and afaik no other graphics format defines gradients that way. |
What I mean that, reading the spec and trying to implement the color stop positioning algorithm outlined in it — with my understanding on it, and lacking other context to its history — I was surprised to find current browsers have a different approach. (Hence my question in #3931).
I'm not aware of anything of the sort. I chanced upon it writing some test cases for an implementation I'm working on. Might be an edge-case to mix unpositioned color stops with interpolation hints in the same gradient and, even then, seeing that browsers render it consistently, as an author you might be inclined to accept it as-is. (As such, I think the resolution to pave the cowpaths in this regard is appropriate.) This proposal (a |
Insofar as easing functions make it into the CSS gradient syntax, I would like to propose a new easing function, tentatively called
midpoint(x)
, for smooth interpolation between color stops, without the drawbacks of the interpolation hints syntax.css-images-4
spec, interpolation hints seem to affect how color stops are positioned, and at least current browser interpretations adhere to that reading of the spec.To enable authors to obtain an intuitive effect from interpolation hints without the drawbacks outlined in (1) and without retroactively redefining the behavior of interpolation hints, we can piggy-back on the easings proposal (2) to present authors with similar functionality.
The
midpoint
easing function takes a single argumentx ∈ [0, 1]
that controls the relative position of the midpoint between the two color stopsA
andB
. The resulting color is computed (by following the interpolation hint definition) as follows:x = 0
, return color B for any point between the two color stops (equivalent tostep-start
)x = 1
, return color A for any point between the two color stops (equivalent tostep-end
)x ∈ (0, 1)
:t ∈ [0, 1]
of the point, relative to the two color stopsx = 0.5
is equivalent tolinear
These two definitions are equivalent:
I have opted for
x ∈ [0, 1]
instead ofx ∈ [0%, 100%]
to make it clear that the value is local to the easing function, and not a position along the gradient line.The text was updated successfully, but these errors were encountered: