1 | initial version |
An oval or rectangle can be created using float or double values by defining the coordinates of their respective points using the data type float or double. For example, to create an oval, the center point and the radius can be defined using float or double values as shown below:
float centerX = 100.0f; float centerY = 100.0f; float radiusX = 50.0f; float radiusY = 30.0f;
ellipse(centerX, centerY, radiusX, radiusY);
To create a rectangle, the x, y coordinates of its top-left corner and the width and height of the rectangle can be defined using float or double values as shown below:
float x = 50.0f; float y = 50.0f; float width = 100.0f; float height = 50.0f;
rect(x, y, width, height);