绘制星空
来源:互联网 发布:武汉java培训机构排名 编辑:程序博客网 时间:2024/04/29 02:45
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
</head>
<body>
</body>
</html><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
</head>
<body>
<canvas id="canvas" style="border:1px solid black;margin:0 auto;display:block;">
浏览器不支持
</canvas>
<script>
window.onload=function()
{
var canvas=document.getElementById("canvas");
var cxt=canvas.getContext("2d");
canvas.width=800;
canvas.height=800;
//drawStar(cxt,150,300,400,400,0);
cxt.fillStyle="black";
cxt.fillRect(0, 0, canvas.width,canvas.height);
//cxt.lineJoin="bevel";
//cxt.miterLimit=80;
//
cxt.fillStyle="pink";
cxt.lineJoin="round";
cxt.fill();
cxt.stroke();
for(var i=0;i<200;i++)
{
var r=Math.random()*10+10;
var x=Math.random()*canvas.width;
var y=Math.random()*canvas.height;
var a=Math.random()*360;
drawStar(cxt,r,r,x,y,a);
}
}
function drawStar(cxt,r,R,x,y,rot)
{
cxt.beginPath();
for(var i=0;i<5;i++)
{
cxt.lineTo(Math.cos((18+i*72-rot)/180*Math.PI)*R+x, -Math.sin((18+i*72-rot)/180*Math.PI)*R+y);//横坐标前部分是角度转弧度,大圆半径暂定300,
cxt.lineTo(Math.cos((54+i*72-rot)/180*Math.PI)*r+x, -Math.sin((54+i*72-rot)/180*Math.PI)*r+y);
}
cxt.closePath();
cxt.fillStyle="rgba(0,236,0,0.5)";
cxt.lineJoin="round";
cxt.fill();
cxt.stroke();}
</script>
</body>
</html>
<html lang="en">
<head>
<meta charset="utf-8">
</head>
<body>
</body>
</html><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
</head>
<body>
<canvas id="canvas" style="border:1px solid black;margin:0 auto;display:block;">
浏览器不支持
</canvas>
<script>
window.onload=function()
{
var canvas=document.getElementById("canvas");
var cxt=canvas.getContext("2d");
canvas.width=800;
canvas.height=800;
//drawStar(cxt,150,300,400,400,0);
cxt.fillStyle="black";
cxt.fillRect(0, 0, canvas.width,canvas.height);
//cxt.lineJoin="bevel";
//cxt.miterLimit=80;
//
cxt.fillStyle="pink";
cxt.lineJoin="round";
cxt.fill();
cxt.stroke();
for(var i=0;i<200;i++)
{
var r=Math.random()*10+10;
var x=Math.random()*canvas.width;
var y=Math.random()*canvas.height;
var a=Math.random()*360;
drawStar(cxt,r,r,x,y,a);
}
}
function drawStar(cxt,r,R,x,y,rot)
{
cxt.beginPath();
for(var i=0;i<5;i++)
{
cxt.lineTo(Math.cos((18+i*72-rot)/180*Math.PI)*R+x, -Math.sin((18+i*72-rot)/180*Math.PI)*R+y);//横坐标前部分是角度转弧度,大圆半径暂定300,
cxt.lineTo(Math.cos((54+i*72-rot)/180*Math.PI)*r+x, -Math.sin((54+i*72-rot)/180*Math.PI)*r+y);
}
cxt.closePath();
cxt.fillStyle="rgba(0,236,0,0.5)";
cxt.lineJoin="round";
cxt.fill();
cxt.stroke();}
</script>
</body>
</html>
0 0
- 绘制星空
- 初试three.js--绘制星空
- 利用c语言绘制漫天星空-动画
- 星空
- 星空
- 星空
- 上海天文台实习的一个项目-根据卫星数据绘制南极星空分布图
- 一个Android自定义背景视图,通过触摸绘制类星空背景图
- Canvas小demo(直线和曲线绘制出一个星空,月亮,绿地)
- 绘制星空升级版(使用图形变换translate和rotate)
- 星空恋
- 星空地球
- 美丽星空
- 吞噬星空
- 蓝色星空
- 蓝色星空
- 仰望星空
- 仰望星空
- 取消事件对象(DOM/IE)
- SpriteRenderer 与 MeshRenderer的排序问题
- asp.net解决高并发的方案
- CentOS7之开发环境搭建
- java Socket简单聊天实现 —— 实现服务器端向客户端广播内容
- 绘制星空
- Markdown语法帮助
- ArcGIS 桌面60天试用许可申请流程
- LINUX的文件权限
- NS3-logging 日志模块的使用
- linux软硬链接
- java中24种设计模式及7大设计原则
- 1066.Root of AVL Tree (25)...to be continued...
- [Rails应用实战]WebChat的敏捷开发