1. When the layout is rotated it behaves that same as normal bounded scrolling.
2. Change the formulas like so:
set scroll x: Clamp(Sprite.X, WindowWidth/(2*LayoutScale), LayoutWidth-WindowWidth/(2*LayoutScale))
set scroll y: Clamp(Sprite.Y, WindowHeight/(2*LayoutScale), LayoutHeight-WindowHeight/(2*LayoutScale))
If just the layer is scaled replace LayoutScale with LayerScale(layer).