Class Shape
java.lang.Object
org.openpatch.scratch.extensions.shape.Shape
Represents a generic shape that can be transformed and drawn.
This class serves as a base for specific shapes like Rectangle, Circle, and
Ellipse.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancontains(double x, double y) Check if the shape contains a point defined by its x and y coordinates.voiddraw(processing.core.PGraphics buffer) Get the bounds of the shape.booleanintersects(Shape other) Check if the shape intersects with another shape.rotate(double theta, double anchorX, double anchorY) Rotate the shape by the specified angle around a given anchor point.scale(double scaleX, double scaleY) Check if the shape is empty.translate(double dx, double dy) Translate the shape by the specified distances in the x and y directions.
-
Field Details
-
awtShape
-
-
Constructor Details
-
Shape
protected Shape()
-
-
Method Details
-
contains
public boolean contains(double x, double y) Check if the shape contains a point defined by its x and y coordinates.- Parameters:
x- the x-coordinate of the pointy- the y-coordinate of the point- Returns:
- true if the shape contains the point, false otherwise
-
intersects
Check if the shape intersects with another shape.- Parameters:
other- the other shape to check intersection with- Returns:
- true if the shapes intersect, false otherwise
-
scale
Check if the shape is empty.- Returns:
- true if the shape is empty, false otherwise
-
translate
Translate the shape by the specified distances in the x and y directions.- Parameters:
dx- the distance to translate in the x directiondy- the distance to translate in the y direction- Returns:
- a new Shape object that is translated
-
rotate
Rotate the shape by the specified angle around a given anchor point.- Parameters:
theta- the angle in degrees to rotateanchorX- the x-coordinate of the anchor pointanchorY- the y-coordinate of the anchor point- Returns:
- a new Shape object that is rotated
-
getBounds
Get the bounds of the shape.- Returns:
- a Bounds object representing the bounding box of the shape
-
draw
public void draw(processing.core.PGraphics buffer)
-