draw_roundrect_colour_ext

Draws a rectangle with rounded corners of the given radius, colouring it with a gradient of two colours.

Syntax:

draw_roundrect_colour_ext(x1, y1, x2, y2, xrad, yrad, col1, col2, outline);


Argument Description
x1 The x coordinate of the left of the rounded rectangle.
y1 The y coordinate of the top of the rounded rectangle.
x2 The x coordinate of the right of the rounded rectangle.
y2 The y coordinate of the bottom of the rounded rectangle.
xrad The radius of the curve along the x axis from the rectangle corners.
yrad The radius of the curve along the y axis from the rectangle corners.
col1 The center colour.
col2 The outside edge colour.
outline Whether the rectangle is an outline (true) or filled in (false).


Returns: N/A


Description

With this function you can draw either an outline of a rounded rectangle or a filled rounded rectangle where the (x1,y1) position is the top left corner and the (x2,y2) position is the bottom right corner. If the rectangle is filled, then the colour arguments will be used to generate a colour gradient from the centre to the edges, where colour 1 is the centre colour and colour 2 the edge colour. You must also supply radius values for the x and y axis (in pixels) and the corners will be rounded by these amounts. You can define how precise the drawing of the corners is with the function draw_set_circle_precision.


Example:

var dist = point_distance(x, y, mouse_x, mouse_y) / 10;
var col = make_colour_hsv(clamp(dist, 0, 255), 255, 255);
draw_roundrect_colour_ext(x - 50, y - 50, x + 50, y + 50, dist, dist, col, c_white, 0);

This would draw a filled-in square with rounded corners, the radius of which is defined by the distance from the instance doing the drawing to the mouse. This value is also used to calculate the centre blend colour.


Back: Drawing Basic Forms
Next: draw_triangle
© Copyright YoYo Games Ltd. 2018 All Rights Reserved