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