W3C home > Mailing lists > Public > whatwg@whatwg.org > July 2006

[whatwg] Canvas 2d methods

From: Stefan Gössner <stefan@goessner.net>
Date: Tue, 04 Jul 2006 01:57:21 +0200
Message-ID: <44A9AEE1.3080406@goessner.net>
L. David Baron wrote:

>On Sunday 2006-07-02 22:47 +0200, Stefan G?ssner wrote:
>>hmm ...
>>  .rotate(Math.PI/4)
>>  .translate(4,-6);
>>illustrates a sequence of manipulations semantically very well, doesn't it?
>In my opinion, this pattern generally makes sense semantically when used
>on immutable objects (e.g., strings in JavaScript).
>I don't think this pattern makes sense for mutable objects.  It just
>suggests immutability.  And making the canvas context objects immutable
>doesn't really make sense without much more significant changes.
I don't understand the mutable/immutable argument. If I had a mutable 
Point object

var Point = {
  setX: function(x) {..},
  setY: function(y) {..},
  setZ: function(z) {..}

why should this pattern


make semantically more sense than


The object's state is altered always in the same *intended* order. And 
the latter doesn't suggest more immutability than the former in my opinion.

The same mechanism applies to the current transformation matrix, which 
is part of the drawing state of the canvas' context object.
Stefan G?ssner
Received on Monday, 3 July 2006 16:57:21 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:58:47 UTC