Rectangle
From Spheriki
Draws a colored rectangle on the video buffer, using the given position and dimensions.
Contents |
[edit]
Usage
Rectangle(x, y, width, height, color);
- x Number. The x coordinate (left-right position) of the top-left corner of the rectangle.
- y Number. The y coordinate (up-down position) of the top-left corner of the rectangle.
- width Number, non-negative. The width of the rectangle in pixels.
- height Number, non-negative. The height of the rectangle in pixels.
- color A Sphere Color object, holding the color of the rectangle to be drawn.
[edit]
Examples
var blue = CreateColor(0, 0, 255); Rectangle(40, 20, 100, 150, blue); FlipScreen(); GetKey();
The above example draws a pure blue rectangle at screen coordinates (40, 20), with a width of 100 pixels and a height of 150 pixels. Sphere will then wait for a key press.
// Draw some stuff here // ... Rectangle(50, 50, 100, 100, CreateColor(255, 255, 255, 128)); FlipScreen();
The above example will draw a translucent white square on the screen.
[edit]
Notes
- Like all primitive drawing functions, it is necessary to call FlipScreen() to see the results of a Rectangle() call.
- If the
colorparameter (a Sphere Color object) has an alpha less than 255, the rectangle drawn will be blended with the current contents of the screen.
- This function is unrelated to the Rectangle object that is returned by a call to GetClippingRectangle().
- The equivalent function to draw a rectangle on a Sphere Surface object is Surface.rectangle(), which can optionally replace pixels with a color less than 255 alpha, rather than blend.
[edit]
See also
- Sphere Color object
- Surface.rectangle()
- CreateColor()
- FlipScreen()
- GetKey()

