Author Topic: Calculating correct offset for a scaled image  (Read 2600 times)


Two images, a base texture and an overlay image.  The base image is 'full size', while the overlay is several factors smaller.  In Designer the overlay image needs to be scaled and offset such that it is in the exact correct position on the base image.


What is the formula to calculate the required offset for a scaled image such that it is at the same position over its base texture as it was in Photoshop or other image editing software?  (Eye-balling it isn't accurate enough.)

Basically, I'm using masks that cover only part of the base texture.  The masks need to be at the same base texture offset as they are in Photoshop.  But since the Transform2D is applying the scale before the translation I'm having problems calculating the correct offset.


In Photoshop:

Base texture: 2048x2048
Mask: 512x512 positioned over the base texture at a (top, left) offset of (1536, 752).

In Designer with Transform2D:

Scale is easy, /2 twice to get (4, 0, 4, 0).

The un-scaled offset is (0.75, 0.367).  But that doesn't work after the scaling.  The correct scaled x-offset is -1.5 (-2 * 0.75).  But when I use that formula for the y-offset it is obviously wrong.

Hi Steve,
Sorry for the late reply.
The main difference between Photoshop's canvas coordinates system and Designer's one is that SD origin (0,0) is at the very centre of the canvas, while Photoshop's origin is located at the bottom left corner.
I know that this might be confusing but the best options are :
  • Either use two "Transformation 2D" nodes, one for the scale and one for the translation. (Be careful as the X axis is actually pointing toward the left side)
  • Or use your pattern as an FX-Map input, in which the Matrice is way more easy to use.
I hope this will help.

"Hinhin!" :-D