HTML5 Canvas Draw Linear Gradient
HTML5 Canvas Draw Linear Gradient
Example
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
// Create gradient
var grd = ctx.createLinearGradient(0,0,200,0);
grd.addColorStop(0,"red");
grd.addColorStop(1,"white");
// Fill with gradient
ctx.fillStyle = grd;
ctx.fillRect(10,10,150,80)
<!DOCTYPE html>
<html>
<body>
<canvas id="myCanvas" width="200" height="100" style="border:1px solid #d3d3d3;">
Your browser does not support the HTML5 canvas tag.</canvas>
<script>
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
// Create gradient
var grd = ctx.createLinearGradient(0,0,200,0);
grd.addColorStop(0,"red");
grd.addColorStop(1,"white");
// Fill with gradient
ctx.fillStyle = grd;
ctx.fillRect(10,10,150,80);
</script>
</body>
</html>
게시판 목록
퍼블리셔팁
질문은 상단의 QA에서 해주시기 바랍니다.
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 137 | HTML | 19년 전 | 3778 | ||
| 136 | HTML |
pearly
|
19년 전 | 4132 | |
| 135 | HTML | 19년 전 | 4234 | ||
| 134 | HTML |
pearly
|
19년 전 | 4648 | |
| 133 | HTML |
|
19년 전 | 3273 | |
| 132 | HTML |
|
19년 전 | 3133 | |
| 131 | HTML |
|
19년 전 | 2808 | |
| 130 | HTML |
|
19년 전 | 3685 | |
| 129 | HTML |
|
19년 전 | 2748 | |
| 128 | HTML |
|
19년 전 | 3339 | |
| 127 | HTML |
|
19년 전 | 8595 | |
| 126 | HTML |
|
19년 전 | 2542 | |
| 125 | HTML |
|
19년 전 | 3007 | |
| 124 | HTML |
|
19년 전 | 5356 | |
| 123 | HTML |
|
19년 전 | 2929 | |
| 122 | HTML |
|
19년 전 | 2838 | |
| 121 | HTML |
|
19년 전 | 3436 | |
| 120 | HTML | 19년 전 | 3201 | ||
| 119 | HTML |
|
19년 전 | 3186 | |
| 118 | HTML | 19년 전 | 5072 | ||
| 117 | HTML |
|
19년 전 | 3648 | |
| 116 | HTML | 19년 전 | 3507 | ||
| 115 | HTML | 19년 전 | 3899 | ||
| 114 | HTML |
|
19년 전 | 3858 | |
| 113 | HTML |
|
19년 전 | 5283 | |
| 112 | HTML |
|
19년 전 | 3614 | |
| 111 | HTML | 19년 전 | 4092 | ||
| 110 | HTML |
|
19년 전 | 3522 | |
| 109 | HTML | 19년 전 | 4864 | ||
| 108 | HTML |
홀로남은자
|
19년 전 | 2979 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기