<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>JavaScript on 博客主页</title>
    <link>https://jaxon.ccwu.cc/tags/javascript/</link>
    <description>Recent content in JavaScript on 博客主页</description>
    <generator>Hugo</generator>
    <language>zh</language>
    <lastBuildDate>Thu, 16 Apr 2026 08:00:00 +0800</lastBuildDate>
    <atom:link href="https://jaxon.ccwu.cc/tags/javascript/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>✍️ 汉字笔顺动画演示</title>
      <link>https://jaxon.ccwu.cc/posts/hanzi-writer/</link>
      <pubDate>Thu, 16 Apr 2026 08:00:00 +0800</pubDate>
      <guid>https://jaxon.ccwu.cc/posts/hanzi-writer/</guid>
      <description>&lt;h2 id=&#34;让汉字动起来&#34;&gt;&#xA;  让汉字动起来&#xA;  &lt;a class=&#34;heading-link&#34; href=&#34;#%e8%ae%a9%e6%b1%89%e5%ad%97%e5%8a%a8%e8%b5%b7%e6%9d%a5&#34;&gt;&#xA;    &lt;i class=&#34;fa-solid fa-link&#34; aria-hidden=&#34;true&#34; title=&#34;Link to heading&#34;&gt;&lt;/i&gt;&#xA;    &lt;span class=&#34;sr-only&#34;&gt;Link to heading&lt;/span&gt;&#xA;  &lt;/a&gt;&#xA;&lt;/h2&gt;&#xA;&lt;p&gt;这是一款用于展示汉字笔画顺序和交互式书写练习的 JavaScript 库。&lt;/p&gt;&#xA;&lt;div style=&#34;text-align:center;margin:20px&#34;&gt;&#xA;  &lt;input type=&#34;text&#34; id=&#34;charInput&#34; value=&#34;我&#34; maxlength=&#34;1&#34; style=&#34;padding:8px;font-size:16px;width:60px&#34;&gt;&#xA;  &lt;button onclick=&#34;updateChar()&#34; style=&#34;padding:8px 16px;margin-left:10px&#34;&gt;更新&lt;/button&gt;&#xA;  &lt;button onclick=&#34;playAnimation()&#34; style=&#34;padding:8px 16px;margin-left:10px;background:#007bff;color:#fff;border:none&#34;&gt;播放动画&lt;/button&gt;&#xA;&lt;/div&gt;&#xA;&lt;div id=&#34;animationContainer&#34; style=&#34;width:300px;height:300px;margin:20px auto;border:1px solid #ddd&#34;&gt;&lt;/div&gt;&#xA;&lt;div id=&#34;quizContainer&#34; style=&#34;width:300px;height:300px;margin:20px auto;border:1px solid #ddd&#34;&gt;&lt;/div&gt;&#xA;&lt;div style=&#34;text-align:center&#34;&gt;&#xA;  &lt;button onclick=&#34;startQuiz()&#34; style=&#34;padding:8px 16px&#34;&gt;开始练习&lt;/button&gt;&#xA;  &lt;button onclick=&#34;resetQuiz()&#34; style=&#34;padding:8px 16px;margin-left:10px&#34;&gt;重置&lt;/button&gt;&#xA;&lt;/div&gt;&#xA;&lt;script src=&#34;https://cdn.jsdelivr.net/npm/hanzi-writer@3.5/dist/hanzi-writer.min.js&#34;&gt;&lt;/script&gt;&#xA;&lt;script&gt;&#xA;let animationWriter = null;&#xA;let quizWriter = null;&#xA;let currentChar = &#39;我&#39;;&#xA;let totalMistakes = 0;&#xA;let correctStrokes = 0;&#xA;&#xA;function initWriters(char) {&#xA;  if (animationWriter) animationWriter.destroy();&#xA;  if (quizWriter) quizWriter.destroy();&#xA;  &#xA;  animationWriter = HanziWriter.create(&#39;animationContainer&#39;, char, {&#xA;    width: 280, height: 280, padding: 10,&#xA;    strokeColor: &#39;#007bff&#39;,&#xA;    outlineColor: &#39;#ddd&#39;,&#xA;    showOutline: true,&#xA;  });&#xA;  &#xA;  quizWriter = HanziWriter.create(&#39;quizContainer&#39;, char, {&#xA;    width: 280, height: 280, padding: 10,&#xA;    strokeColor: &#39;#28a745&#39;,&#xA;    outlineColor: &#39;#ddd&#39;,&#xA;    showCharacter: false,&#xA;    showOutline: true,&#xA;  });&#xA;  &#xA;  currentChar = char;&#xA;  totalMistakes = 0;&#xA;  correctStrokes = 0;&#xA;  setTimeout(() =&gt; playAnimation(), 500);&#xA;}&#xA;&#xA;function updateChar() {&#xA;  const char = document.getElementById(&#39;charInput&#39;).value;&#xA;  if (char &amp;&amp; char.length === 1) {&#xA;    initWriters(char);&#xA;  } else {&#xA;    alert(&#39;请输入一个汉字！&#39;);&#xA;  }&#xA;}&#xA;&#xA;function playAnimation() {&#xA;  if (animationWriter) animationWriter.animateCharacter();&#xA;}&#xA;&#xA;function startQuiz() {&#xA;  if (quizWriter) {&#xA;    quizWriter.quiz({&#xA;      onCorrectStroke: () =&gt; correctStrokes++,&#xA;      onMistake: () =&gt; totalMistakes++,&#xA;    });&#xA;  }&#xA;}&#xA;&#xA;function resetQuiz() {&#xA;  if (quizWriter) {&#xA;    quizWriter.destroy();&#xA;    initWriters(currentChar);&#xA;  }&#xA;}&#xA;&#xA;window.addEventListener(&#39;load&#39;, () =&gt; initWriters(&#39;我&#39;));&#xA;&lt;/script&gt;</description>
    </item>
  </channel>
</rss>
