Draws a rectangle.


GML Code Example

draw_rectangle(x1, y1, x2, y2, outline);

Argument Description
x1 The x coordinate of the top left corner of the rectangle.
y1 The y coordinate of the top left corner of the rectangle.
x2 The x coordinate of the bottom right corner of the rectangle.
y2 The y coordinate of the bottom right corner of the rectangle.
outline Whether the rectangle is drawn filled (false) or as a one pixel wide outline (true).

Returns: N/A


With this function you can draw either an outline of a rectangle or a filled rectangle where the (x1,y1) position is the top left corner and the (x2,y2) position is the bottom right corner.


GML Code Example

 draw_rectangle(100, 100, 300, 200, true);

This will draw a rectangle outline, with its top left corner at (100,100) and its bottom right corner at (300,200).

These examples are submitted by the community. Upvote the examples you think are most helpful.

Random Filled Rectangles and With Edges by /u/tmcicuurd12b42 on January 20, 2017

GML Code

///draw event

for(var i = 0; i<100; i++)
    //get random position for from and to coords
    var x1 = random(room_width);
    var y1 = random(room_height);
    var x2 = random(room_width);
    var y2 = random(room_height);
    //set white (c_white)
    //draw filled
    draw_rectangle(x1, y1, x2, y2, false);
    //set black (c_black)
    //draw border
    draw_rectangle(x1, y1, x2, y2, true);
See It In Action:

No Edits Suggested

Is this page unclear or not descriptive enough? Suggest an edit to the page and with enough upvotes your changes will be made.

No Questions Have Been Ask

Do you have a question about this page? Ask it Here