Skip to content

Centres

  • by

Change the co-ordinates of an overlay FROM its centre relative to canvas centre TO its top left corner relative to canvas top left corner (0,0)
W= canvas width
H= canvas height
w= overlay width
h = overlay height
cx = overlay centre x relative to canvas centre x
( left of canvas centre cx is negative, right of canvas centre cx is positive )
cy = overlay centre y relative to canvas centre y
( above canvas centre cy is negative, below canvas centre cy is positive )

Position of top left corner of overlay relative to top left corner of canvas is;
x=((W-w)/2)+cx
y=((H-h)/2)+cy