搜索
热搜: 活动 交友 discuz
查看: 22|回复: 5

马黑黑老师《这个图案以前用svgdr画过》

[复制链接]
  • TA的每日心情
    开心
    昨天 21:56
  • 签到天数: 444 天

    连续签到: 5 天

    [LV.9]以坛为家II

    519

    主题

    1370

    回帖

    1万

    积分

    社区管理员

    积分
    13686

    最佳新人活跃会员热心会员推广达人宣传达人灌水之王突出贡献优秀版主荣誉管理

    发表于 前天 19:47 | 显示全部楼层 |阅读模式
    <style>
        /* svg id选择器可以定义使用的部分属性(fill、stroke-*等) */
        #msvg { display: block; margin: auto; fill: none; stroke: steelblue; stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; }
        /* 外层图案(齿轮)样式 */
        .path{ stroke-dasharray: var(--len); stroke-dashoffset: var(--len); animation: draw linear 6s var(--delay) forwards; --delay: 4s; }
        /* 里层图案(圆)样式 */
        .cc { animation: grow linear 4s forwards; }
        /* 描边动画 */
        @keyframes draw { to { stroke-dashoffset: 0; } }
        /* 圆变大动画 */
        @keyframes grow { to { r: 120; } }
    </style>
    
    <svg id="msvg" width="600" height="600" viewBox="-200 -200 400 400" xmlns="http://www.w3.org/2000/svg"></svg>
    
    <script>
        loadJs('https://638183.freep.cn/638183/svgdr/svgdr.min.js', tzRun);
    
        function tzRun() {
            var dr = _dr(msvg);
    
            const vertex1 = dr.circlePoints(26, 200, 180); // 外切圆1点坐标
            const vertex2 = dr.circlePoints(26, 200, 160); // 外切圆2点坐标
            // 拼接路径
            let path = 'M';
            for (let i = 0; i < vertex1.length; i++) {
                const v1 = vertex1[i].join(',');
                const v2 = vertex2[i].join(',');
                path += i % 2 === 0 ? v1 + ' ' + v2 + ' ' : v2 + ' ' + v1 + ' ';
            };
            path += 'Z'; // 路径闭环
            dr.path(path).set('class', 'path'); // 绘制路径
            dr.elm.style.setProperty('--len', dr.elm.getTotalLength()); // 设置--len变量
    
            dr.circle(0, 0, 0).set('class', 'cc'); // 画圆
        }
    
        function loadJs(url, callback) {
            var script = document.createElement('script');
            script.charset = 'utf-8';
            script.src = url;
            script.onload = function() {
                if (callback) callback();
            };
            document.head.appendChild(script);
        }
    </script>
    
  • TA的每日心情
    开心
    昨天 21:56
  • 签到天数: 444 天

    连续签到: 5 天

    [LV.9]以坛为家II

    519

    主题

    1370

    回帖

    1万

    积分

    社区管理员

    积分
    13686

    最佳新人活跃会员热心会员推广达人宣传达人灌水之王突出贡献优秀版主荣誉管理

     楼主| 发表于 前天 19:48 | 显示全部楼层
    path 路径通过两个外切圆获取各 26 个圆周上的点坐标,这些点按照预设规则连线成为闭合路径,最终的路径数据如下:
    1. M180.00,0.00 160.00,0.00 155.35,38.29 174.77,43.08 159.38,83.65 141.67,74.36 119.76,106.10 134.73,119.36 102.25,148.14 90.89,131.68 56.74,149.60 63.83,168.30 21.70,178.69 19.29,158.83 -19.29,158.83 -21.70,178.69 -63.83,168.30 -56.74,149.60 -90.89,131.68 -102.25,148.14 -134.73,119.36 -119.76,106.10 -141.67,74.36 -159.38,83.65 -174.77,43.08 -155.35,38.29 -160.00,0.00 -180.00,0.00 -174.77,-43.08 -155.35,-38.29 -141.67,-74.36 -159.38,-83.65 -134.73,-119.36 -119.76,-106.10 -90.89,-131.68 -102.25,-148.14 -63.83,-168.30 -56.74,-149.60 -19.29,-158.83 -21.70,-178.69 21.70,-178.69 19.29,-158.83 56.74,-149.60 63.83,-168.30 102.25,-148.14 90.89,-131.68 119.76,-106.10 134.73,-119.36 159.38,-83.65 141.67,-74.36 155.35,-38.29 174.77,-43.08 Z
    复制代码

  • TA的每日心情
    开心
    昨天 21:56
  • 签到天数: 444 天

    连续签到: 5 天

    [LV.9]以坛为家II

    519

    主题

    1370

    回帖

    1万

    积分

    社区管理员

    积分
    13686

    最佳新人活跃会员热心会员推广达人宣传达人灌水之王突出贡献优秀版主荣誉管理

     楼主| 发表于 前天 19:49 | 显示全部楼层
    图案中,圆从小到大的动画,是通过改变圆的半径而得,半径从 0 长到 120。

    在CSS中,圆的半径属性 r 得到原生支持,所以可以使用 @keyframes 关键帧动画选择器基于圆的半径设置动画
  • TA的每日心情
    开心
    昨天 21:56
  • 签到天数: 444 天

    连续签到: 5 天

    [LV.9]以坛为家II

    519

    主题

    1370

    回帖

    1万

    积分

    社区管理员

    积分
    13686

    最佳新人活跃会员热心会员推广达人宣传达人灌水之王突出贡献优秀版主荣誉管理

     楼主| 发表于 前天 19:54 | 显示全部楼层
    1. <style>
    2. @import 'https://638183.freep.cn/638183/web/tz/tz.v4.css';
    3. .pa {
    4. --offsetX: 0px;
    5. --bg: url('https://ff.xiaoqiaodali.top:5401/i/2026/06/21/6a36d4571ca23.gif') no-repeat center/cover;
    6. --ma-size: 12%;
    7. width: 450px;
    8. height: 800px;
    9. position: relative;
    10. overflow: hidden;
    11. }
    12. .pa *, .pa *::before, .pa *::after {
    13. content: none !important;
    14. }
    15. #custom-lrc-container {
    16. position: absolute;
    17. top: 50px; /* 定位显示的位置 */
    18. right: 30px;
    19. width: 2em; /* 宽高与横排时反过来 */
    20. height: 80%;
    21. writing-mode: vertical-rl; /* 设为竖排 */
    22. z-index: 9999;
    23. pointer-events: none;
    24. }
    25. .lrc-line {
    26. position: absolute;
    27. left: 50%;
    28. transform: translateX(-50%);
    29. white-space: nowrap;
    30. color: #fefefe;
    31. color:darkgreen;
    32. font-size: 20px;
    33. font-family: "隶书", "LiSu", serif;
    34. font-weight: normal;
    35. text-shadow: 0 0 12px rgba(0,0,0,0.8);
    36. opacity: 0;
    37. transition: opacity 0.5s ease, transform 0.5s ease;
    38. margin: 0;
    39. top: 0;
    40. }
    41. .lrc-line.active {
    42. opacity: 1;
    43. transform: translateX(-50%) scale(1.15);
    44. z-index: 10;
    45. }
    46. @media (max-aspect-ratio: 9/16) {
    47. .pa {
    48. width: 100vw;
    49. height: calc(100vw * 16 / 9);
    50. }
    51. }
    52. @media (min-aspect-ratio: 9/16) {
    53. .pa {
    54. width: calc(100vh * 9 / 16);
    55. height: 100vh;
    56. }
    57. }
    58. </style>
    59. <div class="pa">
    60. <div id="custom-lrc-container"></div>
    61. </div>
    62. <script type="module">
    63. import TZ from 'https://638183.freep.cn/638183/web/tz/tz.v4.js';
    64. const tz = TZ.TZ('pa');
    65. tz.add('audio', '', '', { src: 'https://imgimg.qqdsw8.cn/view.php/915c88832e0049c6bd78acf0744ba633.mp3' });
    66. tz.add('video', '', 'pd-vid', {src: 'https://imgimg.qqdsw8.cn/view.php/2ec28ce2bc8f195e7a531771c6e8ff41.mp4'}).style('opacity: 0.5;');
    67. //
    68. tz.add('img', '', 'ma', {
    69. src: 'https://pic1.imgdb.cn/item/6a36c2802830ce602a508060.gif'
    70. })
    71. .style('right: 10px; bottom: 400px;')
    72. .playmp3();
    73. //
    74. tz.bgprog().style('bottom: 50%; color: #fefefe; width: 80%; ')
    75. tz.fs().style('left: 40px; top: 40px;');
    76. const lrcString = `
    77. [00:04.45]曾醉
    78. [00:06.33]作词:五子
    79. [00:07.91]作曲:Winky诗
    80. [00:10.10]演唱:HITA
    81. [00:25.50]山深问桃花染过几度春
    82. [00:29.65]哪一枝勾住过客衣上风尘
    83. [00:36.34]有倦意三分
    84. [00:38.38]要行路千程
    85. [00:41.12]怎记这山水静默待离人
    86. [00:49.95]轻舟邀斜月听岸上孤筝
    87. [00:54.14]回旋处恰趁醉踏青石前门
    88. [01:00.79]有余音两声
    89. [01:02.98]共与你微醺
    90. [01:04.90]融入这一夜长灯落满身
    91. [01:13.09]曾画下山间桃花流水逐云
    92. [01:18.43]跌破了一晌贪梦了无痕
    93. [01:23.92]倚泉浣笔重逢或偶遇洗不净
    94. [01:29.40]点墨片心留在归梦时分
    95. [01:58.22]斟满浮生在酒中浮与沉
    96. [02:02.17]哪一口填满岁月旧日余温
    97. [02:08.79]有醉意三分
    98. [02:10.90]都酿做前尘
    99. [02:13.70]梦醒后又在何处扮离人
    100. [02:22.39]红梅邀斜月听墙里孤筝
    101. [02:26.85]回旋处不是你惯唱的游吟
    102. [02:33.54]似乡音两声
    103. [02:35.68]唱今雪纷纷
    104. [02:37.64]错看成那年桃花落满身
    105. [02:45.83]曾见你山间走马落日长云
    106. [02:51.25]踏破了一声珍重无处闻
    107. [02:56.70]敛花做酒
    108. [02:58.57]相送或独酌都太冷清
    109. [03:02.25]待到如今那池春水已平
    110. [03:08.13]用醉眼看不清擦肩人
    111. [03:13.70]酒醒后分不清假与真
    112. [03:19.13]行遍天涯旧约难记存
    113. [03:23.85]分岔太多归路不可寻
    114. [03:29.41]曾画下山间桃花流水逐云
    115. [03:34.88]跌破了一晌贪梦何处寻
    116. [03:40.28]倚泉浣笔
    117. [03:42.30]重逢或偶遇洗不净
    118. [03:45.82]点墨片心留在归梦时分
    119. [03:51.23]曾见你山间走马落日长云
    120. [03:56.60]踏破了一声珍重了无痕
    121. [04:02.05]敛花做酒
    122. [04:03.82]相送或独酌都太冷清
    123. [04:07.66]待到如今那池春水已平`;
    124. function initCustomLrc(lrcText) {
    125. const container = document.getElementById('custom-lrc-container');
    126. const lines = [];
    127. const lineRegex = /\[(\d{2})\d{2})\.(\d{2,3})\](.*)/;
    128. const rawLines = lrcText.split('\n');
    129. rawLines.forEach(text => {
    130. const match = text.match(lineRegex);
    131. if (match) {
    132. const minutes = parseInt(match[1]);
    133. const seconds = parseInt(match[2]);
    134. const milliseconds = parseInt(match[3]);
    135. const time = minutes * 60 + seconds + milliseconds / 1000;
    136. let content = match[4].trim();
    137. content = content.replace(/&#\d+;/g, '').trim();
    138. if (content) {
    139. lines.push({ time, content, element: null });
    140. }
    141. }
    142. });
    143. lines.forEach((line) => {
    144. const div = document.createElement('div');
    145. div.className = 'lrc-line';
    146. div.textContent = line.content;
    147. container.appendChild(div);
    148. line.element = div;
    149. });
    150. const audio = document.querySelector('.pa audio');
    151. if (audio) {
    152. audio.addEventListener('timeupdate', () => {
    153. const currentTime = audio.currentTime;
    154. let activeIndex = -1;
    155. for (let i = 0; i < lines.length; i++) {
    156. if (currentTime >= lines[i].time) {
    157. activeIndex = i;
    158. } else {
    159. break;
    160. }
    161. }
    162. lines.forEach((line, idx) => {
    163. if (idx === activeIndex) {
    164. line.element.classList.add('active');
    165. } else {
    166. line.element.classList.remove('active');
    167. }
    168. });
    169. });
    170. audio.addEventListener('ended', () => {
    171. lines.forEach(line => line.element.classList.remove('active'));
    172. });
    173. }
    174. }
    175. setTimeout(() => {
    176. const audioEl = document.querySelector('.pa audio');
    177. if(audioEl) {
    178. initCustomLrc(lrcString);
    179. } else {
    180. const observer = new MutationObserver(() => {
    181. const aud = document.querySelector('.pa audio');
    182. if(aud) {
    183. initCustomLrc(lrcString);
    184. observer.disconnect();
    185. }
    186. });
    187. observer.observe(document.querySelector('.pa'), { childList: true, subtree: true });
    188. }
    189. }, 500);
    190. let prog = document.querySelector('.prog');
    191. prog.style.transform = 'rotate(-90deg)';
    192. prog.style.cssText += 'left:300px;top:250px;color:brown;';
    193. </script>
    复制代码
    -->
    LRC歌词
  • TA的每日心情
    奋斗
    昨天 13:23
  • 签到天数: 528 天

    连续签到: 17 天

    [LV.9]以坛为家II

    192

    主题

    887

    回帖

    1万

    积分

    社区贵宾

    积分
    13312

    最佳新人活跃会员热心会员推广达人宣传达人灌水之王突出贡献

    发表于 昨天 14:01 | 显示全部楼层
    本帖最后由 klxf 于 2026-6-22 23:20 编辑

    漂亮~谢谢分享,祝开心

    点评

    谢谢友友光临!  详情 回复 发表于 昨天 21:58
    该会员没有填写今日想说内容.
  • TA的每日心情
    开心
    昨天 21:56
  • 签到天数: 444 天

    连续签到: 5 天

    [LV.9]以坛为家II

    519

    主题

    1370

    回帖

    1万

    积分

    社区管理员

    积分
    13686

    最佳新人活跃会员热心会员推广达人宣传达人灌水之王突出贡献优秀版主荣誉管理

     楼主| 发表于 昨天 21:58 | 显示全部楼层
    klxf 发表于 2026-6-22 14:01
    本帖最后由 klxf 于 2026-6-22 21:57 编辑 漂亮~谢谢分享,祝开心

    谢谢友友光临!
    返回列表 发新帖
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    QQ|Archiver|小黑屋|纳兰音画网 ( 蜀ICP备2021011087号-1 )

    GMT+8, 2026-6-23 01:16 , Processed in 0.126232 second(s), 24 queries .

    Powered by Discuz! X3.5

    © 2001-2020 Comsenz Inc.

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