html5教程实现Photoshop渐变色效果
复制代码
代码如下:<!DOCTYPE html><head>
<meta charset=utf-8>
<title>html5画线、圆、矩形</title>
<script src="<a href="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script">http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script</a>>
</head>
<script>
$(document).ready(function(){
var c=document.getElementById("drawbox");
var draw=c.getContext("2d"); //获取2d内容的引用,调用绘图API</p><p>//指定渐变区块
var grd=draw.createLinearGradient(50,50,200,50); //坐标,长宽
grd.addColorStop(0,"black"); //起点颜色
grd.addColorStop(1,"green"); //终点颜色</p><p>draw.fillStyle=grd; //设为填充样式
draw.fillRect(50,50,200,50); //填充进矩形内
})
</script>
</body>
<canvas id="drawbox" width="500" height="500"></canvas>
</body>
</html>
效果图:
最后更新于 2022-11-12 14:40:44 并被添加「html5教程 Photoshop 渐变色 」标签,已有 位童鞋阅读过。
本站使用「署名 4.0 国际」创作共享协议,可自由转载、引用,但需署名作者且注明文章出处
相关文章
- 美享时刻意大利面儿童意面轻脂低卡速食拌面家庭套餐通心粉面条
- matplotlib事件处理基础(事件绑定、事件属性)
- python中的unittest框架实例详解
- 医用退热贴儿童宝宝发烧退烧贴物理降温和小儿成人高烧降温贴1338
- Python Pygame实现俄罗斯方块