<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>旋转</title>
<style>
* {margin:0padding:0border:0}
div {width:200pxheight:200pxmargin-left:100pxmargin-top:-100px}
img {width:200pxheight:200pxborder-radius:100pxanimation:myfirst 5s linear infinite-webkit-animation:myfirst 5s linear infiniteanimation-play-state:running-webkit-animation-play-state:running}
img:hover {animation-play-state:paused-webkit-animation-play-state:paused}
@keyframes myfirst {0% {transform:rotate(0deg)} 100% {transform:rotate(360deg)}}
@-webkit-keyframes myfirst {0% {transform:rotate(0deg)} 100% {transform:rotate(360deg)}}
</style>
</head>
<body>
<p style="margin-top:100px"></p>
<div><img src="163146_vN8g_574908.jpg"/><div>
</body>
</html>
需要的图片
提供个思路:楼主手中那么多经纬度坐标点,想必不可能一个一个手工操作,应该是批量操作的。如果是这样,那就找一个标准格式的GPX文件(GPS轨迹文件),用WORD或写字板打开,将……之间的数据全部清除,然后把你的数据一次性拷贝到里面去。尔后用批量搜索替换的法,将每个坐标点都处理成标准格式的轨迹点和路点,存储备用。在谷歌地球或者奥维互动地图中,打开该GPX文件,所有的点就会显示出来了。归纳一下上面的思路,就是将所有的坐标点转换成GPS轨迹文件中的轨迹点,在此基础上处理成可见路点,然后在地图上显示出来。今天研究的是利用HTML5的Canvas画图来模拟太阳系运转,首先,在这个太阳系里分为画轨道和画星球两个部分,对于每一个星球我们要知道它的颜色和公转周期,如下图。
采用面向对象编程的思想,代码如下
stars.html
[html] view plain copy
<!DOCTYPE HTML>
<html>
<head></head>
<body>
<canvas id="canvas" width="1000" height="1000" style="background:#000">
你的浏览器不支持canvas标签!
</canvas>
<script src="stars.js">
</script>
</body>
</html>
stars.js
[javascript] view plain copy
/******************************************/
/**/
/* 本节代码体现了用JavaScript编写面向对 */
/* 象程序的思想,希望能认真阅读理解。 */
/**/
/******************************************/
//设置2d绘图环境
var ctx = document.getElementById("canvas").getContext("2d")
//画轨道
function drawTrack(){
for(var i = 0i <8i++){
ctx.beginPath()
ctx.arc(500, 500, (i + 1) * 50, 0, 360, false)
ctx.closePath()
ctx.strokeStyle = "#fff"
ctx.stroke()
}
}
//画星球的类
function Star(x, y, radius, cycle, sColor, eColor){
//设置星球类的属性
this.x = x//星球的坐标点
this.y = y
this.radius = radius //星球的半径
this.cycle = cycle//设置周期
this.sColor = sColor //星球的颜色,起始颜色和结束颜色
this.eColor = eColor
this.color = null
//设置一个计时器
this.time = 0
//给星球类定义一个方法
this.draw = function(){
ctx.save() //保存之前的内容
ctx.translate(500, 500) //重置0,0坐标
ctx.rotate(this.time * (360 / this.cycle) * Math.PI / 180) //旋转角度
//画星球
ctx.beginPath()
ctx.arc(this.x, this.y, this.radius, 0, 360, false)
ctx.closePath()
//设置星球的填充颜色
this.color = ctx.createRadialGradient(this.x, this.y, 0, this.x, this.y, this.radius)
this.color.addColorStop(0, this.sColor)
this.color.addColorStop(1, this.eColor)
ctx.fillStyle = this.color
ctx.fill()
//恢复之前画布的内容
ctx.restore()
this.time += 1
}
}
//创建一个太阳的构造函数
function Sun(){
Star.call(this, 0, 0, 20, 0, "#FFFF00", "#FF9900")
}
//创建一个水星的构造函数
function Mercury(){
Star.call(this, 0, -50, 10, 87.70, "#A69697", "#5C3E40")
}
//创建一个金星的构造函数
function Venus(){
Star.call(this, 0, -100, 10, 224.701, "#C4BBAC", "#1F1315")
}
//创建一个地球的构造函数
function Earth(){
Star.call(this, 0, -150, 10, 365.2422, "#78B1E8", "#050C12")
}
//创建一个火星的构造函数
function Mars(){
Star.call(this, 0, -200, 10, 686.98, "#CEC9B6", "#76422D")
}
//创建一个木星的构造函数
function Jupiter(){
Star.call(this, 0, -250, 10, 4332.589, "#C0A48E", "#322222")
}
//创建一个土星的构造函数
function Saturn(){
Star.call(this, 0, -300, 10, 10759.5, "#F7F9E3", "#5C4533")
}
//创建一个天王星的构造函数
function Uranus(){
Star.call(this, 0, -350, 10, 30799.095, "#A7E1E5", "#19243A")
}
//创建一个海王星的构造函数
function Neptune(){
Star.call(this, 0, -400, 10, 60152, "#0661B2", "#1E3B73")
}
var sun = new Sun()
var mercury = new Mercury()
var venus = new Venus()
var earth = new Earth()
var mars = new Mars()
var jupiter = new Jupiter()
var saturn = new Saturn()
var uranus = new Uranus()
var neptune = new Neptune()
function Move(){
ctx.clearRect(0, 0, 1000, 1000)
drawTrack()
sun.draw()
mercury.draw()
venus.draw()
earth.draw()
mars.draw()
jupiter.draw()
saturn.draw()
uranus.draw()
neptune.draw()
}
setInterval(Move,10)