canvas 로 곡선 그리기
html)
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 37 38 39 40 41 | <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, height=device-height, minimum-scale=1.0, maximum-scale=1.0, initial-scale=1.0"> <title>Insert title here</title> <script type="text/javascript"> window.onload = function(){ var canvas = document.getElementById("canvas"); if(canvas.getContext){ var draw = canvas.getContext("2d"); //조절점이 1개 draw.beginPath(); draw.moveTo(50,50); //quadraticCurveTo(조절점x, 조절점y, 선의 끝점x, 선의 끝점y) draw.quadraticCurveTo(150, 200, 250, 50); draw.lineWidth = 10; draw.strokeStyle = "green"; draw.stroke(); //조절점이 2개 draw.beginPath(); draw.moveTo(50,200); //bezierCurveTo(조절점1x, 조절점1y, 조절점2x, 조절점2y, 선의 끝점x, 선의 끝점y) draw.bezierCurveTo(100,300, 200,100, 250,200); draw.lineWidth = 10; draw.strokeStyle = "blue"; draw.stroke(); } } </script> </head> <body> <canvas id="canvas" width="300px" height="400px"></canvas> </body> </html> | cs |
결과
'IT > - 프로그래밍' 카테고리의 다른 글
HTML5/CSS3 canvas 로 사각형 그리기 (0) | 2017.07.08 |
---|---|
HTML5/CSS3 canvas 로 삼각형 그리기 (0) | 2017.07.07 |
HTML5/CSS3 canvas 로 원그리기 (0) | 2017.07.05 |
HTML5/CSS3 canvas 로 line 그리기 (0) | 2017.07.04 |
HTML5/CSS3 audio : 사운드 파일 재생하기 (0) | 2017.07.03 |