Drawing Rectangles

From Progzoo
Jump to navigation Jump to search

There are methods to draw and fill rectangles built into the graphics libraries.

Draw Rectangle

The method Graphics method drawRect(x,y,width,height) can be used to draw a rectangle with the current line style and colour. The top left corner is specified by (x,y) the width and height are as specified.

A Drawn Rectangle

[Font] [Default] [Show] [Resize] [History] [Profile]

Fill Rectangle

A Filled Rectangle

[Font] [Default] [Show] [Resize] [History] [Profile]

Rounded Rectangle

The methods drawRoundRect(x,y,width,height,rx,ry) draws a rectangle with rounded corners.

  • x,y Top left corner of the rectangle
  • width, height the width and height of the rectangle
  • rx, ry The radius of the corners in the x and y directions
A Rectangle with Rounded Corners

[Font] [Default] [Show] [Resize] [History] [Profile]