Java AWT - draw a polygon connected by smooth curved lines

Here I ask more stupid graphic questions. I hope that soon I will leave the world of graphics behind and firmly put myself in a colorless middle level. I have a new respect for people who can tinker with images in nice ways using code.

However, I draw a polygon on the canvas. It can have an arbitrary number of points, but now suppose 12. The polygon, as implemented, is connected by straight lines from point to point. I would like to apply some transformation so that the shape is more “natural”, as if someone connected the dots with a pen / pencil.

I am not sure if this is too vague from the description. I think I'm looking for a bezier curve, but I'm a graphic (and geometry) weak jaw. I'm interested in new solutions in general, just something that makes a one-sided polygon more like ink paint. Perhaps with controls to achieve a more or less "natural" form.

If you need more information, please feel free to ask.

Thanks Matt

+5
source share
2 answers

:
* GeneralPath
* GeneralPath.curveTo(float x1, float y1, float x2, float y2, float x3, float y3)
* Graphics2D
* Graphics2D.draw(Shape s), GeneralPath ( )

:
* BasicStroke (width = 1, cap = CAP_ROUND, join = JOIN_ROUND)
* Graphics2D.setStroke

, x3, y3 To

+4

JVS JVM Graphics Graphics2D, .

.

0

All Articles