Skip to main content
Known Participant
Apr 12, 2023 4:34 PM UTC
Answered

Stroke text via code in HTML5 canvas

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 is closed to new replies. Start a new post to keep the conversation going.
JoãoCésar17023019
JoãoCésar17023019Correct answer
Community Expert
Apr 13, 2023 11:36 AM UTC

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

6 replies

JoãoCésar17023019
Community Expert
JoãoCésar17023019Community ExpertCorrect answer
Community Expert
Apr 13, 2023 11:36 AM UTC

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

Translate
Community Expert
Apr 21, 2023 1:31 AM UTC

This is good information JoãoCésar

 

Translate
Community Expert
Apr 13, 2023 1:18 AM UTC
Known Participant
Apr 13, 2023 7:34 AM UTC

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

Translate
Community Expert
Apr 14, 2023 12:45 AM UTC

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

Translate