LED动态特效HTML5页⾯源码
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>MYDEMO</title>
<style type="text/css" media="screen" >
body {
background: #eee;
}
网络营销的特点* {
position: absolute;
margin: 0; padding: 0;
彩印设置}
input[type="text"] {
border: 1px solid #ddd;
padding: 6px;
font-size: 18px;
width: 200px;
text-transform: uppercase;
top: 30px;
left: 130px;
}
input[type="submit"] {
display: block;
width: 100px;
border: 0;
line-height: 35px;
height: 35px;
color: #fff;
background: mediumpurple;
font-size: 18px;
top: 30px;
left: 350px;
cursor: pointer;
}
form {
width: 600px;
height: 100px;
}
</style>
</head>
<body>
<canvas id="text" width="500" height="100"></canvas>
<canvas id="stage" width="500" height="100"></canvas>
<form id="form">
<input type="text" id="inputText" value="刘亚鹏" />
<input type="submit" value="点击" />
</form>
<div >
</div>
<script>
(window._gsQueue||(window._gsQueue=[])).push(function(){"use strict";window._gsDefine("easing.Back",["easing.Ease"],function(t){var e,i,s,r=window.GreenSock </script>
<script>
(function(t){"use strict";var e=t.GreenSockGlobals||t;if(!e.TweenLite){var i,s,r,n,a,o=function(t){var i,s=t.split("."),r=e;for(i=0;s.length>i;i++)r[s[i]]=r=r[s[i]]||{};return r}, </script>
<script>
<script>
<script>
科目二怎样倒车入库(function() {
var lastTime = 0;
var vendors = ['webkit', 'moz'];
for(var x = 0; x < vendors.length && !questAnimationFrame; ++x) {
window.cancelAnimationFrame =
window[vendors[x]+'CancelAnimationFrame'] || window[vendors[x]+'CancelRequestAnimationFrame']; }
if (!questAnimationFrame)
var currTime = new Date().getTime();
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
var id = window.setTimeout(function() { callback(currTime + timeToCall); },
timeToCall);
lastTime = currTime + timeToCall;
return id;
};
if (!window.cancelAnimationFrame)
window.cancelAnimationFrame = function(id) {
clearTimeout(id);
};
}());
</script>
<script>
(function(){
var stage, textStage, form, input;
var circles, textPixels, textFormed;
var offsetX, offsetY, text;
var colors = ['#B2949D', '#FFF578', '#FF5F8D', '#37A9CC', '#188EB2'];
function init() {
initStages();
initForm();
initText();
initCircles();
animate();
addListeners();
}
/
/ Init Canvas
function initStages() {
offsetX = (window.innerWidth-600)/2;
offsetY = (window.innerHeight-300)/2;
textStage = new createjs.Stage("text");
textStage.canvas.width = 600;
textStage.canvas.height = 200;
stage = new createjs.Stage("stage");
stage.canvas.width = window.innerWidth;
stage.canvas.height = window.innerHeight;
}
function initForm() {
form = ElementById('form');
p = offsetY+200+'px';
form.style.left = offsetX+'px';
input = ElementById('inputText');艾玛沃特森凸点
}
function initText() {
text = new createjs.Text("t", "80px 'Source Sans Pro'", "#eee");
text.x = 300;
}
function initCircles() {
circles = [];
circles = [];
for(var i=0; i<600; i++) {
var circle = new createjs.Shape();
给刘翔的一封信var r = 7;
var x = window.innerWidth*Math.random();
var y = window.innerHeight*Math.random();
var color = colors[Math.floor(i%colors.length)];
var alpha = 0.2 + Math.random()*0.5;
circle.alpha = alpha;
circle.radius = r;
circle.x = x;
circle.y = y;
circles.push(circle);
stage.addChild(circle);
tweenCircle(circle);
}
}
// animating circles
function animate() {
stage.update();
requestAnimationFrame(animate);
}
function tweenCircle(c, dir) {
if(c.tween) c.tween.kill();
if(dir == 'in') {
c.tween = (c, 0.4, {x: c.originX, y: c.originY, ease:Qua
d.easeInOut, alpha: 1, radius: 5, scaleX: 0.4, scaleY: 0.4, onComplete: function() {
tweenCircle(c);
}});
陈若仪林志颖} else if(dir == 'out') {
c.tween = (c, 0.8, {x: window.innerWidth*Math.random(), y: window.innerHeight*Math.random(), ease:Qua
d.easeInOut, alpha: 0.2 + Math.ran c.movement = 'float';
tweenCircle(c);
}});
} else {
vement == 'float') {
c.tween = (c, 5 + Math.random()*3.5, {x: c.x + -100+Math.random()*200, y: c.y + -100+Math.random()*200, ease:Qua
d.easeInOut, alpha: 0 onComplete: function() {
tweenCircle(c);
}});
} else {
c.tween = (c, 0.05, {x: c.originX + Math.random()*3, y: c.originY + Math.random()*3, ease:Qua
d.easeInOut,
onComplete: function() {
tweenCircle(c);
}});
}
}
}
function formText() {
for(var i= 0, l=textPixels.length; i<l; i++) {
circles[i].originX = offsetX + textPixels[i].x;
circles[i].originY = offsetY + textPixels[i].y;
tweenCircle(circles[i], 'in');
}
textFormed = true;
if(textPixels.length < circles.length) {
for(var j = textPixels.length; j<circles.length; j++) {
circles[j].tween = (circles[j], 0.4, {alpha: 0.1});
}
}
}
function explode() {
for(var i= 0, l=textPixels.length; i<l; i++) {
tweenCircle(circles[i], 'out');
tweenCircle(circles[i], 'out');
}
if(textPixels.length < circles.length) {
for(var j = textPixels.length; j<circles.length; j++) {
circles[j].tween = (circles[j], 0.4, {alpha: 1});
}
}
}
// event handlers
function addListeners() {
form.addEventListener('submit', function(e) {
e.preventDefault();
if(textFormed) {
explode();
if(input.value != '') {
setTimeout(function() {
createText(UpperCase());
}, 810);
} else {
textFormed = false;
}
} else {
createText(UpperCase());
}
});
}
function createText(t) {
var fontSize = 860/(t.length);
if (fontSize > 160) fontSize = 160;
< = t;
text.font = "900 "+fontSize+"px 'Source Sans Pro'";
text.x = 300;
text.y = (172-fontSize)/2;
textStage.addChild(text);
textStage.update();
var ctx = ElementById('text').getContext('2d');
var pix = ImageData(0,0,600,200).data;
textPixels = [];
for (var i = pix.length; i >= 0; i -= 4) {
if (pix[i] != 0) {
var x = (i / 4) % 600;
var y = Math.floor(Math.floor(i/600)/4);
if((x && x%8 == 0) && (y && y%8 == 0)) textPixels.push({x: x, y: y}); }
}
formText();
}
})();
</script>
</body>
</html>
成品效果
发布评论