GradientRectangle

From Spheriki

Jump to: navigation, search

Draws a filled rectangle on the screen that smoothly changes colors between the vertices.

Contents

Usage

GradientRectangle(x, y, width, height, color_ul, color_ur, color_br, color_bl);
  • x Number. The x coordinate of the top-left corner of the rectangle.
  • y Number. The y coordinate of the top-left corner of the rectangle.
  • width Number, non-negative. The width of the drawn rectangle.
  • height Number, non-negative. The height of the drawn rectangle.
  • color_ul Sphere Color object. Color of the upper-left corner.
  • color_ur Sphere Color object. Color of the upper-right corner.
  • color_br Sphere Color object. Color of the bottom right corner.
  • color_bl Sphere Color object. Color of the bottom left corner.

Examples

var red = CreateColor(255, 0, 0);
var green = CreateColor(0, 255, 0);
var blue = CreateColor(0, 0, 255);
var yellow = CreateColor(255, 255, 0);

GradientRectangle(10, 10, 300, 220, red, green, blue, yellow);
FlipScreen();
GetKey();

This example prepares some basic colors, and then displays a multi-colored rectangle using them. Sphere then waits for a key press. Note the order in which the colors are used, and where they appear.

Notes

  • Like all functions that draw to the screen, you will need to call FlipScreen() to see the results.
  • If all four corners are the same color, it is better to use the Rectangle() function instead of this.

See also

Personal tools