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 9235 - <canvas>: perspective transformations
Summary: <canvas>: perspective transformations
Status: RESOLVED FIXED
Alias: None
Product: WHATWG
Classification: Unclassified
Component: HTML (show other bugs)
Version: unspecified
Hardware: All All
: P3 enhancement
Target Milestone: Needs Impl Interest
Assignee: Ian 'Hixie' Hickson
QA Contact: HTML WG Bugzilla archive list
URL: http://www.whatwg.org/specs/web-apps/...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-03-12 19:54 UTC by contributor
Modified: 2016-04-21 16:09 UTC (History)
9 users (show)

See Also:


Attachments

Description contributor 2010-03-12 19:54:20 UTC
Section: http://www.whatwg.org/specs/web-apps/current-work/#transformations

Comment:
An additional useful transformation would be Perspective.

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

A possible function declaration would be:

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

Where parameters constitute four tuples, describing an offset from each of the four viewport corners.
Comment 2 Axel Dahmen 2010-03-20 17:27:50 UTC
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.
Comment 3 Maciej Stachowiak 2010-03-21 00:02:15 UTC
(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>
Comment 4 Axel Dahmen 2010-03-22 12:25:30 UTC
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 -
"http://groups.google.com/group/comp.infosystems.www.authoring.stylesheets/browse_thread/thread/389a6a51be2ad903"



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.
Comment 5 Philip Taylor 2010-03-23 16:07:09 UTC
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?)
Comment 6 Ian 'Hixie' Hickson 2010-04-02 01:23:26 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: 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.
Comment 7 Axel Dahmen 2010-05-07 03:24:02 UTC
Sure. I'm looking forward to upcoming versions of the spec then.
Comment 8 Ian 'Hixie' Hickson 2012-02-29 22:23:10 UTC
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.
Comment 9 Axel Dahmen 2012-03-11 21:20:35 UTC
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:

https://skydrive.live.com/?cid=f18aeca352311e71&id=F18AECA352311E71!236&sff=1



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
                       ,dY:0
                       ,bezierClockwise:new TransformationPoint()
                       ,bezierCounterClockwise:new TransformationPoint()
                       }


RFC
Axel Dahmen
Comment 10 public-rdfa-wg 2013-01-24 06:44:37 UTC
This bug was cloned to create HTML WG bug 19053.
Comment 11 Ian 'Hixie' Hickson 2013-03-20 00:05:29 UTC
Do any browser vendors want to implement something like this?
Comment 12 Justin Novosad 2016-04-21 16:09:08 UTC
This was resolved by allowing the current transform to be specified using a 4x4 DOMMatrix, via the DOMMatrixInit dictionary

Fixed by:
https://github.com/whatwg/html/commit/52ef2b19a2f818a032d12c0bc708c058784b9224