-
Notifications
You must be signed in to change notification settings - Fork 25
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
Arbitrary gradient transforms #28
Comments
Yes that would be nice. But I agree the API ought to offer a simpler way to do this. |
The transform & inverse trick unfortunately doesn't help with applying a gradient style to strokes, because transforming the context transforms the stroke geometry itself, resulting in odd-looking width, joins, etc.: https://jsfiddle.net/mwelsh/7zLac8m3/9/ |
Strong vote for transforms attached to all "shaders" in canvas2d:
+ gradients
+ patterns (image-shaders)
…On Tue, May 17, 2022 at 1:08 AM Mike Welsh ***@***.***> wrote:
The transform & inverse trick unfortunately doesn't help with applying a
gradient style to strokes, because transforming the context transforms the
stroke geometry itself, resulting in odd-looking width, joins, etc.:
https://jsfiddle.net/mwelsh/7zLac8m3/9/
—
Reply to this email directly, view it on GitHub
<#28 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABC77QYS7EEFXT35MGQCDOTVKMSTZANCNFSM5WAGRDBQ>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
--
"I think I can safely say that nobody understands quantum mechanics."
-- Richard Feynman
"It ain't what you don't know that gets you into trouble. It's what you
know for sure that just ain't so." -- Mark Twain
"I am pleased to see that we have differences" -- Surak
|
It'd be nice if
CanvasGradient
could have an arbitrary transform. For example, this would allow for elliptical radial gradients or skewed gradients.This is possible with the current canvas API in some situations by 1) tracing the path with
lineTo
etc., 2) callingcontext.transform(..)
, and 3) callingcontext.fill()
, which transforms the gradient while not transforming the path. But this feels both roundabout and doesn't play nicely if you want to usePath2D
.Ideally there would be a
CanvasGradient.transform
method that accepts aDomMatrix
similar toCanvasRenderingContext2d.transform
. This would be analogous to SVGgradientTransform
.Another possibility would be to allow
context.createPattern
to accept aCanvasGradient
, asCanvasPattern.setTransform
already exists.The text was updated successfully, but these errors were encountered: