最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

js+canvas實(shí)現(xiàn)網(wǎng)站背景鼠標(biāo)吸附線條動(dòng)畫

 更新時(shí)間:2022年07月21日 17:10:21   作者:hst?  
這篇文章主要為大家詳細(xì)介紹了js+canvas實(shí)現(xiàn)網(wǎng)站背景鼠標(biāo)吸附線條動(dòng)畫,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了js+canvas實(shí)現(xiàn)網(wǎng)站背景鼠標(biāo)吸附線的具體代碼,供大家參考,具體內(nèi)容如下

完整代碼:

<!DOCTYPE html>
<html lang="en">
<head>
? ? <meta charset="UTF-8">
? ? <title>Title</title>
</head>
<body>
<script>
! function() {
? ? function n(n, e, t) {
? ? ? ? return n.getAttribute(e) || t
? ? }

? ? function e(n) {
? ? ? ? return document.getElementsByTagName(n)
? ? }

? ? function t() {
? ? ? ? var t = e("script"),
? ? ? ? ? ? o = t.length,
? ? ? ? ? ? i = t[o - 1];
? ? ? ? return {
? ? ? ? ? ? l: o,
? ? ? ? ? ? z: n(i, "zIndex", -1),
? ? ? ? ? ? o: n(i, "opacity", .5),
? ? ? ? ? ? c: n(i, "color", "0,0,0"),
? ? ? ? ? ? n: n(i, "count", 99)
? ? ? ? }
? ? }

? ? function o() {
? ? ? ? a = m.width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth, c = m.height = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight
? ? }

? ? function i() {
? ? ? ? r.clearRect(0, 0, a, c);
? ? ? ? var n, e, t, o, m, l;
? ? ? ? s.forEach(function(i, x) {
? ? ? ? ? ? for(i.x += i.xa, i.y += i.ya, i.xa *= i.x > a || i.x < 0 ? -1 : 1, i.ya *= i.y > c || i.y < 0 ? -1 : 1, r.fillRect(i.x - .5, i.y - .5, 1, 1), e = x + 1; e < u.length; e += 1) {
? ? ? ? ? ? ? ? n = u[e], null !== n.x && null !== n.y && (o = i.x - n.x, m = i.y - n.y, l = o * o + m * m, l < n.max && (n === y && l >= n.max / 2 && (i.x -= .03 * o, i.y -= .03 * m), t = (n.max - l) / n.max, r.beginPath(), r.lineWidth = t / 2, r.strokeStyle = "rgba(" + d.c + "," + (t + .2) + ")", r.moveTo(i.x, i.y), r.lineTo(n.x, n.y), r.stroke()))
? ? ? ? ? ? }
? ? ? ? }), x(i)
? ? }
? ? var a, c, u, m = document.createElement("canvas"),
? ? ? ? d = t(),
? ? ? ? l = "c_n" + d.l,
? ? ? ? r = m.getContext("2d"),
? ? ? ? x = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function(n) {
? ? ? ? ? ? window.setTimeout(n, 1e3 / 45)
? ? ? ? },
? ? ? ? w = Math.random,
? ? ? ? y = {
? ? ? ? ? ? x: null,
? ? ? ? ? ? y: null,
? ? ? ? ? ? max: 2e4
? ? ? ? };
? ? m.id = l, m.style.cssText = "position:fixed;top:0;left:0;z-index:" + d.z + ";opacity:" + d.o, e("body")[0].appendChild(m), o(), window.onresize = o, window.onmousemove = function(n) {
? ? ? ? n = n || window.event, y.x = n.clientX, y.y = n.clientY
? ? }, window.onmouseout = function() {
? ? ? ? y.x = null, y.y = null
? ? };
? ? for(var s = [], f = 0; d.n > f; f += 1) {
? ? ? ? var h = w() * a,
? ? ? ? ? ? g = w() * c,
? ? ? ? ? ? v = 2 * w() - 1,
? ? ? ? ? ? p = 2 * w() - 1;
? ? ? ? s.push({
? ? ? ? ? ? x: h,
? ? ? ? ? ? y: g,
? ? ? ? ? ? xa: v,
? ? ? ? ? ? ya: p,
? ? ? ? ? ? max: 6e3
? ? ? ? })
? ? }
? ? u = s.concat([y]), setTimeout(function() {
? ? ? ? i()
? ? }, 100)
}();
</script>
</body>
</html>

效果圖:

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論

海城市| 华亭县| 兴山县| 万安县| 大足县| 宜兰县| 两当县| 隆尧县| 忻城县| 特克斯县| 辰溪县| 柞水县| 贵定县| 东兴市| 天全县| 宝山区| 岚皋县| 台前县| 芮城县| 越西县| 兴隆县| 蓬莱市| 遵化市| 三亚市| 通榆县| 荥经县| 镇康县| 大竹县| 西和县| 新龙县| 神池县| 义马市| 余江县| 新巴尔虎右旗| 商水县| 九龙城区| 大庆市| 南阳市| 定远县| 韶山市| 乳源|