canvas

kirin.logยท2021๋…„ 4์›” 24์ผ
0
post-custom-banner

๐Ÿš— canvas

  • Canvas API๋Š” JavaScript์™€ HTML <canvas> ์—˜๋ฆฌ๋จผํŠธ๋ฅผ ํ†ตํ•ด ๊ทธ๋ž˜ํ”ฝ์„ ๊ทธ๋ฆฌ๊ธฐ์œ„ํ•œ ์ˆ˜๋‹จ์„ ์ œ๊ณตํ•œ๋‹ค.
  • ์• ๋‹ˆ๋ฉ”์ด์…˜, ๊ฒŒ์ž„ ๊ทธ๋ž˜ํ”ฝ, ๋ฐ์ดํ„ฐ ์‹œ๊ฐํ™”, ์‚ฌ์ง„ ์กฐ์ž‘ ๋ฐ ์‹ค์‹œ๊ฐ„ ๋น„๋””์˜ค ์ฒ˜๋ฆฌ๋ฅผ ์œ„ํ•ด ์‚ฌ์šฉ๋œ๋‹ค.
  • Canvas API๋Š” ์ฃผ๋กœ 2D ๊ทธ๋ž˜ํ”ฝ์— ์ค‘์ ์„ ๋‘๊ณ  ์žˆ๋‹ค
๐Ÿ‘‰html

<canvas id="canvas" width="150" height="150"></canvas>

<!--
<canvas> ์š”์†Œ์—๋Š” width์™€ height์˜ ๋‘ ์†์„ฑ๋งŒ ์žˆ๋‹ค. 
์ด๊ฒƒ๋“ค์€ ๋ชจ๋‘ ์„ ํƒ์‚ฌํ•ญ์ด๋ฉฐ DOM ํ”„๋กœํผํ‹ฐ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์„ค์ •ํ•  ์ˆ˜๋„ ์žˆ๋‹ค.
-->
๐Ÿ‘‰js

let canvas = document.getElementById('canvas');
let ctx = canvas.getContext('2d');

//  <canvas> ์š”์†Œ๋Š” getContext() ๋ฉ”์„œ๋“œ๋ฅผ ์ด์šฉํ•ด์„œ ๊ทธ๋ฆฌ๊ธฐ ํ•จ์ˆ˜๋“ค์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค
profile
boma91@gmail.com
post-custom-banner

0๊ฐœ์˜ ๋Œ“๊ธ€