Toggle navigation
在线编辑器
在线代码
文本比较
jQuery下载
前端库
在线手册
登录/注册
下载代码
html
css
js
分享到微信朋友圈
X
html
css
* { margin: 0; padding:0; overflow: hidden; } canvas { display: block; }
JavaScript
var c = document.getElementById("c"), ctx = c.getContext("2d"), cw = (c.width = window.innerWidth), ch = (c.height = window.innerHeight), paper = new Image(200,200), ink = new Image(75,100), // Dimensions of the viewable area, not the entire sprite-sheet numFrames = 7, n=0, data={}; window.addEventListener("load", function(){ window.addEventListener("touchstart", function(e){ e.preventDefault(); setData(e.touches[0].clientX,e.touches[0].clientY); setTween(); }); window.addEventListener("click", function(e){ setData(e.offsetX,e.offsetY); setTween(); }); drawBg(); // First run, generate a few drips for (var i=0; i<5; i++){ setData( cw/2-150+200*Math.random(), ch/2-100+200*Math.random() ); setTween(i/10); } }); function setData(inputX,inputY){ (n<3)? n++ : n=0; data = { "frame":0, "x":inputX, "y":inputY, "s":75*n, "scale":.7 + Math.random()*.5, "rotate": ( Math.random() * Math.PI * 2 ) } } function setTween(delay=0){ TweenMax.to(data, .45, { delay:delay, frame:numFrames, ease:SteppedEase.ease.config(numFrames), onUpdate:run, onUpdateParams:[data] }) } function drawBg (alpha=1){ var pattern = ctx.createPattern(paper, "repeat"); ctx.globalAlpha = alpha; ctx.fillStyle = pattern;//'#fff'; ctx.fillRect(0, 0, cw, ch); } function run ( data ){ // Thank you @Shaw for help with the random scale+rotation - https://codepen.io/shshaw/ ctx.setTransform(1, 0, 0, 1, 0, 0); // Reset the transforms from previous draws ctx.globalCompositeOperation = "source-atop"; // Fade old drops by redrawing background texture drawBg(.01); // ctx.globalAlpha = 1; // Restore globalAlpha that was modified in drawBg() ctx.translate( data.x, data.y ); // Translate over to the mouse position to center your scaling & rotation on that point ctx.scale(data.scale, data.scale ); // Randomized scale ctx.rotate( data.rotate ); // Randomized rotation in radians ctx.translate( -data.x, -data.y ); // Move back to the starting position ctx.globalCompositeOperation = ["darken","multiply"][Math.round(Math.random())]; ctx.drawImage( ink, data.s, data.frame*ink.height, ink.width, ink.height, data.x-33, data.y-(ink.height/2), ink.width, ink.height ); } window.addEventListener("resize", function(){ cw = c.width = window.innerWidth; ch = c.height = window.innerHeight; drawBg(); }); paper.src = "http://www.jq22.com/tp/780035c7-713e-485c-823d-b0f9c5f3e4ab.jpg"; ink.src = "http://www.jq22.com/tp/17773a57-9a97-4993-9ec8-c5e106bc4eb5.png";
粒子
时间
文字
hover
canvas
3d
游戏
音乐
火焰
水波
轮播图
鼠标跟随
动画
css
加载动画
导航
菜单
按钮
滑块
tab
弹出层
统计图
svg
×
Close
在线代码下载提示
开通在线代码永久免费下载,需支付20jQ币
开通后,在线代码模块中所有代码可终身免费下!
您已开通在线代码永久免费下载,关闭提示框后,点下载代码可直接下载!
您已经开通过在线代码永久免费下载
对不起,您的jQ币不足!可通过发布资源 或
直接充值获取jQ币
取消
开通下载
<!doctype html> <html> <head> <meta charset="utf-8"> <title>墨滴-jq22.com</title> <script src="https://www.jq22.com/jquery/jquery-1.10.2.js"></script> <style>
</style> </head> <body>
<script>
</script>
</body> </html>
2012-2021 jQuery插件库版权所有
jquery插件
|
jq22工具库
|
网页技术
|
广告合作
|
在线反馈
|
版权声明
沪ICP备13043785号-1
浙公网安备 33041102000314号