ar4ipers,
мысли вслух ...
if (checkStarCollision(selectPoligon, list[i])) {
ctx.fillStyle = "red";
}
else {
ctx.fillStyle = "black";
}
if (checkStarCollision(selectPoligon, list[i])) {
list[i].color = "red";
}
else {
list[i].color = "black";
}
function drawPoligon(poligon) {
ctx.beginPath();
*!*
ctx.fillStyle = poligon.color ? poligon.color : curentColor;
*/!*
ctx.moveTo(poligon.points[0].x, poligon.points[0].y);
for (var i = 1; i < poligon.points.length; i++) {
ctx.lineTo(poligon.points[i].x, poligon.points[i].y);
}
ctx.closePath();
ctx.fill();
}
if (ctx.isPointInPath(mousePos.x, mousePos.y)) {
isDragging = true;
list[i].bool = true;
*!*
selectPoligon = list[i];
*/!*
delta.x = list[i].x - mousePos.x;
delta.y = list[i].y - mousePos.y;
break;
}