numVerts()
Purpose
Find the number of vertices (points) in a shape
Description
Returns the number of vertices (points) in a shape drawn with drawShape()
Syntax
points = numVerts( shape )
Arguments
shape Handle which stores the shape in question
points Integer number of vertices (points) in the shape
Example
c = controls( 0 )
oldc = controls( 0 )
gw = gWidth()
gh = gHeight()
points = [
{ random( gw ), random( gh ) + 100 },
{ random( gw ), random( gh ) + 100 },
{ random( gw ), random( gh ) + 100 }
]
shape = createPoly( points )
vertices = numVerts( shape )
loop
clear()
c = controls( 0 )
if c.a and !oldc.a then
points[len( points )] = { random( gw ), random( gh ) + 100 }
deleteShape( shape )
shape = createPoly( points )
vertices = numVerts( shape )
for i = 0 to vertices loop
setVertexColour( shape, i, { random( 1.0 ), random( 1.0 ), random( 1.0 ), 1 } )
repeat
endif
drawShape( shape )
printAt( 0, 0, "Press the A button to add a vertex. Current vertex count: ", vertices )
oldc = c
update()
repeat
Associated Commands
copyShape(), createBox(), createCircle(), createCurve(), createLine(), createLineStrip(), createPoly(), createStar(), createTriangle(), deleteShape(), drawShape(), getShapeBounds(), getShapeLocation(), getShapeRotation(), getShapeScale(), getShapeTint(), getVertex(), getVertexColour(), getVertexLineColour(), getVertexLineThickness(), joinShapes(), moveShape(), rotateShape(), scaleShape(), setShapeColour(), setShapeLineStyle(), setShapeRotation(), setShapeScale(), setShapeScaleModeLocal(), setShapeTint(), setVertex(), setVertexColour(), setVertexLineStyle()