DIV CSS 佈局教程網

您现在的位置: DIV+CSS佈局教程網 >> 網頁腳本 >  >> HTML基礎知識 >> HTML和Xhtml
HTML5 Canvas 文字筆觸顏色:strokeStyle 與 strokeText
編輯:HTML和Xhtml     

若要為 Canvas 文字加上描邊效果,可使用 strokeStyle 設定筆觸顏色,再用 strokeText() 繪製文字輪廓。

基本語法

context.strokeStyle = "blue";
context.strokeText("Hello World!", x, y);

描邊效果通常會搭配 lineWidth 使用,線寬越大,文字輪廓越明顯。若同時使用 fillText() 與 strokeText(),可以做出填色加描邊的立體文字效果。

範例

context.font = "60pt Calibri";
context.lineWidth = 3;
context.strokeStyle = "blue";
context.strokeText("Hello World!", 80, 110);

實務應用中,描邊文字常用於標題、海報、遊戲介面或需要提高辨識度的視覺設計。

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved