Is there a way you can break text inside of the canvas? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 6

Is there a way you can break text inside of the canvas?

Canvas trouble

17th Sep 2019, 2:17 PM
Web Shark
Web Shark - avatar
8 Answers
17th Sep 2019, 4:43 PM
Anthony Johnson
Anthony Johnson - avatar
+ 6
The text is not going to be animated... It is going to be ptinted and when it gets to the end of the width... I needed it to break to the next line.
17th Sep 2019, 3:26 PM
Web Shark
Web Shark - avatar
+ 6
Anthony Johnson... The answer was what I was looking for... Has solved my problem. Thanks
17th Sep 2019, 6:17 PM
Web Shark
Web Shark - avatar
+ 5
Its cool 😎
17th Sep 2019, 7:08 PM
Web Shark
Web Shark - avatar
+ 2
Your welcome. Sorry for all the extra stuff in the code. I just used it for a temporary template lol. Glad I could help. 😁
17th Sep 2019, 6:42 PM
Anthony Johnson
Anthony Johnson - avatar
+ 1
I don't think the canvas elements fillText method supports CSS word-break or word-wrap methods. Its worth a shot, I could be wrong. It might have to be done manually with a JavaScript function. Something like if text === context.canvas.width {transform()}.... it seems like alot of work. But it could work. Is the text going to be animated?
17th Sep 2019, 3:07 PM
Anthony Johnson
Anthony Johnson - avatar
0
Like how?
17th Sep 2019, 2:33 PM
Dlite
Dlite - avatar
0
text inside canvas can only be replaced not modified
18th Sep 2019, 8:35 PM
Catalin Popinciuc
Catalin Popinciuc - avatar