pts icon indicating copy to clipboard operation
pts copied to clipboard

[Question] Rounded corners in polygon

Open ajitid opened this issue 4 years ago • 1 comments

Hi, I wanted to start learning and making 2D stuff on the web and found Pts to be a lib which suits my use case. Just have a quick question, is there any (easy) way to create rounded corners in rectangles and in other polygons? If so, what is the API and also can we manipulate corner radius of each vertex individually?

I haven't delved into docs that much, so might have missed it.

ajitid avatar Sep 25 '20 20:09 ajitid

Hi @ajitid -- thanks for trying out Pts!

There's no native canvas API for rounded corners. I can think of two ways --

  1. A hack: use the 'round' stroke to round the corners. This has many limitations but it's probably the easiest if you just need a quick solution. Eg:
form.stroke("#000", 20, 'round').fill('#000').polygon( ... )
  1. Draw a custom path using straight lines and arcs. This can be a bit painful to implement though.

Let me mark this as a feature request. It's a new feature we can consider building into Pts.

Thanks for filing this issue!

williamngan avatar Sep 26 '20 07:09 williamngan