楼主: 花简静

花简静贴子代码及说明汇总(翻页有新贴)

[复制链接]
一叶知秋 版主勋章 山高为峰 山外有山 樱果相依 24 46 47 48 闲花落
 楼主| 发表于 2024-5-16 21:44 | 显示全部楼层
本帖最后由 花简静 于 2024-5-20 19:55 编辑

5·20






点评
回复

使用道具

一叶知秋 版主勋章 山高为峰 山外有山 樱果相依 24 46 47 48 闲花落
 楼主| 发表于 2024-5-16 21:44 | 显示全部楼层
本帖最后由 花简静 于 2024-8-18 15:28 编辑

<style>     #papa { margin: 130px 0 20px calc(50% - 931px); width: 1700px; height: 900px; background: #f1f1f1 url('https://642303.freep.cn/642303/tu/5y06.webp') no-repeat center/cover; box-shadow: 3px 4px 8px #000; overflow: hidden; z-index: 1; position: relative; --x: 0; --y: 0; }     #papa:hover #mplay { opacity: .5; }     #mplay { position: absolute; width: 120px; height: 120px; left: var(--x); top: var(--y); border: 1px solid #eee; border-radius: 50%; background: url('https://pic.imgdb.cn/item/65b11e61871b83018a790510.webp') no-repeat -10px -10px; opacity: 0; cursor: pointer; transition: 1s; animation: rot 5s linear infinite var(--state); display: grid; place-items: center; font-weight: bold; color: red; text-shadow: 1px 1px 2px white; }     #vid { position: absolute; left: 0; bottom: 0; width: 100%; height: calc(100% + 80px); object-fit: cover; mix-blend-mode: screen; pointer-events: none; }     #canv { position: absolute; mix-blend-mode: screen; opacity: .5; z-index: 2;}     @keyframes rot { to { transform: rotate(360deg); } } </style>   <div id="papa">     <audio id="aud" src="https://music.163.com/song/media/outer/url?id=28699996" loop autoplay></audio>     <canvas id="mycanv" width="1700" height="900" style="border:0px solid gray"></canvas>     <video id="vid" src="https://img.tukuppt.com/video_show/2418175/00/18/94/5ef7a50c397ff.mp4" loop muted></video>     <div id="mplay">5·20</div> </div>   <script>   var ww = mycanv.width, hh = mycanv.height, deg = -90, raf = null; var ctx = mycanv.getContext('2d'); class ccText { constructor(text) { this.chars = text.split(''); this.colors = this.chars.map(color => `#${Math.random().toString(16).substr(4,4.95)}`); }; draw(context) { context.font = 'bold 40px sans-serif'; context.textAlign = 'center'; context.textBaseline = 'middle'; context.shadowOffsetX = -2; context.shadowOffsetY = 2; context.shadowColor = '#000'; context.shadowBlur = 4; var a = 360 / this.chars.length, r1 = ww/2 - 620, r2 = hh/2 - 360; this.chars.forEach((char,key) => { var rad = (a * key + deg) * Math.PI / 180; var x = ww/1.6 + r1 * Math.cos(rad), y = hh/1.25 + r2 * Math.sin(rad); context.fillStyle = this.colors[key]; context.fillText(char, x, y); }); }; }; var cc = new ccText('千山论坛朋友们五二〇快乐');   var render = () => { aud.paused ? cancelAnimationFrame(raf) : raf = requestAnimationFrame(render); ctx.clearRect(0, 0, ww, hh); deg = (deg + 0.5) % 360; cc.draw(ctx); }; papa.onmousemove = (e) => {     if(e.target.id === 'mplay') return;     var x = e.offsetX, y = e.offsetY;     if(x < 60) x = 60;     if(x > papa.offsetWidth - 60) x = papa.offsetWidth - 60;     if(y < 60) y = 60;     if(y > papa.offsetHeight - 60) y = papa.offsetHeight - 60;     papa.style.setProperty('--x', `${x - 60}px`);     papa.style.setProperty('--y', `${y - 60}px`);     mplay.style.backgroundPosition = `-${x - 60}px -${y - 60}px`; }; mplay.onclick = () => aud.paused ? aud.play() : aud.pause();   aud.onplaying = aud.onpause = () => mState(); aud.onseeked = () => cancelAnimationFrame(raf);   var mState = () => aud.paused ?     (papa.style.setProperty('--state', 'paused'), vid.pause(), cancelAnimationFrame(raf)) :     (papa.style.setProperty('--state', 'running'), vid.play(), render());   </script> <BR><BR><BR><BR><BR><BR>
点评
回复

使用道具

一叶知秋 版主勋章 山高为峰 山外有山 樱果相依 24 46 47 48 闲花落
 楼主| 发表于 2024-5-16 21:44 | 显示全部楼层
点评
回复

使用道具

一叶知秋 版主勋章 山高为峰 山外有山 樱果相依 24 46 47 48 闲花落
 楼主| 发表于 2024-5-18 21:37 | 显示全部楼层
点评
回复

使用道具

一叶知秋 版主勋章 山高为峰 山外有山 樱果相依 24 46 47 48 闲花落
 楼主| 发表于 2024-5-18 21:37 | 显示全部楼层
点评
回复

使用道具

一叶知秋 版主勋章 山高为峰 山外有山 樱果相依 24 46 47 48 闲花落
 楼主| 发表于 2024-5-18 21:37 | 显示全部楼层
点评
回复

使用道具

一叶知秋 版主勋章 山高为峰 山外有山 樱果相依 24 46 47 48 闲花落
 楼主| 发表于 2024-5-18 21:37 | 显示全部楼层
点评
回复

使用道具

一叶知秋 版主勋章 山高为峰 山外有山 樱果相依 24 46 47 48 闲花落
 楼主| 发表于 2024-5-18 21:37 | 显示全部楼层
点评
回复

使用道具

一叶知秋 版主勋章 山高为峰 山外有山 樱果相依 24 46 47 48 闲花落
 楼主| 发表于 2024-5-18 21:37 | 显示全部楼层
点评
回复

使用道具

一叶知秋 版主勋章 山高为峰 山外有山 樱果相依 24 46 47 48 闲花落
 楼主| 发表于 2024-5-18 21:37 | 显示全部楼层
点评
回复

使用道具

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|千山论坛

GMT+8, 2024-9-27 02:14

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表