LazyLib

org.lazywizard.lazylib.opengl
Class DrawUtils

Object
  extended by DrawUtils

public class DrawUtils
extends Object

Contains methods to draw simple 2D shapes using OpenGL primitives. These methods only contain the actual drawing code and assumes all OpenGL flags, color, line width etc have been set by the user beforehand.

Since:
1.7
Author:
LazyWizard

Method Summary
static void drawArc(float centerX, float centerY, float radius, float startAngle, float arcAngle, int numSegments)
          Draws an arc made up of line segments.
static void drawCircle(float centerX, float centerY, float radius, int numSegments, boolean drawFilled)
          Draws a simple circle made of line segments, or a filled circle if drawFilled is true.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

drawCircle

public static void drawCircle(float centerX,
                              float centerY,
                              float radius,
                              int numSegments,
                              boolean drawFilled)
Draws a simple circle made of line segments, or a filled circle if drawFilled is true.

This method only contains the actual drawing code and assumes all OpenGL flags, color, line width etc have been set by the user beforehand. Due to the way this works, this can be used to make any regular polygon with a number of sides equal to numSegments.

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 (in pixels) of the circle to be drawn.
numSegments - How many line segments the circle should be made up of (higher number = smoother circle, but higher GPU cost).
drawFilled - Whether the circle should be hollow or filled.

Since:
1.7

drawArc

public static void drawArc(float centerX,
                           float centerY,
                           float radius,
                           float startAngle,
                           float arcAngle,
                           int numSegments)
Draws an arc made up of line segments.

This method only contains the actual drawing code and assumes all OpenGL flags, color, line width etc have been set by the user beforehand. Due to the way this works, this can be used to make any regular polygon with a number of sides equal to numSegments if arcAngle is set to 360.

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 (in pixels) 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, but higher GPU cost).

Since:
1.7

LazyLib