Rotated StringShape in buffered picture

I’ve noticed that if I use a rotated StringShape in a picture buffer, it ends up being displaced from the preferred location, but if I draw directly to the screen, no such problem.

So, for instance, in a canvas Paint event:
dim pp as Picture
dim gg as Graphics
dim tLabel as StringShape
Dim r As New RectShape

r.Width = 50
r.Height =15
r.Border = 100
r.BorderColor = RGB(0, 0, 0) // black
r.FillColor = RGB(50, 155, 155) // teal
r.BorderWidth = 1
r.Rotation =30*3.14/180
gg.DrawObject(r, 150, 150)

tLabel=new StringShape
tLabel.text=“test text”
gg.DrawObject tLabel,150,150
g.DrawPicture pp,0,0
//takes care of stuff on the offscreen bitmap
//rotated text is black and nowhere near the rectangle

g.DrawObject(r, 100,150)
g.DrawObject (tLabel,100,150)
//these two drawn direct to screen are colocated

Either I am missing something or, I suspect, there is a bug somewhere. OS is Mac 10.11.6, Xojo 2018.1.1

I think you are building your buffer pict size based on the wrong object. Base it off the canvas instead trueWindow.

This, near start of your code, fixes the issue…

Dim r As New RectShape
pp= new picture(me.width,me.height, 32)

If you base off trueWindow, you have to compensate for the x,y of the canvas within the window.

Oh. Just found your other thread. You’re trying to do caching for HiDPI. Yep, text object rotation is about a weird x,y that varies with window height.

Thanks for the confirmation. Probably (?) could get this to work by using the stranger way I cached the HiDPI graphics the first time (use new picture but scale/rescale it to match what I’ll want to send to screen). Will have to take a look later, but that might be a useful workaround for my present situation.

PS–do you know if there is a bug report on that? I looked and found a ton of things tangled with rotated text but not this specific issue.

I’ve just read this topic briefly… but <> seems to be a similar (or maybe the underlying the same) issue: macOS: Position of rotated StringShape is incorrect (when printing).

Thanks, similar but different as here it is the canvas location that is bad and that seems to require use of the offscreen Picture created by TrueWindow.BitmapForCaching. Using a regular Picture offscreen seems OK, as does drawing directly to the screen. May well be something similar at the base. Might submit a bug report if nothing else turns up.

Just out of curiosity… in which direction(s) is it offset?

Offset direction depends on the rotation. I made a simple app where you can move a slider and change the rotation and basically the positions end up defining a circle–I haven’t quite gotten down to figuring out what controls the radius or the position of the center, though the center generally seems to be a negative y position. Rotates clockwise about the center point.

So the modified clock demo to show how the rotated test gets rotated is here.