createTriangle()

Purpose

Creates a triangle to be drawn with drawShape()

Description

Creates a triangle with centre origin to be drawn at the specified x and y locations

Syntax

shape = createTriangle( x1, y1, x2, y2, x3, y3 )

Arguments

shape Handle which stores the newly created shape

x1 Horizontal screen position in pixels of the first point

y1 Vertical screen position in pixels of the first point

x2 Horizontal screen position in pixels of the second point

y2 Vertical screen position in pixels of the second point

x3 Horizontal screen position in pixels of the third point

y3 Vertical screen position in pixels of the third point

Example

// draw a multicoloured triangle on the screen
x = 0
y = 1

points = [
    [ gwidth() / 3, gheight() / 3 ],
    [ gwidth() / 3 + gwidth() / 3, gheight() / 3 ],
    [ gwidth() / 2, gheight() - gheight() / 3 ]
]

shape_1 = createTriangle( points[0][x], points[0][y], points[1][x], points[1][y], points[2][x], points[2][y] )

setVertexColour( shape_1, 0, red )
setVertexColour( shape_1, 1, green )
setVertexColour( shape_1, 2, blue )

drawShape( shape_1 )
update()
sleep( 3 )

Associated Commands

copyShape(), createBox(), createCircle(), createCurve(), createLine(), createLineStrip(), createPoly(), createStar(), deleteShape(), drawShape(), getShapeBounds(), getShapeLocation(), getShapeRotation(), getShapeScale(), getShapeTint(), getVertex(), getVertexColour(), getVertexLineColour(), getVertexLineThickness(), joinShapes(), moveShape(), numVerts(), rotateShape(), scaleShape(), setShapeColour(), setShapeLineStyle(), setShapeRotation(), setShapeScale(), setShapeScaleModeLocal(), setShapeTint(), setVertex(), setVertexColour(), setVertexLineStyle()