NimSvg icon indicating copy to clipboard operation
NimSvg copied to clipboard

polyline element

Open sdmcallister opened this issue 3 years ago • 1 comments

Thank you for the amazing library!

Right now you can create a polyline like:

polyline(points="10.0,100.0 20.0,200.0", etc....)

Is there any interest in adding polyline to styles but having the points param being some other type like seq[tuple(float,float)]? Maybe there isn't any advantage though.

sdmcallister avatar Jan 11 '21 12:01 sdmcallister

Yes something like that makes definitely sense.

In general I always wanted to add a more higher level convenience API with explicitly typed arguments. A draft of that is available in https://github.com/bluenote10/NimSvg/blob/master/src/nimsvg/styles.nim

Note: Style is a bit of a misnomer, perhaps it should rather be called Styled or StyledContext. In any case it allows to write stuff like

let styled = defaultStyle()

styled.circle(0, 0, r=10)

# offers often needed convenience like centering a rect
styled.rectCentered(0, 0, w=10, h=10)

# and it would be easy to add
styled.polyline(points)

bluenote10 avatar Jan 11 '21 13:01 bluenote10