<!--<!DOCTYPE html> <html lang="ko"> <head> <meta charset="UTF-8"> <title>픽셀 아트</title> </head> <body> <canvas id="canvas" width="200px"; height="200px"></canvas> <script type="text/javascript"> var canvas = document.getElementById("canvas"); var pxDraw = canvas.getContext("2d"); pxDraw.fillRect(0,0,10,10); </script> </body> </html>--> <!--<!DOCTYPE html> <html lang="ko"> <head> <meta charset="UTF-8"> <title>픽셀 아트</title> </head> <body> <canvas id="canvas" width="200px"; height="200px"></canvas> <script type="text/javascript"> var canvas = document.getElementById("canvas"); var pxDraw = canvas.getContext("2d"); pxDraw.fillStyle = "red"; pxDraw.fillRect(0,0,10,10); pxDraw.fillRect(20,0,10,10); </script> </body> </html>--> <!DOCTYPE html> <html lang="ko"> <head> <meta charset="UTF-8"> <title>픽셀 아트</title> </head> <body> <canvas id="canvas" width="200px"; height="200px"></canvas> <script type="text/javascript"> var canvas = document.getElementById("canvas"); var pxDraw = canvas.getContext("2d"); // 첫 번째 줄 pxDraw.fillStyle = "black"; for(var i=0; i<8; i++) { pxDraw.fillRect(i*10, 0, 10, 10); pxDraw.fillRect(i*10, 10, 10, 10); } // 두 번째 줄 pxDraw.fillRect(0, 20, 10, 10); pxDraw.fillRect(70, 20, 10, 10); for(var i=1; i<7; i++) { pxDraw.fillRect(i*10, 20, 10, 10); pxDraw.fillRect(i*10, 30, 10, 10); } // 세 번째 줄 for(var i=0; i<8; i++) { pxDraw.fillRect(i*10, 30, 10, 10); } // 네 번째 줄 pxDraw.fillRect(0, 40, 10, 10); pxDraw.fillStyle = "blue"; pxDraw.fillRect(20, 40, 10, 10); pxDraw.fillRect(50, 40, 10, 10); pxDraw.fillStyle = "bisque"; pxDraw.fillRect(30, 40, 10, 10); pxDraw.fillRect(40, 40, 10, 10); pxDraw.fillStyle = "black"; pxDraw.fillRect(70, 40, 10, 10); pxDraw.fillStyle = "bisque"; // 다섯 번째 줄 for(var i=0; i<3; i++) { pxDraw.fillRect(i*10, 50, 10, 10); } pxDraw.fillStyle = "sienna"; pxDraw.fillRect(30, 50, 10, 10); pxDraw.fillRect(40, 50, 10, 10); pxDraw.fillStyle = "bisque"; for(var i=5; i<8; i++) { pxDraw.fillRect(i*10, 50, 10, 10); } // 여섯 번째 줄 pxDraw.fillRect(0, 60, 10, 10); pxDraw.fillRect(10, 60, 10, 10); pxDraw.fillRect(60, 60, 10, 10); pxDraw.fillRect(70, 60, 10, 10); pxDraw.fillStyle = "black"; for(var i=2; i<6; i++) { pxDraw.fillRect(i*10, 60, 10, 10); } // 일곱 번째 줄 pxDraw.fillStyle = "bisque"; for(var i=0; i<8; i++) { pxDraw.fillRect(i*10, 70, 10, 10); } </script> </body> </html>
|