Fork me on GitHub
View source

package haxepunk.utils

class DrawContext

Constructor

View source

new (lineThickness : Float = 1, color : Color = Color.White, alpha : Float = 1) : Void

Variables

alpha : Float

The alpha value to draw. Ranges between 0-1 where 0 is completely transparent and 1 is opaque.

blend : BlendMode

The blending mode used by Draw functions. This will not apply to Draw.line(), but will apply to Draw.linePlus().

color : Color

The red, green, and blue values in a single integer value.

lineThickness : Float

The line thickness to use when drawing lines. Defaults to a single pixel wide.

scene : Scene

The Scene to draw to. If null, will draw to the current active scene.

shader : Shader

The shader used by Draw functions. This will default to a color shader if not set.

smooth : Bool

Whether shapes should be drawn with antialiasing.

Functions

View source

arc (x : Float, y : Float, radius : Float, start : Float, angle : Float, segments : Int = 25) : Void

Draws a circle to the screen.


Parameters:
x   

X position of the circle's center.

y   

Y position of the circle's center.

radius   

Radius of the circle.

start   

The starting angle in radians.

angle   

The arc size in radians.

segments   

Increasing will smooth the circle but takes longer to render. Must be a value greater than zero.

View source

circle (x : Float, y : Float, radius : Float, segments : Int = 25, scaleX : Float = 1, scaleY : Float = 1) : Void

Draws a circle to the screen.


Parameters:
x   

X position of the circle's center.

y   

Y position of the circle's center.

radius   

Radius of the circle.

segments   

Increasing will smooth the circle but takes longer to render. Must be a value greater than zero.

scaleX   

Scales the circle horizontally.

scaleY   

Scales the circle vertically.

View source

circleFilled (x : Float, y : Float, radius : Float, segments : Int = 25, scaleX : Float = 1, scaleY : Float = 1) : Void

Draws a circle to the screen.


Parameters:
x   

X position of the circle's center.

y   

Y position of the circle's center.

radius   

Radius of the circle.

segments   

Increasing will smooth the circle but takes longer to render. Must be a value greater than zero.

scaleX   

Scales the circle horizontally.

scaleY   

Scales the circle vertically.

View source

curve (x1 : Int, y1 : Int, x2 : Int, y2 : Int, x3 : Int, y3 : Int, segments : Int = 25) : Void

Draws a quadratic curve.


Parameters:
x1   

X start.

y1   

Y start.

x2   

X control point, used to determine the curve.

y2   

Y control point, used to determine the curve.

x3   

X finish.

y3   

Y finish.

segments   

Increasing will smooth the curve but takes longer to render. Must be a value greater than zero.

View source

line (x1 : Float, y1 : Float, x2 : Float, y2 : Float) : Void

Draws a straight line.


Parameters:
x1   

Starting x position.

y1   

Starting y position.

x2   

Ending x position.

y2   

Ending y position.

View source

polyline (points : Array<Float>, miterJoint : Bool = false) : Void

Draws a triangulated line polyline to the screen. This must be a closed loop of concave lines


Parameters:
points   

An array of floats containing the points of the polyline. The array is ordered in x, y format and must have an even number of values.

View source

rect (x : Float, y : Float, width : Float, height : Float) : Void

Draws a rectangle outline. Lines are drawn inside the width and height.


Parameters:
x   

X position of the rectangle.

y   

Y position of the rectangle.

width   

Width of the rectangle.

height   

Height of the rectangle.


Available since:

2.5.2

View source

rectFilled (x : Float, y : Float, width : Float, height : Float) : Void

Draws a filled rectangle.


Parameters:
x   

X position of the rectangle.

y   

Y position of the rectangle.

width   

Width of the rectangle.

height   

Height of the rectangle.


Available since:

4.0.0

View source

setColor (color : Color = 0xFFFFFF, alpha : Float = 1) : Void

Convenience function to set both color and alpha at the same time.