How to skew text generated by fillText () for canvas tag in HTML5?

How to skew text generated by fillText () for canvas tag in HTML5?

Will this be done in the same way as MozTransform, webkitTransform, oTransform, transform, etc.?

+4
source share
1 answer

Use an instruction like

context.setTransform (1, -0.2, 0, 1, 0, 0); 

See the specification for canvas transformations .

So where would you use a CSS line like

 -moz-transform: matrix(a, c, b, d, tx, ty) 

you can use javascript

 context.setTransform (a, c, b, d, tx, ty); 

An example of a drawing would be

 context.font = '20px arial,sans-serif' ; context.fillStyle = 'black' ; context.setTransform (1, -0.2, 0, 1, 0, 0); context.fillText ('your text', 10, 10) ; context.setTransform (1, 0, 0, 1, 0, 0); 

Notice the final setTransform , which returns the conversion to identifier.

+9
source

Source: https://habr.com/ru/post/1308528/


All Articles