Re: Transformed Pointer Coordinates?

On Feb 11, 2013, at 6:12 PM, Boris Zbarsky <bzbarsky@MIT.EDU> wrote:

> On 2/11/13 8:54 PM, Dirk Schulze wrote:
>> The point in the case of the SVG WG is a dictionary:
> 
> Is there any explanation for why a dictionary was chosen?
> 
> One benefit of using an interface over a dictionary is that you can pass 
> points by reference if desired, not just by value.  Another is that 
> passing them to WebIDL methods is likely faster (though on the flip side 
> working with them from JS might be slower, so the performance angle 
> really depends on how these objects will be used.

It was a request by web authors to allow simple ways to pass points. Dictionaries are very popular for web developers: foo({x: 20, y: 20, z: 0}) is more likely to be excepted than foo(new DOMPath(20,20,0)).

Here is the quote of the discussion:

""
birtles: could you have a dictionary that has x, y, z plus whatever you call the last one?
krit: w?
birtles: the z defaults to 0, the w to 1; as a dictionary it wouldn't have methods, but something on the Matrix class could take a dictionary and return a dictionary
… so no need to define a new Point interface
… when you've got a method that takes a point in, you pass in { x: 1, y: 2 } and in 2D space you don't specify any more
krit: once you set this point, can you still read back the fourth component?
birtles: yes the method could stick the "w" property on there and authors could ignore it
krit: I'm not in favour of a dictionary
birtles: Matrix.transformPoint() could take a dictionary and return a dictionary
... it's convenient to use that syntax
… and you can still get ".x" from the return value
<birtles> e.g. var ret = matrix.transformPoint({ x: 23, y: 24 })
<birtles> console.log(ret.x)
dmitry: I like this; I don't like `new Point(23, 24)`
dino: I kind of like the idea of not needing a defined type
""
http://www.w3.org/2013/02/07-svg-minutes.html#item04

Greetings,
Dirk 

> 
> -Boris
> 

Received on Tuesday, 12 February 2013 02:29:06 UTC