GML Rectangles, drawing quirk (wtf)


if (abs(mouse_x - x) < 48) && (abs(mouse_y - y) < 48){

So what this does is it creates a rectangle (duh), but the way it works is it creates a little square box on every CORNER from the center origin, meaning that instead of getting the size given, you get twice that. That's weird, but...

THEN if you try to fix it fit into a 100x100 box (like I did here) it either covers a pixel, or doesn't cover a pixel if it's one size too big or too small, even though at an even number it should make a perfect box.

So instead, I had to make 2 parts of this code odd numbered, just to have a symmetrical square.

Question: WHY is it like this? This is really weird.


ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Question: WHY is it like this? This is really weird.
GPUs, I'm afraid. Spec does not define how primitives should be drawn, so everyone do it whatever way that is fastest for their setup. So rectangles and lines can be at +-1 pixel from where you asked to draw them. Drawing a stretched textured rectangle (e.g. draw_sprite_stretched) will not have this flaw, as with that it was more apparent that either you do it one way, or it won't look right.