noflo/noflo-canvas

vector, point, rectangle

Closed this issue · 3 comments

Rectangle outputs an object ({rectangle: [x,y,w,h]}) so that fill and stroke know what to do with it. But that's different than drawImage's rectangle inputs. We can't really accept both kinds of rectangle there, since it has to be either array or object to parse manual input from the node inspector.

What's currently Vector could be Point, since it is specific to x and y. Point could follow Circle and Rectangle, and output {point: [x, y]}.

Vector could be a simple array in/out, for any number of numbers. Then it would be easy to plug Vector into Point, Circle, Rectangle, and have those modules do the conversion.

What do you think @automata?

Since arrays are objects in js, this works:

var p = [0,1];
p.type = 'point';

Do you think this is too tricky or OK?

Here's what the data looks like to stroke a circle and rectangle:

screen shot 2014-04-16 at 5 46 35 pm

I think that's OK for these primitives that should directly become context function arguments.

For Stroke, Fill, LineWidth, etc., I think it might be a little saner to make an object:

{
  type: 'stroke',
  strokables: []
}