GradientLine

From Spheriki

Jump to: navigation, search

GradientLine draws a line on the screen that changes smootly between two colors.

Contents

Usage

GradientLine(x1, y1, x2, y2, color1, color2);
  • x1 The x coordinate to start at, in pixels.
  • y1 The y coordinate to start at, in pixels.
  • x2 The x coordinate to end at, in pixels.
  • y2 The y coordinate to end at, in pixels.
  • color1 The Sphere Color object for the starting point of the line.
  • color2 The Sphere Color object for the ending point of the line.

Examples

var white = CreateColor(255, 255, 255);
var black = CreateColor(0, 0, 0);
GradientLine(0, 0, 320, 240, white, black);

If the resolution is set to 320x240, will draw a white line that fades out to black from the top left to the bottom right of the screen.

var white = CreateColor(255, 255, 255);
var black = CreateColor(0, 0, 0);
GradientLine(0, 0, GetScreenWidth(), GetScreenHeight(), white, black);

Same as the one above, except it takes the screen width and screen height as ending points. This will draw a diagonal line changing from white to black, from the top-left of the screen to the bottom-right, at any resolution.

GradientLine(20, 14, 50, 75, CreateColor(0, 0, 255), CreateColor(255,0,0));

Draws a line from coordinates (20, 14) to (15, 75), which changes from blue to red.

Note

GradientLine, as with all drawing functions, draws to the video buffer and not the screen directly. To see what's been drawn, you must use the FlipScreen() function. For example:

var white = CreateColor(255, 255, 255);
var black = CreateColor(0, 0, 0);

GradientLine(0,0,320,240, white, black);
FlipScreen();
GetKey();

See also

Personal tools