1
目前我在畫布2D上下文中使用僞3D形狀。但是,我仍然堅持填充形狀兩側。填充僞3D畫布形狀
這裏的繪圖功能我寫道:
Shape.prototype.draw = function (ctx) {
var offsetX = ctx.canvas.width/2;
var offsetY = ctx.canvas.height/2;
var i = this.edges.length;
while (i--) {
var vertex1 = this.rotatedVertexs[ this.edges[i][0] ];
var vertex2 = this.rotatedVertexs[ this.edges[i][1] ];
ctx.beginPath();
ctx.moveTo(vertex1[0] + offsetX, vertex1[1] + offsetY);
ctx.lineTo(vertex2[0] + offsetX, vertex2[1] + offsetY);
ctx.fill();
ctx.stroke();
}
};
...和一個簡單的例子小提琴:http://jsfiddle.net/ARTsinn/xYZyU/
任何想法我上來的錯嗎?