Package org.lazywizard.lazylib
Class ShapeUtils
Object
ShapeUtils
Provides methods to calculate vertices of common shapes. Equivalent
algorithms to
DrawUtils, but returns the raw vertices
instead of drawing them for you. These float arrays can be converted
to a List of Vector2fs if needed by calling
VectorUtils.toVectorList(float[]) on them.- Since:
- 3.0
- Author:
- LazyWizard
-
Method Summary
Modifier and TypeMethodDescriptionstatic float[]createArc(float centerX, float centerY, float radius, float startAngle, float arcAngle, int numSegments) Creates the vertices for an arc shape.static float[]createCircle(float centerX, float centerY, float radius, int numSegments) Creates the vertices for a simple circle.static float[]createEllipse(float centerX, float centerY, float width, float height, float angleOffset, int numSegments) Creates the vertices for an elliptical shape.
-
Method Details
-
createCircle
public static float[] createCircle(float centerX, float centerY, float radius, int numSegments) Creates the vertices for a simple circle.Optimized circle-drawing algorithm based on code taken from: http://slabode.exofire.net/circle_draw.shtml
- Parameters:
centerX- The x value of the center point of the circle.centerY- The y value of the center point of the circle.radius- The radius of the circle to be drawn.numSegments- How many line segments the circle should be made up of (higher number = smoother circle).- Returns:
- The vertices needed to draw a circle with the given parameters.
- Since:
- 3.0
-
createEllipse
public static float[] createEllipse(float centerX, float centerY, float width, float height, float angleOffset, int numSegments) Creates the vertices for an elliptical shape.Optimized circle-drawing algorithm based on code taken from: http://slabode.exofire.net/circle_draw.shtml
- Parameters:
centerX- The x value of the center point of the circle.centerY- The y value of the center point of the circle.width- The width (size on unrotated x-axis) of the ellipse.height- The height (size on unrotated y-axis) of the ellipse.angleOffset- How much to rotate the ellipse from its original axis, in degrees.numSegments- How many line segments the ellipse should be made up of (higher number = smoother ellipse).- Returns:
- The vertices needed to draw an ellipse with the given parameters.
- Since:
- 3.0
-
createArc
public static float[] createArc(float centerX, float centerY, float radius, float startAngle, float arcAngle, int numSegments) Creates the vertices for an arc shape.Optimized arc-drawing algorithm based on code taken from: http://slabode.exofire.net/circle_draw.shtml
- Parameters:
centerX- The x value of the center point of the arc.centerY- The y value of the center point of the arc.radius- The radius of the arc to be drawn.startAngle- The angle the arc should start at, in degrees.arcAngle- The size of the arc, in degrees.numSegments- How many line segments the arc should be made up of (higher number = smoother arc).- Returns:
- The vertices needed to draw an arc with the given parameters.
- Since:
- 3.0
-