Oval
Ovals are drawn between a starting point (x1, y1) and an ending point (x2, y2). The oval fills the box, touching the center of each side.
Creating an Oval
You can create an Oval using the following functions:
oval = Oval(x1, y1, x2, y2)
Oval(x1, y1, x2, y2, color, fill, thickness, rotation, visibility)
| Parameter | Type | Default | Description |
|---|---|---|---|
x1 |
int or float |
required | The horizontal position of the box's top-left corner, in pixels. |
y1 |
int or float |
required | The vertical position of the box's top-left corner, in pixels. |
x2 |
int or float |
required | The horizontal position of the box's bottom-right corner, in pixels. |
y2 |
int or float |
required | The vertical position of the box's bottom-right corner, in pixels. |
color |
Color |
Color.BLACK |
The color. |
fill |
bool |
False |
Whether the oval is filled in (True) or just an outline (False). |
thickness |
int |
1 |
The outline thickness, in pixels. |
rotation |
int or float |
0 |
How far to turn the oval, in degrees, counter-clockwise. |
visibility |
int |
100 |
How visible the oval is, from 0 (invisible) to 100 (fully visible). |
For example,
oval = Oval(50, 30, 100, 150)
Once created, you can add it to a Display using the Display's add() function.
Functions
Once an Oval oval has been created, the following functions are available:
Position
| Function | Description |
|---|---|
oval.getPosition() |
Return the object's position, the top-left corner of its bounding box. |
oval.getX() |
Return the object's horizontal position. |
oval.getY() |
Return the object's vertical position. |
oval.getCenter() |
Return the object's center point. |
oval.getCenterX() |
Return the object's horizontal center. |
oval.getCenterY() |
Return the object's vertical center. |
oval.setPosition(x, y) |
Move the object so the top-left corner of its bounding box sits at the given point. |
oval.setX(x) |
Set the object's horizontal position. |
oval.setY(y) |
Set the object's vertical position. |
oval.setCenter(x, y) |
Move the object so its center sits at the given point. |
oval.setCenterX(x) |
Set the object's horizontal center. |
oval.setCenterY(y) |
Set the object's vertical center. |
oval.move(x, y) |
Move the object to a new position. |
Size
| Function | Description |
|---|---|
oval.getSize() |
Return the object's width and height. |
oval.getWidth() |
Return the object's width. |
oval.getHeight() |
Return the object's height. |
oval.setSize(width, height) |
Set the object's width and height. |
oval.setWidth(width) |
Set the object's width. |
oval.setHeight(height) |
Set the object's height. |
Rotation
| Function | Description |
|---|---|
oval.getRotation() |
Return how far the object is turned. |
oval.setRotation(rotation) |
Turn the object to a given angle. |
oval.rotate(angle) |
Turn the object by an additional angle. |
Visibility
| Function | Description |
|---|---|
oval.getVisibility() |
Return how visible the object is. |
oval.setVisibility(visibility) |
Set how visible the object is. |
Color
| Function | Description |
|---|---|
oval.getColor() |
Return the shape's color. |
oval.getFill() |
Report whether the shape is filled in. |
oval.getThickness() |
Return the shape's outline thickness. |
oval.setColor() |
Set the shape's color. |
oval.setFill(fill) |
Set whether the shape is filled in. |
oval.setThickness(thickness) |
Set the shape's outline thickness. |
Information
| Function | Description |
|---|---|
oval.getEndpoints() |
Return the object's four corners. |
oval.getBoundingBox() |
Return the smallest upright box that surrounds the object. |
oval.getGroup() |
Return the Group this object belongs to. |
oval.getDisplay() |
Return the Display this object is on. |
oval.setToolTipText() |
Set the hover text shown over the object. |
Hit Testing
| Function | Description |
|---|---|
oval.contains(x, y) |
Report whether a point lies inside the object. |
oval.intersects(other) |
Report whether this object overlaps another. |
oval.encloses(other) |
Report whether this object completely contains another. |
Events
| Function | Description |
|---|---|
oval.onMouseClick(action) |
Set up a function to call when the mouse is clicked on this object. |
oval.onMouseDown(action) |
Set up a function to call when the mouse button is pressed on this object. |
oval.onMouseUp(action) |
Set up a function to call when the mouse button is released over this object. |
oval.onMouseMove(action) |
Set up a function to call when the mouse moves over this object. |
oval.onMouseDrag(action) |
Set up a function to call when the mouse is dragged over this object. |
oval.onMouseEnter(action) |
Set up a function to call when the mouse moves onto this object. |
oval.onMouseExit(action) |
Set up a function to call when the mouse moves off this object. |
oval.onKeyType(action) |
Set up a function to call when a key is typed (pressed and released). |
oval.onKeyDown(action) |
Set up a function to call when a key is pressed down. |
oval.onKeyUp(action) |
Set up a function to call when a key is released. |