Game Development Reference
In-Depth Information
function onDraw ( index, xOff, yOff, xFlip, yFlip )
MOAIDraw.drawRay ( 0, 0, 1, 0)
MOAIDraw.drawRay ( 0, 0, 0, 1)
MOAIGfxDevice.setPointSize(5)
MOAIGfxDevice.setPenColor(1,0,0,1)
MOAIDraw.drawPoints(-50,50,50,50,50,-50,-50,-50,-50,50)
end
The Drawing Attributes
The canvas on which MOAIDraw draws the vector primitives is called MOAIGfxDevice . You can query
it and set certain drawing attributes, such as the color, line width, and point size. This section will
describe each of these.
Color
The MOAIGfxDevice.setPenColor function is used to set the color for drawing and filling. The syntax
for setting the color is setPenColor(r, g, b, a) . The values for r , g , b , and a are in the range of 0 to 1.
For example, the following line sets the color to green:
MOAIGfxDevice.setPenColor(0,1,0,1)
Line Width
The MOAIGfxDevice.setPenWidth function sets the width of any line drawn after the function call. The
function is passed a width value, which determines how thick the line is usually expressed in positive
integer units.
function onDraw ( index, xOff, yOff, xFlip, yFlip )
MOAIGfxDevice.setPenWidth(3)
MOAIGfxDevice.setPenColor(1,0,0,1)
MOAIDraw.drawRect(-50,-50,50,50)
end
Point Size
The MOAIGfxDevice.setPointSize function sets the size of the points that are drawn using the
drawPoints function usually expresses in positive integer units.
function onDraw ( index, xOff, yOff, xFlip, yFlip )
MOAIDraw.drawRay ( 0, 0, 1, 0)
MOAIDraw.drawRay ( 0, 0, 0, 1)
MOAIGfxDevice.setPointSize(5)
MOAIGfxDevice.setPenColor(1,0,0,1)
MOAIDraw.drawPoints(-50,50,50,50,50,-50,-50,-50,-50,50)
end
 
Search WWH ::




Custom Search