I have a canvas which will hold a moderate to large amount of shapes (50-500).
I have succeeded in drawing the outline of the shape I would like using these tools:
function DrawPolygon(diagramLayer, polygon) {
var diagramImage = new Kinetic.Shape(function () {
var context = this.getContext();
context.beginPath();
context.lineWidth = 1;
context.strokeStyle = "#ff0000";
var lastVertice = polygon.Vertices[polygon.Vertices.length - 1];
context.moveTo(lastVertice.X, lastVertice.Y);
for (var i = 0; i < polygon.Vertices.length; i++) {
var vertice = polygon.Vertices[i];
context.lineTo(vertice.X, vertice.Y);
}
context.stroke();
context.closePath();
});
diagramImage.on("mouseover", function () {
});
diagramLayer.add(diagramImage);
planViewStage.add(diagramLayer);
}
I would like to change diagramImage's context's strokeStyle to a different color on mouseOver. I understand that the canvas element does not keep track of 'state' and, as such, has no idea that there is a shape on it currently.
I am wondering a few things:
Here's a lab that shows how you can change a shape's color with mouseover:
http://www.html5canvastutorials.com/labs/html5-canvas-interactive-flower/