当前位置: 移动技术网 > IT编程>开发语言>JavaScript > Canvas

Canvas

2019年02月26日  | 移动技术网IT编程  | 我要评论
颜色渐变
// canvas画图
// 颜色渐变
var grd = draw.createlineargradient(0,0,175,50);
grd.addcolorstop(0, '#f00');
grd.addcolorstop(0.5, '#0f0');
grd.addcolorstop(1.0, '#00f');
draw.fillstyle = grd;
draw.fillrect(10,10, 210, 60);
view code

 

// 获取元素位置属性
getboundingclientrect()

// 保留一段时间的特效 
context.globalcompositeoperation = 'destination-out';
// 之前的轨迹透明,之后的轨迹部分显示
context.fillstyle = 'rgba(0, 0, 0, 0.5)';
context.fillrect( 0, 0, cw, ch );
context.globalcompositeoperation = 'lighter';
view code

 

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网