如何使用 SVG 在網頁上製作手寫文字動畫?
問題陳述:
您正在嘗試對儲存為SVG 的文字進行動畫處理,但您只能夠為筆畫設定動畫,但這不是所需的效果。您希望實現類似於給定範例的動畫,從而創建手繪外觀。這是您到目前為止所擁有的:
代碼示例:
<div> <pre class="brush:php;toolbar:false">.test { width: 300px; } .l1 { animation: dash 15s 1; stroke-dasharray: 300; stroke-dashoffset: 300; animation-fill-mode: forwards; } .l2 { stroke-dasharray: 300; stroke-dashoffset: 300; animation: dash 20s linear forwards; animation-delay: 1s; } .l3 { stroke-dasharray: 300; stroke-dashoffset: 300; animation: dash 25s linear forwards; animation-delay: 2.5s; } .l4 { stroke-dasharray: 300; stroke-dashoffset: 300; animation: dash 25s linear forwards; animation-delay: 4.5s; } @keyframes dash { to { stroke-dashoffset: 0; } }
答案:
動畫您想要實現的目標使用標準的破折號動畫技術,但使用類似於手繪風格。
Dash動畫技術:
標準線,例如:
<path d="M 10,75 L 290,75" stroke="red" stroke-width="50"></path>
透過控制值來動畫關鍵影格中的Stroke-DashArray和Stroke -DashOffset動畫。
.path { stroke-dasharray: 300; stroke-dashoffset: 300; animation: dash 15s 1; animation-fill-mode: forwards; } @keyframes dash { to { stroke-dashoffset: 0; } }
在此範例中,Stroke-dasharray 屬性定義了路徑上的虛線和間隙的長度,Stroke-dashoffset 定義了路徑內虛線的偏移量。隨著動畫從 0% 進展到 100%,筆畫短劃線偏移值會減少,導致虛線沿著路徑逐漸出現。
建立手繪外觀:
要使用輪廓剪輯動畫筆劃,需要使用一個附加的 SVG 路徑以及與動畫筆劃的寬度和顏色相匹配的筆劃。此輪廓路徑應覆蓋動畫筆畫將佔據的整個區域。透過將輪廓的描邊線連接屬性定義為斜接,創建了尖角樣式,給人一種手繪線條的印象。
以上是如何使用SVG的Dash動畫創造手繪文字動畫效果?的詳細內容。更多資訊請關注PHP中文網其他相關文章!

重構自己的代碼看起來是什麼樣的?約翰·瑞亞(John Rhea)挑選了他寫的一個舊的CSS動畫,並介紹了優化它的思維過程。

CSSanimationsarenotinherentlyhardbutrequirepracticeandunderstandingofCSSpropertiesandtimingfunctions.1)Startwithsimpleanimationslikescalingabuttononhoverusingkeyframes.2)Useeasingfunctionslikecubic-bezierfornaturaleffects,suchasabounceanimation.3)For

@keyframesispopularduetoitsversatoryand and powerincreatingsmoothcsssanimations.keytricksinclude:1)definingsmoothtransitionsbetnestates,2)使用AnimatingMultatingMultationMultationProperPertiessimultane,3)使用使用4)使用BombingeNtibalibility,4)使用CombanningWiThjavoFofofofoftofofo

CSSCOUNTERSAREDOMANAGEAUTOMANAMBERINGINWEBDESIGNS.1)他們可以使用forterablesofcontents,ListItems,and customnumbering.2)AdvancedsincludenestednumberingSystems.3)挑戰挑戰InclassINCludeBrowsEccerCerceribaliblesibility andperformiballibility andperformissises.4)創造性

使用滾動陰影,尤其是對於移動設備,是克里斯以前涵蓋的一個微妙的UX。傑夫(Geoff)涵蓋了一種使用動畫限制屬性的新方法。這是另一種方式。


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

EditPlus 中文破解版
體積小,語法高亮,不支援程式碼提示功能

SublimeText3 Linux新版
SublimeText3 Linux最新版

mPDF
mPDF是一個PHP庫,可以從UTF-8編碼的HTML產生PDF檔案。原作者Ian Back編寫mPDF以從他的網站上「即時」輸出PDF文件,並處理不同的語言。與原始腳本如HTML2FPDF相比,它的速度較慢,並且在使用Unicode字體時產生的檔案較大,但支援CSS樣式等,並進行了大量增強。支援幾乎所有語言,包括RTL(阿拉伯語和希伯來語)和CJK(中日韓)。支援嵌套的區塊級元素(如P、DIV),

Safe Exam Browser
Safe Exam Browser是一個安全的瀏覽器環境,安全地進行線上考試。該軟體將任何電腦變成一個安全的工作站。它控制對任何實用工具的訪問,並防止學生使用未經授權的資源。

Dreamweaver Mac版
視覺化網頁開發工具