This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 15255 - CanvasRenderingContext2D.getTransform() would be quite awesome
Summary: CanvasRenderingContext2D.getTransform() would be quite awesome
Status: RESOLVED FIXED
Alias: None
Product: HTML WG
Classification: Unclassified
Component: HTML Canvas 2D Context (show other bugs)
Version: unspecified
Hardware: All All
: P2 enhancement
Target Milestone: ---
Assignee: Ian 'Hixie' Hickson
QA Contact: HTML WG Bugzilla archive list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-17 13:25 UTC by Michael Morris-Pearce
Modified: 2012-01-28 22:23 UTC (History)
5 users (show)

See Also:


Attachments

Description Michael Morris-Pearce 2011-12-17 13:25:16 UTC
Feature request:
CanvasRenderingContext2D.getTransform() returns an Array[6] of the current transformation matrix.

This was brought up previously:
http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2010-July/027394.html

The previous request did not receive any public comments, and I'd like to re-prompt the request for reasons not mentioned.

getTransform would allow authors to copy transformation state from one context to another as needed. This is particularly relevant in code that coordinates graphics among multiple canvases (save/restore is not applicable).

For example:

(1) Authors could save a reused canvas alongside its context2d transform, compute the bitmap's bounding geometry from the transform, and later decide whether the bitmap should be redrawn based on its geometry.

(2) Similarly, redrawing the bitmap onto a new canvas with the same transform  requires portability of the original state.

(3) getTransform allows for general purpose math operations. For example, if the author wants to know over which pixel in a canvas bitmap the cursor is hovering: simply getTransform(), invert the matrix, and multiply with the cursor to get the pixel index.

A workaround I wrote can be found here:
http://gitorious.org/meta2d/core/blobs/master/src/context.js

The same repository contains examples that give a context (no pun intended) to the utility of getTransform. It would be nice to do this without a cludge, and get back some CPU.
Comment 1 Michael Morris-Pearce 2011-12-17 13:45:15 UTC
Er, s/Context/Transform in summary.
Comment 2 Ian 'Hixie' Hickson 2012-01-28 22:23:46 UTC
EDITOR'S RESPONSE: This is an Editor's Response to your comment. If you are satisfied with this response, please change the state of this bug to CLOSED. If you have additional information and would like the editor to reconsider, please reopen this bug. If you would like to escalate the issue to the full HTML Working Group, please add the TrackerRequest keyword to this bug, and suggest title and text for the tracker issue; or you may create a tracker issue yourself, if you are able to do so. For more details, see this document:
   http://dev.w3.org/html5/decision-policy/decision-policy.html

Status: Partially Accepted
Change Description: none yet
Rationale: I'm marking this LATER to consider it with other canvas-related feature requests when I get back to adding canvas features.