Rysowanie wielokąta nieregularnego (1)
Klasa używa skryptu figures.js
Listing
var cv = document.getElementById("canvas"); var ctx = cv.getContext("2d"); var points = new IrregPolygon(new Point(20, 20), new Point(70, 70), new Point(70, 130), new Point(30, 120), new Point(10, 100)); points.fillStyle = "red"; points.strokeStyle = "blue"; points.fill = true; points.stroke = true; points.lineWidth = 5; points.draw(ctx); // var perimeter = points.perimeter(); ctx.fillText("obwód: "+ perimeter, 180, 20);