开发者

math to center an image on a screen?

开发者 https://www.devze.com 2023-03-17 06:27 出处:网络
Given a screen of dimensions (w,h) and a photo of dimensi开发者_Python百科on (ww,hh) how do I calculate the x,y point on screen to place the upper left corner of the image so the image is centered?

Given a screen of dimensions (w,h) and a photo of dimensi开发者_Python百科on (ww,hh) how do I calculate the x,y point on screen to place the upper left corner of the image so the image is centered?

Thanks!


x = (w - ww) / 2;
y = (h - hh) / 2;


x = (w/2) - (ww/2)
y = (h/2) - (hh/2)
0

精彩评论

暂无评论...
验证码 换一张
取 消