iddan / react-native-canvas

A Canvas component for React Native
MIT License
990 stars 172 forks source link

How to add rotate on a dom element like text #284

Closed angleneo closed 2 years ago

angleneo commented 2 years ago

I try to use ctx.rotate , but it not work.

fillText(ctx, text = '', color = '#000', x = 0, y = 0, bold = '', rotate ) { if (text) { ctx.fillStyle = color ctx.font = ${bold} ${size}px sans-serif ctx.fillText(text, x, y) ctx.rotate((rotate * Math.PI) / 180) } }

Gabsys commented 2 years ago

If you want to rotate the text, I think you need to call .rotate() first before .fillText()