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