# Change text orientation on canvas

Iason Dimitrakopoulos

Greenhorn

Posts: 13

Iason Dimitrakopoulos

Greenhorn

Posts: 13

posted 12 years ago

i did thanks

i've used graphics 2d to rotate the text but now i have encountered a second problem. i rotate the graphics to draw the tilted text

however r.x and r.y are x,y values in a Rectangle prior to rotating the graphics. I want to place the text exactly at that point but not the point that has been rotated, is there a mathematical formula to go back to the original point? i hope someone understands something from this because my english isnt so good

i've used graphics 2d to rotate the text but now i have encountered a second problem. i rotate the graphics to draw the tilted text

however r.x and r.y are x,y values in a Rectangle prior to rotating the graphics. I want to place the text exactly at that point but not the point that has been rotated, is there a mathematical formula to go back to the original point? i hope someone understands something from this because my english isnt so good

posted 12 years ago

I think I understand. You want the string to start at x,y (i.e. 1,2), but once the graphics object is rotated the string appears at the rotated coordinate (i.e. 1,1). You could use trig, but my math skills are far worse than your English. I'd say the easy way would be to create a new Image object (Component.createImage()), do the rotate+write routine on its Graphics context, then paint the Image at x,y on your canvas.