timjs / elm-collage

Create interactive vector graphics and position them relative to each other
BSD 3-Clause "New" or "Revised" License
58 stars 19 forks source link

Add Bézier curves #8

Open timjs opened 6 years ago

timjs commented 6 years ago

A way to create Bézier curves would be great! The idea is to add a curve function which creates a Path. The resulting path can be traced and closed in the same way as segements and lines.

Note: maybe we'll have to rename path to polyline to avoid some confusion, see #10.

Kwarrtz commented 6 years ago

If you want to add Bézier curves, you might consider going all the way and adding some sort of analog to the full SVG <path> element.

lil-spooky-vert commented 5 years ago

The different svg curve and arc commands are fairly complicated, how simple or complex of an interface were you thinking for these?

michaelmesser commented 4 years ago

I will attempt to add the function bezier : Point -> Point -> Point -> Point -> Path like vilterp/elm-diagrams. Hopefully it isn't too difficult.

michaelmesser commented 4 years ago

Do you just want cubic bezier? I can also try to add arc. I'm still trying to figure out how to calculate the bounding box. Should it be possible to join paths into longer paths?

timjs commented 4 years ago

Joining is not necessary I think. Having arc would be nice

Sent with GitHawk

michaelmesser commented 4 years ago

What do you want the type signature for arc to be? The generated path will be:

A rx ry x-axis-rotation large-arc-flag sweep-flag x y
timjs commented 4 years ago

What do other packages do? Take a look at the libraries for Haskell, Clean, Elm etc. I expect you can propose one or two variants and users can take a look

Sent with GitHawk

georgefst commented 3 years ago

I would love to see this work like Haskell's Diagrams lib.

Though I guess with #40 having gone quiet, that doesn't seem likely any time soon... I'm half-tempted to put myself forward, but I really don't use Elm much.

michaelmesser commented 3 years ago

With custom operators and kernel function removed, Elm became too frustrating to use. At some point, I might attempt to write a diagrams library for Idris 2 (which has a JS backend), but I don't think I'll get to it for some time.

georgefst commented 3 years ago

That'd be cool, I've meaning to give Idris a good look.

Fully agree that Elm has some strange omissions that make me struggle to take it seriously, the complete non-extensibility of comparable being the main one for me. Hence why I'm using Purescript at the day job.

But I do have a soft spot for Elm, because of things like how smooth the documentation and tooling are. I really want to be able to recommend it to people just wanting to start dipping their toes in to FP, and it's frustratingly close to being good enough. Anyway, I have one or two hobby projects where I'm stuck with Elm, and I don't really want to have to migrate.

timjs commented 3 years ago

You both put forward Elm's biggest pain points for me, and the reason I moved back to PureScript/Idris/Haskell as well. I only use Elm for teaching from time to time, because of the friendliness and tooling.

I'm only inclined to maintain this library by accepting pull requests from contributors. Could be for bug fixes or additional features.

Nastiest point for me is that Elm made client side text measuring a big pain in the * by restricting FFI. This is the only (pure!) foreign function this library needs.