Currently I have this code:
float tileX = (float)rectangle.X / (float)newTileSize; float tileY = (float)rectangle.Y / (float)newTileSize; int xOrigin = (int)Math.Round(tileX) * newTileSize; int yOrigin = (int)Math.Round(tileY) * newTileSize; // Same idea for the next 4 lines float tileWidth = (float)rectangle.Width / (float)newTileSize; float tileHeight = (float)rectangle.Height / (float)newTileSize; int selectorWidth = (int)Math.Round(tileWidth) * newTileSize; int selectorHeight = (int)Math.Round(tileHeight) * newTileSize;
The reason for the first two lines is because if I don't cast them as a float it does integer division and I was a floating point value instead so I can round it in the next two lines.
This code is fine I guess it just seems like there would be a better way to do it without so much casting. Just seems rather verbose if that makes any sense.