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) calling context.transform(..), and 3) calling context.fill(), which transforms the gradient while not transforming the path. But this feels both roundabout and doesn't play nicely if you want to use Path2D.
Ideally there would be a CanvasGradient.transform method that accepts a DomMatrix similar to CanvasRenderingContext2d.transform. This would be analogous to SVG gradientTransform.
Another possibility would be to allow context.createPattern to accept a CanvasGradient, as CanvasPattern.setTransform already exists.
It'd be nice if
CanvasGradientcould 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
lineToetc., 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.transformmethod that accepts aDomMatrixsimilar toCanvasRenderingContext2d.transform. This would be analogous to SVGgradientTransform.Another possibility would be to allow
context.createPatternto accept aCanvasGradient, asCanvasPattern.setTransformalready exists.