Discuss and collaborate on GML scripts

You are not logged in.

#1 2009-06-18 11:25:53

Registered: 2007-10-17
Posts: 110

Strange behaviour of draw_rectangle (GM7)

Well it's a pretty well known fact that GM7 draws slightly differently from gm6.

In my "game" (map editor actually) I wanted to make some menu/scrollbars (which require pixel perfect graphics), and I discovered rectangles seem to behave oddly. I'm not entirely sure what causes this, and what the exact effects are (that's why I'm posting this), but the basics I have discovered are as the following:

consider the function: draw_rectangle(x1,y1,x2,y2,outline):
If outline set to false (filling) it will draw a rectangle "INCLUDING" x1 and y1 (left and top lines). Yet "EXCLUDING" x2,y2 (right and bottom lines).
If outline set to true (outline) it will draw a rectangle "INCLUDING" x1 and y1 (left and top lines). And "INCLUDING" x2,y2 (right and bottom lines).

Strange.. (especially since filling includes the left/top).

However what's even more wierd is the thing that happens when you use transformations (rotations around the Z-axis): it stays to be the "right and bottom" lines that aren't displayed. So if you would turn it over 180 degrees, what used to be the original "top and left" lines aren't "displayed" now.. (I'm a bit doubtfull, as to wether they are not DISPLAYED, or that they are simply moved 1 pixel, and the bottom/right lines aren't displayed)..

When turning under a non-90-multiple number of degrees the problem is still there, however it's much more difficult to describe, and I'm not sure what lines are actually removed.

There still needs to be done some research to wether or not this happens also for other shapes & polygons.
An example:
example file - Press "control" to turn the image. (the semi-transparant black-blocks with "spr" in them are actual sprites, so they can be used to see how it display SHOULD be).


Board footer

Powered by FluxBB