GradientTriangle

From Spheriki

Jump to: navigation, search

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

Contents

Usage

GradientTriangle(x1, y1, x2, y2, x3, y3, color1, color2, color3);
  • x1 The x coordinate of the first vertex, in pixels.
  • y1 The y coordinate of the first vertex, in pixels.
  • x2 The x coordinate of the second vertex, in pixels.
  • y2 The y coordinate of the second vertex, in pixels.
  • x2 The x coordinate of the third vertex, in pixels.
  • y2 The y coordinate of the third vertex, in pixels.
  • color1 The Sphere Color object for the first vertex.
  • color2 The Sphere Color object for the second vertex.
  • color3 The Sphere Color object for the third vertex.

Examples

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

Draws a white colored right angle triangle at the top left hand corner of the screen which fades to black at the last two vertices.

var white = CreateColor(255, 255, 255);
var noalpha = CreateColor(255, 255, 255, 0);
GradientTriangle(0, 0, 100, 0, 0, 100, white, noalpha, noalpha);

Draws a white colored right angle triangle at the top left hand corner of the screen which fades out at the last two vertices. If anything is drawn before this command, the white trangle will have partial transparency, smoothly going from the solid white point to the completely transparent end points.


Line(30, 30, 15, 60, 45,60, CreateColor(0, 0, 255), CreateColor(0, 255, 0), CreateColor(255, 0, 0));

Draws an isosceles triangle with vertices at (30, 30), (15, 60), and (45, 60), with vertices going having blue, green, and red colors, and smooth colors inbetween.

Notes

As with all graphical functions, remember to use FlipScreen() to display the results on the screen when you're finished drawing.

See also

Personal tools