首页 技术 正文
技术 2022年11月14日
0 收藏 908 点赞 3,055 浏览 1627 个字

var race = document.getElementById(‘race’);
var cxt = race.getContext(‘2d’);

var ang = 0;
var speed = 1;
var sAng = 0;

function draw() {
cxt.save();

cxt.translate(300, 300);

cxt.save();
cxt.beginPath();
cxt.fillStyle = ‘#CCA548’;
cxt.arc(0, 0, 220, 0, 360*Math.PI/180, false);
cxt.fill();
cxt.closePath();
cxt.restore();

cxt.save();
cxt.beginPath();
cxt.fillStyle = ‘white’;
cxt.arc(0, 0, 200, 0, 360*Math.PI/180, false);
cxt.fill();
cxt.closePath();
cxt.restore();

cxt.save();
cxt.rotate(ang*Math.PI/180);
ang += speed;
//speed += 1;
cxt.fillStyle = ‘#CDC9A5’;
cxt.fillRect(210, -40, 40, 80);
cxt.strokeRect(210, -40, 40, 80);

cxt.fillStyle = ‘white’;
cxt.fillRect(230, -20, 10, 10);
cxt.fillRect(230, 10, 10, 10);

cxt.save();
cxt.translate(210, -20);
cxt.fillStyle = ‘#000’;
cxt.beginPath();
cxt.arc(0, 0,10, 0, 360*Math.PI/180, false);
cxt.fill();
cxt.closePath();

cxt.fillStyle = ‘white’;
cxt.beginPath();
cxt.arc(0, 0, 2, 0, 360*Math.PI/180, false);
cxt.fill();
cxt.closePath();

cxt.save();
if(sAng > 360){
sAng = 0;
}
cxt.rotate(sAng*Math.PI/180);
sAng += 4;
cxt.strokeStyle = ‘white’;
cxt.strokeRect(-5*Math.sqrt(2), -5*Math.sqrt(2), 10*Math.sqrt(2), 10*Math.sqrt(2));
cxt.restore();

cxt.restore();

cxt.save();
cxt.translate(210, 20);
cxt.fillStyle = ‘#000’;
cxt.beginPath();
cxt.arc(0, 0,10, 0, 360*Math.PI/180, false);
cxt.fill();
cxt.closePath();

cxt.save();
cxt.rotate((sAng+45)*Math.PI/180);
cxt.strokeStyle = ‘white’;
cxt.strokeRect(-5*Math.sqrt(2), -5*Math.sqrt(2), 10*Math.sqrt(2), 10*Math.sqrt(2));
cxt.restore();

cxt.restore();

cxt.beginPath();
cxt.arc(210, 20, 2, 0, 360*Math.PI/180, false);
cxt.fill();
cxt.closePath();

cxt.restore();

cxt.restore();
}

//draw();

function animate() {

cxt.clearRect(0, 0, 600, 600);
draw();

requestAnimationFrame(animate);
}

requestAnimationFrame(animate);

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,086
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,561
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,410
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,183
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,820
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,903