好湿?好紧?好多水好爽自慰,久久久噜久噜久久综合,成人做爰A片免费看黄冈,机机对机机30分钟无遮挡

主頁 > 知識庫 > 一款html5 canvas實現(xiàn)的圖片玻璃碎片特效

一款html5 canvas實現(xiàn)的圖片玻璃碎片特效

熱門標簽:外呼線穩(wěn)定線路 南通數(shù)據(jù)外呼系統(tǒng)推廣 阜陽企業(yè)外呼系統(tǒng) 地圖標注位置能賺錢嗎 pageadm實現(xiàn)地圖標注 邢臺縣地圖標注app 申請400電話流程簡介 外呼系統(tǒng)電話怎么投訴 呼和浩特外呼電銷系統(tǒng)排名
今天要為大家?guī)硪豢頷tml5 canvas實現(xiàn)的圖片玻璃碎片特效。圖片以玻璃碎片的形式出現(xiàn)到界面中,然后似玻璃被打碎的效果漸消息。效果圖如下:

 

源碼下載 

html代碼:


復制代碼
代碼如下:

<img src="city_copy.jpg" id="src_img" class="hidden">
<div id="container" style="-webkit-perspective: 500px;">
<div>
<script src="delaunay.js"></script>
<script src="TweenMax.min.js"></script>


js代碼:

復制代碼
代碼如下:

// canvas settings
var imageWidth = 768,
imageHeight = 485;
var vertices = [],
indices,
boxes = [];
var image,
fragments = [],
container = document.getElementById('container');
window.onload = function () {
image = document.getElementById('src_img');
triangulate();
makeBoxes();
makeFragments();
};
function triangulate() {
var x,
y,
dx = imageWidth / 8,
dy = imageHeight / 8,
offset = 0.5;
for (var i = 0; i <= imageWidth; i += dx) {
for (var j = 0; j <= imageHeight; j += dy) {
if (i && (i !== imageWidth)) x = i + randomRange(-dx * offset, dx * offset);
else x = i;
if (j && (j !== imageHeight)) y = j + randomRange(-dy * offset, dy * offset);
else y = j;
vertices.push([x, y]);
}
}
indices = Delaunay.triangulate(vertices);
}
function makeBoxes() {
var p0, p1, p2,
xMin, xMax,
yMin, yMax;
for (var i = 0; i < indices.length; i += 3) {
p0 = vertices[indices[i + 0]];
p1 = vertices[indices[i + 1]];
p2 = vertices[indices[i + 2]];
xMin = Math.min(p0[0], p1[0], p2[0]);
xMax = Math.max(p0[0], p1[0], p2[0]);
yMin = Math.min(p0[1], p1[1], p2[1]);
yMax = Math.max(p0[1], p1[1], p2[1]);
boxes.push({
x: xMin,
y: yMin,
w: xMax - xMin,
h: yMax - yMin
});
}
}
function makeFragments() {
var p0, p1, p2,
box,
fragment;
TweenMax.set(container, { perspective: 500 });
var tl0 = new TimelineMax({ repeat: -1 });
for (var i = 0; i < indices.length; i += 3) {
p0 = vertices[indices[i + 0]];
p1 = vertices[indices[i + 1]];
p2 = vertices[indices[i + 2]];
box = boxes[i / 3];
fragment = new Fragment(p0, p1, p2, box);
var rx = randomRange(30, 60) * ((i % 2) ? 1 : -1);
var ry = randomRange(30, 60) * ((i % 2) ? -1 : 1);
var tl1 = new TimelineMax();
TweenMax.set(fragment.canvas, {
y: box.y - 1000
});
tl1.to(fragment.canvas, randomRange(0.9, 1.1), {
y: box.y,
ease: Back.easeOut
});
tl1.to(fragment.canvas, 0.5, {
z: -100,
ease: Cubic.easeIn,
delay: 0.4
});
tl1.to(fragment.canvas, randomRange(1, 1.2), {
rotationX: rx,
rotationY: ry,
z: 250,
alpha: 0,
ease: Cubic.easeOut
});
tl0.insert(tl1);
fragments.push(fragment);
container.appendChild(fragment.canvas);
}
}
function randomRange(min, max) {
return min + (max - min) * Math.random();
}
Fragment = function (v0, v1, v2, box) {
this.v0 = v0;
this.v1 = v1;
this.v2 = v2;
this.box = box;
this.canvas = document.createElement('canvas');
this.canvas.width = this.box.w;
this.canvas.height = this.box.h;
this.canvas.style.width = this.box.w + 'px';
this.canvas.style.height = this.box.h + 'px';
this.ctx = this.canvas.getContext('2d');
TweenMax.set(this.canvas, {
x: this.box.x,
y: this.box.y
});
this.ctx.translate(-this.box.x, -this.box.y);
this.ctx.beginPath();
this.ctx.moveTo(this.v0[0], this.v0[1]);
this.ctx.lineTo(this.v1[0], this.v1[1]);
this.ctx.lineTo(this.v2[0], this.v2[1]);
this.ctx.closePath();
this.ctx.clip();
this.ctx.drawImage(image, 0, 0);
}; //@ sourceURL=pen.js

標簽:內(nèi)蒙古 辛集 黃山 撫順 鶴崗 楊凌 蚌埠 德州

巨人網(wǎng)絡(luò)通訊聲明:本文標題《一款html5 canvas實現(xiàn)的圖片玻璃碎片特效》,本文關(guān)鍵詞  一款,html5,canvas,實現(xiàn),的,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《一款html5 canvas實現(xiàn)的圖片玻璃碎片特效》相關(guān)的同類信息!
  • 本頁收集關(guān)于一款html5 canvas實現(xiàn)的圖片玻璃碎片特效的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    主站蜘蛛池模板: 情趣内衣办公室(H)| www.99热.com| 高H荤爽肉欲文| 色屁屁www一区二区三区| 日本bl动漫高h| 双性被室友发现H1V1| 敌伦交换第24部分阅读| 91久久国产综合精品女同我| www黄色网址| 亚洲人成人7777在线在线播放| 天堂网日本| 七夕和女神酒店里高潮视频瞬间流出 | 妻子韩剧在线观看免费完整版| 乱系列h文小说合集| 亚洲日韩AV一级午夜2023年| 黄金时代王小波小说| 林静公交车被做到高潮短文| 她在丈夫面被耍了BD高清电影| 公交车上被弄进走不动| 呦女亚洲一区精品| 男朋友弄湿我还问我哪里难受| 免费?无码?国产在线看果冻| 免费观看一级成人毛片| 北海市| japanese色系tube日本护士| 日韩不卡高清| h真紧很爽| 狠狠噜天天噜日日噜视频麻豆| 双胞胎姐妹齐上阵| 91天堂国产在线 在线播放| 欧美乱妇高清无乱码视频在线 | 久久兔费黄A级毛片高清| 榴莲直播| 各种姿势被陌生人np高h动图| 国产又白又小又紧又急又爽| 日日摸夜夜添夜夜添日韩| 丝袜美腿美女| 国产做A爰片毛片A片美国| 国产精品秘?久久久久久| 乱luen大合集| 高中生被老师第一次处破女|