[Bug 15255] New: CanvasRenderingContext2D.getContext() would be quite awesome

https://www.w3.org/Bugs/Public/show_bug.cgi?id=15255

           Summary: CanvasRenderingContext2D.getContext() would be quite
                    awesome
           Product: HTML WG
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: HTML Canvas 2D Context (editor: Ian Hickson)
        AssignedTo: ian@hixie.ch
        ReportedBy: mikemp@mit.edu
         QAContact: public-html-bugzilla@w3.org
                CC: mike@w3.org, public-html-wg-issue-tracking@w3.org,
                    public-html@w3.org


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.

-- 
Configure bugmail: https://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

Received on Saturday, 17 December 2011 15:24:27 UTC