with_with |
with(canvas){ style.border = "1px solid grey"; style.backgroundColor = "gainsboro"; width = 600; height = 600; }
with(context){ beginPath(); moveTo(0, 0); lineTo(centerX, centerY); lineTo((centerX * 2), 0); closePath(); fillStyle = "darkred"; fill(); beginPath(); moveTo(0, 0); lineTo(centerX, centerY); lineTo(0, centerY * 2); closePath(); fillStyle = "green"; fill(); beginPath(); moveTo(0, centerY * 2); lineTo(centerX, centerY); lineTo(centerX * 2, centerY * 2); closePath(); fillStyle = "brown"; fill(); beginPath(); moveTo(centerX * 2, centerY * 2); lineTo(centerX, centerY); lineTo(centerX * 2, 0); closePath(); fillStyle = "darkgreen"; fill(); fillStyle = "gold"; fillRect((centerX / 2), (centerY / 2), 150, 150); fillStyle = "silver"; fillRect(centerX, centerY, 150, 150); }
|
pending… |
without_with |
canvas.style.border = "1px solid grey"; canvas.style.backgroundColor = "gainsboro"; canvas.width = 600; canvas.height = 600; context.beginPath(); context.moveTo(0, 0); context.lineTo(centerX, centerY); context.lineTo((centerX * 2), 0); context.closePath(); context.fillStyle = "darkred"; context.fill(); context.beginPath(); context.moveTo(0, 0); context.lineTo(centerX, centerY); context.lineTo(0, centerY * 2); context.closePath(); context.fillStyle = "green"; context.fill(); context.beginPath(); context.moveTo(0, centerY * 2); context.lineTo(centerX, centerY); context.lineTo(centerX * 2, centerY * 2); context.closePath(); context.fillStyle = "brown"; context.fill(); context.beginPath(); context.moveTo(centerX * 2, centerY * 2); context.lineTo(centerX, centerY); context.lineTo(centerX * 2, 0); context.closePath(); context.fillStyle = "darkgreen"; context.fill(); context.fillStyle = "gold"; context.fillRect((centerX / 2), (centerY / 2), 150, 150); context.fillStyle = "silver"; context.fillRect(centerX, centerY, 150, 150);
|
pending… |
0 comments