Bug 19053 - An additional useful transformation would be Perspective.
Summary: An additional useful transformation would be Perspective.
Alias: None
Product: HTML WG
Classification: Unclassified
Component: HTML Canvas 2D Context (show other bugs)
Version: unspecified
Hardware: All All
: P3 enhancement
Target Milestone: ---
Assignee: Jay Munro
QA Contact: HTML WG Bugzilla archive list
URL: http://www.whatwg.org/specs/web-apps/...
Depends on:
Reported: 2012-09-25 22:00 UTC by contributor
Modified: 2013-02-22 18:46 UTC (History)
8 users (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description contributor 2012-09-25 22:00:58 UTC
This was was cloned from bug 9235 as part of operation LATER convergence.
Originally filed: 2010-03-12 19:54:00 +0000

 #0   contributor@whatwg.org                          2010-03-12 19:54:20 +0000 
Section: http://www.whatwg.org/specs/web-apps/current-work/#transformations

An additional useful transformation would be Perspective.

Posted from:
 #1   Axel Dahmen                                     2010-03-12 19:57:41 +0000 
Perspecive would make it possible to add pseudo 3D to 2D surfaces.

A possible function declaration would be:


Where parameters constitute four tuples, describing an offset from each of the four viewport corners.
 #2   Axel Dahmen                                     2010-03-20 17:27:50 +0000 
I wrote a typo by mistake. The perspective function declaration should look like this, of course:

 context.perspective(dx1,dy1, dx2,dy2, dx3,dy3, dx4,dy4)

The tuples should be given in this sequence: top-left, top-right, bottom-left, bottom-right.
 #3   Maciej Stachowiak                               2010-03-21 00:02:15 +0000 
(In reply to comment #2)
> I wrote a typo by mistake. The perspective function declaration should look
> like this, of course:
>  context.perspective(dx1,dy1, dx2,dy2, dx3,dy3, dx4,dy4)
> The tuples should be given in this sequence: top-left, top-right, bottom-left,
> bottom-right.

I think we can leave perspective transforms to WebGL: <https://cvs.khronos.org/svn/repos/registry/trunk/public/webgl/doc/spec/WebGL-spec.html>
 #4   Axel Dahmen                                     2010-03-22 12:25:30 +0000 
Actually, because CSS3 implements the same functionality as the canvas element (which makes me believe that the canvas element becomes redundant then), I have suggested the same functionality to CSS3.

Please find the current discussion at: "comp.infosystems.www.authoring.stylesheets", "CSS3 Transformation Suggestion: Add additional perspective version to 3D transformations"
- or -

In the course of that discussion it became clear that the name "perspective" and "3D" don't meet the actual goal of this function.

In fact the function prototype I'm suggesting is more general 
than the other canvas transformation function.

With the suggested transform method it is possible to map all existing basic transformation functions - the translate as well as the scale, skew and rotate function, all into one single function.

So I suggest to call it something global like "transform" then.
 #5   Philip Taylor                                   2010-03-23 16:07:09 +0000 
There is already a general "transform" function, which can do translations/rotations/scales/skews in a single function. (It's limited to affine transformations, though, so it can't do perspective. Would implementations be able to cope with non-affine transformations?)
 #6   Ian 'Hixie' Hickson                             2010-04-02 01:23:26 +0000 
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:

Status: Rejected
Change Description: no spec change
Rationale: This is something we should look at again in a future version, but we've got enough trouble getting the browsers to implement the current stuff without adding more complexity already. Baby steps.
 #7   Axel Dahmen                                     2010-05-07 03:24:02 +0000 
Sure. I'm looking forward to upcoming versions of the spec then.
 #8   Ian 'Hixie' Hickson                             2012-02-29 22:23:10 +0000 
Punting again for now.

I think the best way to move forward on this would be to get a user agent to implement an experimental version of this, so we can experiment with it before adding it to the spec.
 #9   Axel Dahmen                                     2012-03-11 21:20:35 +0000 
Thank you for putting this on the new schedule.

I can't provide a sample implementation, I'm afraid. However I can provide a small presentation demonstrating the expected result.

Here's the URL to the file:


While working on the presentation I noticed that a _function_ does not quite yield the most flexibility. There would be a second function necessary to be able to read the currently computed Canvas 2D Context corner position values.

So I'd like to amend my suggestion to not provide a Transformation/Perspective function but to add a Transformation object property to the Context object. (I will continue to use my suggested type/property names for now to be consistent. I do not presume any naming scheme here.)

The Transformation object returned by the 2D Context object should in turn provide four properties representing each of the four Context corners. The type of each of these properties would be TransformationPoint, providing a delta X and a delta Y value.

Here's the suggested type definition:

Transformation := {"upperLeft":new TransformationPoint()
                  ,"upperRight":new TransformationPoint()
                  ,"lowerLeft":new TransformationPoint()
                  ,"lowerRight":new TransformationPoint()

TransformationPoint := {dX:0, dY:0}

Using this definition it would later even be possible to do spline kind of transformations by defining two spline point positions with each TransformationPoint object. These spline point positions would be given relative to the TransformationPoint object's values.

Given the spline extension, the TransformationPoint class would look like this:

TransformationPoint := {dX:0
                       ,bezierClockwise:new TransformationPoint()
                       ,bezierCounterClockwise:new TransformationPoint()

Axel Dahmen