noflo / noflo-canvas

Generative Canvas 2D drawing with NoFlo.
MIT License
18 stars 13 forks source link

MakeBezierCurve doesn't works with non-array points #24

Closed automata closed 10 years ago

automata commented 10 years ago

Just working with MakeRange -> MakePoint.

automata commented 10 years ago

Seems the problem resides in MakePath. The following is supposed to work, but it doesn't:

captura de tela 2014-06-17 as 00 45 32

Someone can say MakePath is generating two separate paths (one for each point). But even when we group points together it still doesn't works:

captura de tela 2014-06-17 as 00 49 54

Grid app here.

forresto commented 10 years ago

Good question! :dromedary_camel:

forresto commented 10 years ago

I think it can be fixed by handling arrays here: https://github.com/noflo/noflo-canvas/blob/ddffd067a3729365b3a48e210a5b6a7ae7949a65/components/Draw.coffee#L141

OK no, the point array is already expanded in to multiple paths in MakePath via MakeCanvasPrimative.

This is the case where you want it to work like currently implemented, multiples paths, from one point to multiple points: screen shot 2014-06-17 at 11 07 36 am

automata commented 10 years ago

Yeah, you're right, it works following the "spread pattern". However, should we expect it works for only two points?

case1

automata commented 10 years ago

Maybe for count = 2 we have two moveTo and no lineTo?

forresto commented 10 years ago

2 points, or more, or combining points, curves, arcs...

forresto commented 10 years ago

Let's take it back to the data view.

:heavy_check_mark: This works to make 10 2-point paths: {},[]

(path (point 0 0)
      (point (range 0 100 10) 100))

:x: This doesn't work now, but I'd expect it to make 1 2-point path: {},{}

(path (point 0 0)
      (point 100 100))

:x: This doesn't work. Expected: 1 10-point path: []

(path (point (range 0 200 10) (random 0 200 10)))
forresto commented 10 years ago

OK, made a compute override for MakePath and a bunch of test cases. We should make sure this MakeCanvasPrimative issue doesn't apply elsewhere.

screen shot 2014-06-18 at 11 54 35 am http://app.flowhub.io/#example/1e52cf65f6a314dfc394

automata commented 10 years ago

http://app.flowhub.io/#example/c17a5b984b220f7ce110

automata commented 10 years ago

Testing @forresto's fix with basic shapes (useful to extend our existing shapes creating subgraphs like MakeTriangle).

captura de tela 2014-06-18 as 09 24 55

So "spread" is default and if we want a group of points/arcs/curves we should use Group, right? I'm very satisfied with this semantics for MakePath.

forresto commented 10 years ago

Group isn't needed there; I was just testing that one array of points would work the same as multiple points.

automata commented 10 years ago

It's better than what I imagined. So it makes a segment to any received points/arcs/curves and knows how to deal with spreads too.

captura de tela 2014-06-18 as 09 37 14