These forums are currently read-only due to receiving more spam than actual discussion. Sorry.

It is currently Sat Dec 02, 2017 4:23 pm Advanced search

canvas transform help/shortcoming?

Here you can discuss things related to HTML and the Web in general that do not fit in to other categories.

canvas transform help/shortcoming?

Postby benomatic42 » Tue Nov 10, 2009 4:10 pm

I am trying to use canvas for some basic 2d graphics stuff, and the transform functions seem to work well in firefox, doing what I expect. However, I found one shortcoming that I haven't been able to resolve (at least trivially).

After I have applied a series of transforms (via translate, scale, etc.), I get the drawing that I want. After that display, I want to be able to map a user mouse-click back into my model space, meaning I want to use the inverse of the current transform. Unfortunately, I can't find a way to 'get' the current transform. transform and setTransform return 'undefined'.

the alternatively is to implement the translate/scale funcs myself, and keep track of the current transformation myself, invert that and use it directly. But it feels like this kinda of functionality would be a common use, so I wonder: am I missing the boat here? Is there another way to map a user click back into my model space? Or should I be petitioning the specs forum to add getTransform (and get TransformInversion)?

Thanks,

ben
benomatic42
<h6>
 
Posts: 2
Joined: Tue Nov 10, 2009 3:58 pm

Postby zcorpan » Fri Dec 04, 2009 12:53 pm

Maybe SVG is more suitable for your use case?
zcorpan
<article>
 
Posts: 807
Joined: Tue Feb 06, 2007 8:29 pm
Location: Sweden

Postby benomatic42 » Wed Dec 09, 2009 11:51 pm

zcorpan wrote:Maybe SVG is more suitable for your use case?


In theory, yes...

But some (myself included) would argue that SVG isn't suitable for any use cases :)
benomatic42
<h6>
 
Posts: 2
Joined: Tue Nov 10, 2009 3:58 pm

Postby zcorpan » Thu Dec 10, 2009 12:05 am

Why not?
zcorpan
<article>
 
Posts: 807
Joined: Tue Feb 06, 2007 8:29 pm
Location: Sweden

Postby DaveSpencer » Wed Jan 06, 2010 12:38 pm

benomatic42 wrote:
zcorpan wrote:Maybe SVG is more suitable for your use case?


In theory, yes...

But some (myself included) would argue that SVG isn't suitable for any use cases :)


Yes, why isn't SVG suitable?
DaveSpencer
<h6>
 
Posts: 2
Joined: Wed Jan 06, 2010 11:50 am

Postby jove4015 » Thu Mar 18, 2010 5:50 am

I know it's an old thread but I stumbled across this and I have to agree with 2 things here:

1) getTransform would be an incredibly useful function. I can't tell you how much easier it would make my job right now. At the moment, I have huge stacks I must maintain and traverse in my application to compute the transform at a given location, and it is very cumbersome and slow.

2) SVG is not appropriate because of the issue of compatibility. While in theory it's a great idea, and I fully support its implementation, at the moment, it is not supported on the browser that still, despite great increases in market share by open source browsers, is in use by the majority of users - Internet Explorer. I have searched, and searched, and searched, and unless Google has delivered on some magic like what they did with Canvas in the past few days, there is no good option for SVG in Internet Explorer without using unsupported plugins, or Flash. Most of us are using things like SVG and Canvas to avoid plugins or Flash in the first place! I hope, and I pray, that Google or someone else does come up with something soon that mitigates this problem, like excanvas for SVG, but it is not there yet. Until it is, for all practical purposes, I have to act as if SVG does not exist yet. At this point, I'm just very grateful that there *is* an option with Canvas, and for now all my vector-based activities will be programmed with it, despite its shortcomings, precisely because it is the only option available to me. I do not have the option of creating websites that are not compatible with Internet Explorer, and I fear the same is true for most of my contemporaries out in the web development world. I don't think most of you are unaware of this issue - but it seems disingenuous to pretend like SVG is on a level playing field when it just isn't right now.
jove4015
<h6>
 
Posts: 1
Joined: Thu Mar 18, 2010 5:22 am

Postby spmorr02 » Thu Mar 18, 2010 11:37 am

There are actually multiple options for IE in development. There is SVGWeb which is by far the largest one. While it is not native support it is able to be toggled on and off depending on whether the browser has support for SVG.

The other being that IE9 will support SVG which ironically, was just announced a few days ago.

So really I see no reason not to use SVG.
spmorr02
<h5>
 
Posts: 19
Joined: Thu Jan 21, 2010 5:37 pm
Location: Louisville, Kentucky


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 0 guests