HTML5 Canvas Draw Image
HTML5 Canvas Draw Image
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
var img = document.getElementById("scream");
ctx.drawImage(img,10,10);
<!DOCTYPE html>
<html>
<body>
<p>Image to use:</p>
<img id="scream" src="img_the_scream.jpg" alt="The Scream" width="220" height="277">
<p>Canvas to fill:</p>
<canvas id="myCanvas" width="250" height="300"
style="border:1px solid #d3d3d3;">
Your browser does not support the HTML5 canvas tag.</canvas>
<p><button onclick="myCanvas()">Try it</button></p>
<script>
function myCanvas() {
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
var img = document.getElementById("scream");
ctx.drawImage(img,10,10);
}
</script>
</body>
</html>
게시판 목록
퍼블리셔팁
퍼블리싱과 관련된 유용한 정보를 공유하세요.
질문은 상단의 QA에서 해주시기 바랍니다.
질문은 상단의 QA에서 해주시기 바랍니다.
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 917 | CSS | 8년 전 | 1902 | ||
| 916 | CSS | 8년 전 | 1994 | ||
| 915 | CSS | 8년 전 | 2012 | ||
| 914 | CSS | 8년 전 | 2932 | ||
| 913 | CSS | 8년 전 | 1955 | ||
| 912 | CSS | 8년 전 | 2023 | ||
| 911 | CSS | 8년 전 | 1993 | ||
| 910 | CSS | 8년 전 | 1863 | ||
| 909 | HTML | 8년 전 | 2295 | ||
| 908 | CSS | 8년 전 | 2226 | ||
| 907 | CSS | 8년 전 | 2058 | ||
| 906 | CSS | 8년 전 | 2310 | ||
| 905 | CSS | 8년 전 | 2048 | ||
| 904 | CSS | 8년 전 | 1839 | ||
| 903 | CSS | 8년 전 | 1968 | ||
| 902 | CSS | 8년 전 | 2185 | ||
| 901 | CSS | 8년 전 | 2067 | ||
| 900 | CSS | 8년 전 | 2497 | ||
| 899 | CSS | 8년 전 | 2478 | ||
| 898 | CSS | 8년 전 | 2052 | ||
| 897 | CSS | 8년 전 | 1677 | ||
| 896 | CSS | 8년 전 | 2327 | ||
| 895 | CSS | 8년 전 | 2003 | ||
| 894 | CSS | 8년 전 | 2617 | ||
| 893 | CSS | 8년 전 | 1980 | ||
| 892 | HTML | 8년 전 | 2068 | ||
| 891 | HTML | 8년 전 | 2537 | ||
| 890 | HTML | 8년 전 | 2622 | ||
| 889 | HTML | 8년 전 | 3725 | ||
| 888 | HTML | 8년 전 | 2165 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기