渐变圆形及矩形

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
<canvas id="myc" width="1000px" height="700px" style="background-color:#e4dbff" ></canvas>
<script>
var  can = document.getElementById("myc");
var c = can.getContext("2d");
c.moveTo(10,502);
c.lineTo(900,502);
c.stroke();
//圆
var grd=c.createLinearGradient(310,205,220,210);
grd.addColorStop(0,"#FF0D3B");
grd.addColorStop(1,"#F4F4F4");
c.fillStyle=grd;
c.storkstyle=grd;
c.beginPath();
c.moveTo(210, 175);
c.arc(200, 180, 100, -1.1, Math.PI / 4);
c.closePath();
c.fill();
c.stroke();


var grd=c.createLinearGradient(230,25,240,170);
grd.addColorStop(0,"#1510AC");
grd.addColorStop(1,"#F4F4F4");
c.fillStyle=grd;
c.storkstyle=grd;
c.beginPath();
c.moveTo(200,170);
c.arc(200,185,100,-0.4*Math.PI,Math.PI*1.05,true);
c.closePath();
c.fill();
c.stroke();


var grd=c.createLinearGradient(200,310,230,190);
grd.addColorStop(0,"#00BFFF");
grd.addColorStop(1,"#F4F4F4");
c.fillStyle=grd;
c.storkstyle=grd;
c.beginPath();
c.moveTo(200,180);
c.arc(200,180,100,70,Math.PI);
c.closePath();
c.fill();
c.stroke();


//1
var grd=c.createLinearGradient(20,100,20,680);
grd.addColorStop(0,"#FF0D3B");
grd.addColorStop(0.5,"#FFB6AC");
grd.addColorStop(1,"#F4F4F4");
c.fillStyle=grd;
c.fillRect(20,380,40,120);
c.rect(20,380,40,120);
c.strokeStyle=grd;
c.stroke();


var grd=c.createLinearGradient(20,100,20,590);
grd.addColorStop(0,"#0EB9FF");
grd.addColorStop(0.4,"#81D4FF");
grd.addColorStop(1,"#F4F4F4");
c.fillStyle=grd;
c.fillRect(60,320,40,180);
c.rect(60,320,40,180);
c.strokeStyle=grd;
c.stroke();


var grd=c.createLinearGradient(20,100,20,590);
grd.addColorStop(0,"#0A13FF");
grd.addColorStop(0.4,"#8F9CFF");
grd.addColorStop(1,"#F4F4F4");
c.fillStyle=grd;
c.fillRect(100,340,40,160);
c.rect(100,340,40,160);
c.strokeStyle=grd;
c.stroke();


//2
var grd=c.createLinearGradient(20,100,20,620);
grd.addColorStop(0,"#FF0D3B");
grd.addColorStop(0.5,"#FFB6AC");
grd.addColorStop(1,"#F4F4F4");
c.fillStyle=grd;
c.fillRect(220,320,40,180);
c.rect(220,320,40,180);
c.strokeStyle=grd;
c.stroke();


var grd=c.createLinearGradient(20,100,20,550);
grd.addColorStop(0,"#0EB9FF");
grd.addColorStop(0.4,"#81D4FF");
grd.addColorStop(1,"#F4F4F4");
c.fillStyle=grd;
c.fillRect(260,420,40,80);
c.rect(260,420,40,80);
c.strokeStyle=grd;
c.stroke();


var grd=c.createLinearGradient(20,100,20,550);
grd.addColorStop(0,"#0A13FF");
grd.addColorStop(0.4,"#8F9CFF");
grd.addColorStop(1,"#F4F4F4");
c.fillStyle=grd;
c.fillRect(300,380,40,120);
c.rect(300,380,40,120);
c.strokeStyle=grd;
c.stroke();
//3
var grd=c.createLinearGradient(20,100,20,620);
grd.addColorStop(0,"#FF0D3B");
grd.addColorStop(0.5,"#FFB6AC");
grd.addColorStop(1,"#F4F4F4");
c.fillStyle=grd;
c.fillRect(420,360,40,140);
c.rect(420,360,40,140);
c.strokeStyle=grd;
c.stroke();


var grd=c.createLinearGradient(20,100,20,550);
grd.addColorStop(0,"#0EB9FF");
grd.addColorStop(0.4,"#81D4FF");
grd.addColorStop(1,"#F4F4F4");
c.fillStyle=grd;
c.fillRect(460,280,40,220);
c.rect(460,280,40,220);
c.strokeStyle=grd;
c.stroke();


var grd=c.createLinearGradient(20,100,20,550);
grd.addColorStop(0,"#0A13FF");
grd.addColorStop(0.4,"#8F9CFF");
grd.addColorStop(1,"#F4F4F4");
c.fillStyle=grd;
c.fillRect(500,320,40,180);
c.rect(500,320,40,180);
c.strokeStyle=grd;
c.stroke();
//4
var grd=c.createLinearGradient(20,100,20,620);
grd.addColorStop(0,"#FF0D3B");
grd.addColorStop(0.5,"#FFB6AC");
grd.addColorStop(1,"#F4F4F4");
c.fillStyle=grd;
c.fillRect(620,220,40,280);
c.rect(620,220,40,280);
c.strokeStyle=grd;
c.stroke();


var grd=c.createLinearGradient(20,100,20,550);
grd.addColorStop(0,"#0EB9FF");
grd.addColorStop(0.4,"#81D4FF");
grd.addColorStop(1,"#F4F4F4");
c.fillStyle=grd;
c.fillRect(660,240,40,260);
c.rect(660,240,40,260);
c.strokeStyle=grd;
c.stroke();


var grd=c.createLinearGradient(20,100,20,550);
grd.addColorStop(0,"#0A13FF");
grd.addColorStop(0.4,"#8F9CFF");
grd.addColorStop(1,"#F4F4F4");
c.fillStyle=grd;
c.fillRect(700,260,40,240);
c.rect(700,260,40,240);
c.strokeStyle=grd;
c.stroke();
</script>
</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值