Intent to Implement: CanvasPattern.setTransform

72 views
Skip to first unread message

pav...@samsung.com

unread,
Sep 4, 2014, 2:42:20 AM9/4/14
to blin...@chromium.org, pav...@chromium.org
Contact emails
 
Spec

Summary
pattern . setTransform(transform)

Sets the transformation matrix that will be used when rendering the pattern during a fill or stroke painting operation.

When the setTransform() method is invoked on the pattern, the user agent must replace the pattern's transformation matrix with the one described by the SVGMatrix object provided as an argument to the method.

 
Compatibility Risk
Low.
 
Ongoing technical constraints
None.
 
Will this feature be supported on all five Blink platforms?
Yes.
 
OWP launch tracking bug?
 
Link to entry on the feature dashboard
 
Requesting approval to ship?
No

- Pavan

Dirk Schulze

unread,
Sep 4, 2014, 3:16:50 AM9/4/14
to pav...@samsung.com, blin...@chromium.org, pav...@chromium.org
lgtm. I think this is a sane idea.

On Sep 4, 2014, at 8:42 AM, pav...@samsung.com wrote:

> Contact emails
> pav...@samsung.com, vive...@samsung.com
>
> Spec
> http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-canvaspattern-settransform
>
> Summary
> pattern . setTransform(transform)
> Sets the transformation matrix that will be used when rendering the pattern during a fill or stroke painting operation.
>
> When the setTransform() method is invoked on the pattern, the user agent must replace the pattern's transformation matrix with the one described by the SVGMatrix object provided as an argument to the method.

What do you plan to do if the passed matrix is singular? In other cases we silently return earlier and the method does nothing (like addPath). It is not specified in the WHATWG spec, but browsers across the board agreed on this behavior for addPath. I think it makes sense to do it for patterns as well.

Greetings,
Dirk

Rik Cabanier

unread,
Sep 4, 2014, 9:18:10 AM9/4/14
to pav...@samsung.com, blink-dev, pav...@chromium.org
I didn't see this in the dashboard. Maybe this feature is too small for its own entry?
  
Requesting approval to ship?
No

This sound good to implement. Firefox implemented this recently: https://bugzilla.mozilla.org/show_bug.cgi?id=1019257

The only strange thing is that you have to create an SVG element to create a matrix, ie:
var svg = document.getElementById("svg1");
var mtx = svg1.createSVGMatrix();
pat.setTransform(mtx.rotate(-45).scale(0.1));

Introducing DOMMatrix will fix this. 

Rik Cabanier

unread,
Sep 4, 2014, 9:21:04 AM9/4/14
to Dirk Schulze, pav...@samsung.com, blink-dev, pav...@chromium.org
On Thu, Sep 4, 2014 at 12:16 AM, Dirk Schulze <dsch...@chromium.org> wrote:
lgtm. I think this is a sane idea.

On Sep 4, 2014, at 8:42 AM, pav...@samsung.com wrote:

> Contact emails
> pav...@samsung.com, vive...@samsung.com
>
> Spec
> http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-canvaspattern-settransform
>
> Summary
> pattern . setTransform(transform)
> Sets the transformation matrix that will be used when rendering the pattern during a fill or stroke painting operation.
>
> When the setTransform() method is invoked on the pattern, the user agent must replace the pattern's transformation matrix with the one described by the SVGMatrix object provided as an argument to the method.

What do you plan to do if the passed matrix is singular? In other cases we silently return earlier and the method does nothing (like addPath). It is not specified in the WHATWG spec, but browsers across the board agreed on this behavior for addPath. I think it makes sense to do it for patterns as well.

I agree. 
Browsers are currently split on this. 
FF and IE are trying to follow the spec up to a point. WK and blink consistently return early if the matrix is singular. This is a more sane behavior and also faster. 
 
>
>
> Compatibility Risk
> Low.
>
> Ongoing technical constraints
> None.
>
> Will this feature be supported on all five Blink platforms?
> Yes.
>
> OWP launch tracking bug?
> http://code.google.com/p/chromium/issues/detail?id=289572
>
> Link to entry on the feature dashboard
> http://www.chromestatus.com/features/5100084685438976
>
> Requesting approval to ship?
> No
>
> - Pavan

To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.

ju...@google.com

unread,
Sep 4, 2014, 9:56:16 AM9/4/14
to blin...@chromium.org, pav...@chromium.org
I am not an API owner, but speaking as a reviewer and maintainer of 2D canvas, I support this addition. I think it is low risk, lightweight and useful.
Reply all
Reply to author
Forward
0 new messages