html5人物图片360度立体旋转

体验效果:http://hovertree.com/texiao/html5/10.htm

下载:http://hovertree.com/hvtart/bjae/t16oddyt.htm

代码如下:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Full 360 degree View - HoverTree</title>
<style>
.hvtholder {
margin: 0px auto;
width: 789px;
text-align: center;
}
a {
color: blue;
}
</style>
<script type="text/javascript" src="http://hovertree.com/ziyuan/jquery/jquery-1.11.3.min.js"></script>
<script>
var ctx = null; // global variable 2d context
var frame = 1; // 23
var width = 0;
var height = 0;
var started = false;
var images = new Array();
var startedX = -1;
$(function () {
var canvas = document.getElementById("hov"+"ertree_canvas");
canvas.width = 440;// window.innerWidth;
canvas.height = 691;//window.innerHeight;
width = canvas.width;
height = canvas.height;
var bar = document.getElementById(‘loadHove‘+‘rTreeBar‘);
for (var i = 1; i < 24; i++) {
bar.value = i;
if (i < 10) {
images[i] = new Image();
images[i].src = "10/hovertree0" + i + ".jpg";
}
else {
images[i] = new Image();
images[i].src = "10/hovert"+"ree" + i + ".jpg";
}
}
ctx = canvas.getContext("2d");

// mouse event
canvas.addEventListener("mousedown", doMouseDown, false);
canvas.addEventListener(‘mousemove‘, doMouseMove, false);
canvas.addEventListener(‘mouseup‘, doMouseUp, false);
// loaded();

// frame = 1
frame = 1;
images[frame].onload = function () {
redraw();
bar.style.display = ‘none‘;
}
$("#goHovertr"+"ee").on("click", function () { gohovertree();})
})

function doMouseDown(event) {
var x = event.pageX;
var y = event.pageY;
var canvas = event.target;
var loc = getPointOnCanvas(canvas, x, y);
console.log("mouse down at point( x:" + loc.x + ", y:" + loc.y + ")");
startedX = loc.x;
started = true;
}

function doMouseMove(event) {
var x = event.pageX;
var y = event.pageY;
var canvas = event.target;
var loc = getPointOnCanvas(canvas, x, y);
if (started) {
var count = Math.floor(Math.abs((startedX - loc.x)/30));
var frameIndex = Math.floor((startedX - loc.x)/30);
while(count > 0)
{
console.log("frameIndex = " + frameIndex);
count--;
if(frameIndex > 0)
{
frameIndex--;
frame++;
} else if(frameIndex < 0)
{
frameIndex++;
frame--;
}
else if(frameIndex == 0)
{
break;
}

if(frame >= 24)
{
frame = 1;
}
if(frame <= 0)
{
frame = 23;
}
redraw();
}
}
}

function doMouseUp(event) {
console.log("mouse up now");
if (started) {
doMouseMove(event);
startedX = -1;
started = false;
}
}

function getPointOnCanvas(canvas, x, y) {
var bbox = canvas.getBoundingClientRect();
return { x: x - bbox.left * (canvas.width / bbox.width),
y: y - bbox.top * (canvas.height / bbox.height)
};
}

function gohovertree() {
setTimeout( update, 1000/8);
}
function redraw()
{
// var imageObj = document.createElement("img");
// var imageObj = new Image();
var imageObj = images[frame];
ctx.clearRect(0, 0, width, height)
ctx.drawImage(imageObj, 0, 0, width, height);
}
function update() {
redraw();
frame++;
if (frame >= 23) frame = 1;
setTimeout( update, 1000/8);
}
</script>
</head>
<body>
<div class="hvtholder">
<h3>360度旋转产品展示</h3><a href="http://hovertree.com">首页</a> <a href="http://hovertree.com/texiao/">特效</a> <a href="http://hovertree.com/hvtart/bjae/49kk0ib8.htm">原文</a>
<br />点击下面按钮旋转<br /><button id="goHovertree">点击旋转</button>
<br />
</div>
<div style="width:640px;margin:0 auto;">

<progress id="loadHoverTreeBar" value="0" max="23"></progress>

<canvas id="hovertree_canvas">您的浏览器不支持HTML5,使用支持HTTML5的浏览器,何问起,hovertree.com</canvas>

</div>

</body>
</html>

更多: http://www.cnblogs.com/roucheng/p/texiao.html

时间: 2024-10-07 09:25:41

html5人物图片360度立体旋转的相关文章

js鼠标拖动图片360度平面旋转

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Typ

HTML实现图片360度循环旋转

<style> .header{ -webkit-animation:rotateImg 5s linear infinite;<!--修改旋转周期--> border: 1px solid #ccc; vertical-align: middle; } @keyframes rotateImg { 0% {transform : rotate(0deg);} 100% {transform : rotate(360deg);} } @-webkit-keyframes rotat

iOS开发动画(Animation)图片360度不停旋转

1 { 2 CGFloat angle; 3 } 4 5 - (void)viewDidLoad { 6 [super viewDidLoad]; 7 angle = 0; 8 [self startAnimation]; 9 } 10 11 //方法1 12 -(void) startAnimation 13 { 14 [UIView beginAnimations:nil context:nil]; 15 [UIView setAnimationDuration:0.01]; 16 [UIV

CSS3鼠标悬停图片360度旋转效果

一个用HTML5/css3写成的图片旋转特效,鼠标放上后图片就开始不停的旋转,对CSS3动画效果感兴趣的,更不可错过哦,用CSS3实现动画效果很不错的范例. <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="utf-8"> <title>CSS3鼠标悬停图片360度旋转效果丨电表控制器|www.sjzkeda.com</title>

Html5添加产品图片360度旋转插件教程

一.使用方法 <link href="/css/tikslus360.css" rel="stylesheet"> <script src="/js/jquery.min.js"></script> <script src="/js/tikslus360.min.js"></script> 二.Html结构 <div id="view360"

图片360度旋转

<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>图片循环旋转</title> <style> *{margin: 0; padding: 0;} @-webkit-keyframes rotation{ from {-webkit-transform: rotate(0deg);} to {-webkit-transform:

原生图片360度旋转

1 <!doctype html> 2 <html> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 5 <title></title> 6 <style> 7 #left{ position:absolute; left:0; top:0; width:50%; hei

360度立体抽奖盒

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" con

html5 图片360旋转

test.html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>图片360度旋转</title> <style> input { font-size:18px; padding:5px 20px 5px 20px; font-weight:bold; color:white; backgr