To start points and lines are not shapes, and a triangle is not representable with a single function, therefore you need a function to draw shapes , given a number of points as parameters, and one to draw math functions (lines etc.).
Here is an example:
Draw Line, Ellipse, Polygon ...From website above, here is script in JS:
"<script type="text/javascript">
<!--
function myDrawFunction()
{
jg_doc.setColor("#00ff00");
// green
jg_doc.fillEllipse(100, 200, 100, 180);
// co-ordinates related to the document
jg_doc.setColor("maroon");
jg_doc.drawPolyline(new Array(50, 10, 120), new Array(10, 50, 70));
jg_doc.paint();
// draws, in this case, directly into the document
jg.setColor("#ff0000");
// red
jg.drawLine(10, 113, 220, 55);
// co-ordinates related to "myCanvas"
jg.setColor("#0000ff");
// blue
jg.fillRect(110, 120, 30, 60);
jg.paint();
jg2.setColor("#0000ff");
// blue
jg2.drawEllipse(10, 50, 30, 100);
jg2.drawRect(400, 10, 100, 50);
jg2.paint();
}
var jg_doc = new jsGraphics();
// draw directly into document
var jg = new jsGraphics("myCanvas");
var jg2 = new jsGraphics("anotherCanvas");
myDrawFunction();
//-->
</script>"
×