Surface.outlinedRectangle

From Spheriki

Jump to: navigation, search

Draws an outlined rectangle with size determining the thickness onto the surface.

Usage

surface.outlinedRectangle(x, y, width, height, color, [size]);
  • surface Sphere Surface object. The surface to draw the rectangle on.
  • x, y numbers. Coordinates of the top-left corner of the rectangle.
  • width, height numbers. Indicates the size of the rectangle (ex. 50 by 50 pixels).
  • color a Sphere Color object. Indicates what color the outline should be.
  • size a number, optional. Indicates how thick the outline should be. The default is 1 pixel.

Examples

Draw a blue rectangle into the surface ranging from coordinates (10, 10) to (100, 50).

var blue = CreateColor(0,0,255);
var s = CreateSurface(320, 240, CreateColor(0,0,0));

s.outlinedRectangle(10, 10, 90, 40, blue);  //Width and height are 90 and 40 because 10+90=100 and 10+40=50.

Draw a transparent blue rectangle onto the surface and outline it with a white, 2 pixel border.

var blue = CreateColor(0,0,255,128);  //Half transparent blue.
var white = CreateColor(255,255,255);
var s = CreateSurface(320, 240, CreateColor(0,0,0,0));  //See-through surface, useful for blitting transparent stuff over your graphics.

s.rectangle(10, 10, 90, 40, blue);
s.outlinedRectangle(10, 10, 90, 40, white, 2);  //Everything inside the outlined rectangle stays what it was before, meaning blue.


See also



Personal tools