Once again I'm doing Java graphics (Graphics2D) but I noticed there is no Polygon.Double or Polygon.Float classes whereas there is Rectangle2D.Float and Rectangle2D.Double class.
Does anyone know why this is? I just need to draw a triangle using doubles as points.
Internally, a polygon comprises of a list of (x,y) coordinate pairs, where each pair defines a vertex of the polygon, and two successive pairs are the endpoints of a line that is a side of the polygon. The first and final pairs of (x,y) points are joined by a line segment that closes the polygon.
To draw or fill a Polygon Use the Graphics methods g. drawPolygon(p) or g. fillPolygon(p) to draw or fill a polygon, where p is the polygon.
You can use a Path2D
(or a Path2D.Float
or Path2D.Double
) to get the same effect.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With