开发者

math to center an image on a screen?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜