canvas.strokePoly

canvas.strokePoly(xarray, yarray, color)

or

canvas.strokePoly(xyarray, color)

Stroke a polygon through the points defined in xytable with a specific color. The width of the line is the last value passed to canvas.setLineWidth or 1 if no width has ever been specified.

Parameters:
    xarray - An array of x values   
    yarray - An array of y values  
    xyarray - A JS array of objects [{x:x1,y:y1},{x:x2,y:y2}...].  Can be used instead of xarray, yarray
    color -  An RGB color value as an integer value

Example

// Stroke a triangle using a polygon
function StrokeRedTrianglePoly(name) {    
    var canvas = sb.getCanvas(name);    
    var mid = canvas.width / 2;    

    //Shrink the bounds to make the lines visible    
    var height = canvas.height - 2;    
    var width = canvas.width - 2;    
    const pts = [];    
    pts[0] = {x:2,y:2};    
    pts[1] = {x:mid,y :height};    
    pts[2] = {x:width,y:2};    
    pts[3] = pts[0];  //Close the polygon    
    canvas.strokePoly(pts, 0xff0000)
}
Was this article helpful?
0 out of 0 found this helpful