1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| <!DOCTYPE html> <html> <head> <title>Canvas</title> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <style> body { margin: 0; } .canvas { width: 500px; height: 300px; background: #eee; } </style> </head>
<body> <h1>캔버스 사이즈 설정</h1> <canvas class="canvas" width="500" height="300"></canvas> <canvas class="canvas canvas2" width="1000" height="600"></canvas>
<script> const canvas = document.querySelector(".canvas"); const canvas2 = document.querySelector(".canvas2"); const context = canvas.getContext("2d"); const context2 = canvas2.getContext("2d");
context.arc(100, 100, 50, 0, Math.PI * 2, false); context2.arc(100, 100, 50, 0, Math.PI * 2, false); context.fill(); context2.fill(); </script> </body> </html>
|