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에서 해주시기 바랍니다.
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 887 | HTML | 8년 전 | 2242 | ||
| 886 | HTML | 8년 전 | 1784 | ||
| 885 | HTML | 8년 전 | 2209 | ||
| 884 | HTML | 8년 전 | 2262 | ||
| 883 | HTML | 8년 전 | 2427 | ||
| 882 | HTML | 8년 전 | 2175 | ||
| 881 | HTML | 8년 전 | 2302 | ||
| 880 | HTML | 8년 전 | 2628 | ||
| 879 | HTML | 8년 전 | 1725 | ||
| 878 | HTML | 8년 전 | 1950 | ||
| 877 | HTML | 8년 전 | 1962 | ||
| 876 | HTML | 8년 전 | 2154 | ||
| 875 | HTML | 8년 전 | 1689 | ||
| 874 | HTML | 8년 전 | 2719 | ||
| 873 | HTML | 8년 전 | 2566 | ||
| 872 | HTML | 8년 전 | 2615 | ||
| 871 | HTML | 8년 전 | 2929 | ||
| 870 | HTML | 8년 전 | 2200 | ||
| 869 | HTML | 8년 전 | 2636 | ||
| 868 | HTML | 8년 전 | 2154 | ||
| 867 | HTML | 8년 전 | 1931 | ||
| 866 | HTML | 8년 전 | 1664 | ||
| 865 | HTML | 8년 전 | 1921 | ||
| 864 | HTML | 8년 전 | 2052 | ||
| 863 | HTML | 8년 전 | 1350 | ||
| 862 | HTML | 8년 전 | 1647 | ||
| 861 | HTML | 8년 전 | 1612 | ||
| 860 | HTML | 8년 전 | 1881 | ||
| 859 | HTML | 8년 전 | 1536 | ||
| 858 | HTML | 8년 전 | 1831 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기