File hp/display/Graphics.lua
Functions
M:clear () | Clears the drawing operations. |
M:copyParams (params) | Based on the parameters, and then call the function setter. |
M:drawCircle (x, y, r, steps) | Draw a circle. |
M:drawEllipse (x, y, xRad, yRad, steps, Position) | Draw an ellipse. |
M:drawLine (...) | Draws a line. |
M:drawPoints (...) | Draws a point. |
M:drawRay (x, y, dx, dy) | Draw a ray. |
M:drawRect (x0, y0, x1, y1) | Draw a rectangle. |
M:fillCircle (x, y, r, steps) | Fill the circle. |
M:fillEllipse (x, y, xRad, yRad, steps) | Fill an ellipse. |
M:fillFan (...) | Fills the triangle. |
M:fillRect (x0, y0, x1, y1) | Fill a rectangle. |
M:init (params) | The constructor. |
M:setPenColor (r, g, b, a) | Sets the color of the pen. Will be reflected in the drawing functions. |
M:setPenWidth (width) | Set the size of the pen that you specify. Will be reflected in the drawing functions. |
M:setPointSize (size) | Set the size of the specified point. Will be reflected in the drawing functions. |
M:setSize (width, height) | Set the height and width. |
Tables
Graphics | The DisplayObject that has graphics capabilities. |
Functions
- M:clear ()
-
Clears the drawing operations.
Return value:
self - M:copyParams (params)
-
Based on the parameters, and then call the function setter.
Parameters
-
params: Parameter is set to Object.
-
params: Parameter is set to Object.
- M:drawCircle (x, y, r, steps)
-
Draw a circle.
Parameters
- x: Position of the left.
- y: Position of the top.
- r: Radius.(Not in diameter.)
- steps: Number of points.
Return value:
self - M:drawEllipse (x, y, xRad, yRad, steps, Position)
-
Draw an ellipse.
Parameters
- x:
- y:
- xRad: Radius.(Not in diameter.)
- yRad: Radius.(Not in diameter.)
- steps: Number of points.
- Position: of the top.
Return value:
self - M:drawLine (...)
-
Draws a line.
Parameters
- ...: Position of the points(x0, y0).
Return value:
self - M:drawPoints (...)
-
Draws a point.
Parameters
- ...: Position of the points(x0, y0).
Return value:
self - M:drawRay (x, y, dx, dy)
-
Draw a ray.
Parameters
- x: Position of the left.
- y: Position of the top.
- dx: Direction.
- dy: Direction.
Return value:
self - M:drawRect (x0, y0, x1, y1)
-
Draw a rectangle.
Parameters
- x0: Position of the left.
- y0: Position of the top.
- x1: Position of the right.
- y1: Position of the bottom
Return value:
self - M:fillCircle (x, y, r, steps)
-
Fill the circle.
Parameters
- x: Position of the left.
- y: Position of the top.
- r: Radius.(Not in diameter.)
- steps: Number of points.
Return value:
self - M:fillEllipse (x, y, xRad, yRad, steps)
-
Fill an ellipse.
Parameters
- x: Position of the left.
- y: Position of the top.
- xRad: Radius.(Not in diameter.)
- yRad: Radius.(Not in diameter.)
- steps: Number of points.
Return value:
self - M:fillFan (...)
-
Fills the triangle.
Parameters
- ...: Position of the points(x0, y0).
Return value:
self - M:fillRect (x0, y0, x1, y1)
-
Fill a rectangle.
Parameters
- x0: Position of the left.
- y0: Position of the top.
- x1: Position of the right.
- y1: Position of the bottom.
Return value:
self - M:init (params)
-
The constructor.
Parameters
-
params: (option)Parameter is set to Object.
(params:width, height)
-
params: (option)Parameter is set to Object.
- M:setPenColor (r, g, b, a)
-
Sets the color of the pen.
Will be reflected in the drawing functions.Parameters
- r: red
- g: green
- b: blue
- a: alpha
Return value:
self - M:setPenWidth (width)
-
Set the size of the pen that you specify.
Will be reflected in the drawing functions.Parameters
- width: width
Return value:
self - M:setPointSize (size)
-
Set the size of the specified point.
Will be reflected in the drawing functions.Parameters
- size:
Return value:
self - M:setSize (width, height)
-
Set the height and width.
Parameters
- width: width
- height: height
Tables
- Graphics
- The DisplayObject that has graphics capabilities.
You can call in the method chain MOAIDraw.
See MOAIDraw.
Base Classes => DisplayObject, Resizable
example)
local g = Graphics({width = 100, height = 100})
g:setPenColor(1, 0, 0, 1):fillRect():drawRect()
g:setPenColor(0, 1, 0, 1):fillRect(25, 25, 50, 50):drawRect(25, 25, 50, 50)
g:setLayer(layer)