request for comment - polygon using svg syntax

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

request for comment - polygon using svg syntax

donbright
I am wondering how people would feel if the polygon() command could
accept a simple string in the SVG path syntax , for example, following
http://www.w3schools.com/svg/svg_path.asp

polygon("M150 0 L75 200 L225 200 Z"); // triangle  -> M = moveto, L =
lineto, Z = close path

polygon("M 100 350 q 150 -300 300 0 Z"); // curve with flat bottom ->
q = bezier curve control point

The motivation is to enable Bezier curves without having to invent a
new syntax, and also to leverage the SVG knowledge already 'out there'
in internet-land.

The first iteration of this feature would only work with 'closed
paths' (with the Z on the end) and very simple stuff (quadratic
beziers).

Does it seem useful?

-DB

Reply | Threaded
Open this post in threaded view
|

Re: request for comment - polygon using svg syntax

rduarte
> Does it seem useful?

Sure it does. Maybe it makes more sense to do it as a new function (presumably
with an SVG-related name) and leave polygon() as is?

r

Reply | Threaded
Open this post in threaded view
|

Re: request for comment - polygon using svg syntax

Alan Cox
In reply to this post by donbright
On Fri, 22 Mar 2013 19:00:58 -0500
Don Bright <[hidden email]> wrote:

> I am wondering how people would feel if the polygon() command could
> accept a simple string in the SVG path syntax , for example, following
> http://www.w3schools.com/svg/svg_path.asp
>
> polygon("M150 0 L75 200 L225 200 Z"); // triangle  -> M = moveto, L =
> lineto, Z = close path
>
> polygon("M 100 350 q 150 -300 300 0 Z"); // curve with flat bottom ->
> q = bezier curve control point
>
> The motivation is to enable Bezier curves without having to invent a
> new syntax, and also to leverage the SVG knowledge already 'out there'
> in internet-land.
>
> The first iteration of this feature would only work with 'closed
> paths' (with the Z on the end) and very simple stuff (quadratic
> beziers).
>
> Does it seem useful?

Yes and no. It's an obvious way to do this until you try and parameterise
it at which point I don't think the string handling in OpenSCAD is up to
it. It probably needs point types adding to the polygon itself in a way
that can be manipulated.

An svg_to_poly() helper would still I am sure be a handy extra.

Alan