1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
| <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>练字格子</title> <style> div { width: 50px; } </style> </head> <body> <h1>动画</h1> <div> <div id="character-target-div"></div> <div id="character-target2-div"></div> <div id="target"></div> <hr> <button id="animate-button">动画</button> <button id="animate-button2">连续动画</button> </div> <h1>按笔画填写</h1> <div> <div id="ceshi"></div> </div> <script src="https://cdn.jsdelivr.net/npm/hanzi-writer@3.0/dist/hanzi-writer.min.js"></script> <script>
var writer = HanziWriter.create('character-target-div', '我', { width: 100, height: 100, padding: 5, strokeColor: '#EE00FF', radicalColor: '#168F16', showOutline: true, strokeAnimationSpeed: 1, delayBetweenStrokes: 10, showCharacter: false, }); document.getElementById('animate-button').addEventListener('click', function() { writer.loopCharacterAnimation(); });
var char2 = HanziWriter.create('character-target2-div', '爽', { width: 100, height: 100, padding: 5, showCharacter: false }); function chainAnimations() { writer.hideCharacter(); char2.hideCharacter(); writer.animateCharacter({ onComplete: function() { setTimeout(function() { char2.animateCharacter(); }, 1000); } }); } document.getElementById('animate-button2').addEventListener('click', chainAnimations);
var ceshi = HanziWriter.create('ceshi', '测', { width: 150, height: 150, showCharacter: false, padding: 5, showOutline: false, showHintAfterMisses: 3, highlightOnComplete: false, }); ceshi.quiz({ onMistake: function(strokeData) { console.log(strokeData); }, onCorrectStroke: function(strokeData) { console.log(strokeData); }, onComplete: function(summaryData) { console.log(summaryData); } }); </script> </body> </html>
|