Circles.js (system script)
From Spheriki
Use the system script circles.js by Eric Duvic to draw circles.
Contents |
[edit]
Usage
RequireSystemScript("circles.js");
[edit]
Variables and functions of circles.js
- LineCircle(radius, color)
- Circle(radius, color)
- same as
LineCircle(), except the circle is filled with the given 'color'.
- same as
- GradientCircle(radius, color1, color2)
- same as
Circle()but 'color1' and 'color2' smoothly change between center and periphery of the circle.
- same as
[edit]
Examples
First, the example stores the image returned by the function LineCircle() in a variable. The image is drawn onto the screen afterwards.
RequireSystemScript("circles.js"); var myCircle = LineCircle(100, CreateColor(255,0,0)); myCircle.blit(0,0); FlipScreen();
If you think you don't need to use a variable, merge the 2nd and 3rd line to:
LineCircle(100, CreateColor(255, 0, 0)).blit(0,0);
[edit]
Notes
-
LineCircle(),Circle()andGradientCircle()don't draw anything to the screen buffer. You have to blit the image object they return and call FlipScreen() afterwards to see something. The image returned can be stored in a variable for later re-use to save processing time since drawing of circles is usually time consuming (see the examples). The image will have a height and width of twice the given radius. - The Sphere directory
docs/system_scripts/contains a small doc (circles.txt). - Drawing functions for other graphics primitives can be found in the Sphere API and in graphics.js (system script).
[edit]
Known bugs
- During tests the circle images drawn by
Circle()andGradientCircle()appeared to have their rightmost pixel column and their bottommost pixel line missing. It made the circle appear not exactly circular, especially when drawing circles with small radius. See the Spherical Pastebin for a fixed version.

