Skip to main content
Known Participant
April 12, 2023
Answered

Stroke text via code in HTML5 canvas

  • April 12, 2023
  • 2 replies
  • 1139 views

Good evening everyone, in the HTML5 canvas is it possible to add a stroke to a text with a line of code? as done, for example, to add a shadow:
this.shadow = new createjs.Shadow("rgba(0,0,0,0.9)",0,0,9);

thank you all so much for any help!

This topic has been closed for replies.
Correct answer JoãoCésar17023019

Hi.

 

Set a value bigger than 0 to the outline property. For example:

this.yourTF.outline = 2;

 

If needed, place two text fields over each other to keep the fill and the stroke.

 

Regards,

JC

2 replies

JoãoCésar17023019
Community Expert
JoãoCésar17023019Community ExpertCorrect answer
Community Expert
April 13, 2023

Hi.

 

Set a value bigger than 0 to the outline property. For example:

this.yourTF.outline = 2;

 

If needed, place two text fields over each other to keep the fill and the stroke.

 

Regards,

JC

Community Expert
April 21, 2023

This is good information JoãoCésar

 

Community Expert
April 13, 2023
Known Participant
April 13, 2023

thank you very much but maybe i misunderstood, i already have some text, i need to add an outer border to this text using code instead of converting it to shape and manually adding the stroke to each letter...

it can probably be done with a trick using a multiple shadow as well but I'm not very handy with the code in the html5 canvas

Community Expert
April 14, 2023

Sorry, I wasn't helpful. Hopefully, you get it figured out.