This is integer division, which will always give you an integer whereas your ratio will most likely be a decimal number. You need to cast one of the operands to float, or move this part of the expression after screenwidth*0.3.texture.getsize().x/texture.getsize.()y