Module Rubygame::Draw
In: ext/rubygame/rubygame_transform.c

The Draw module provides an interface to SDL_gfx‘s methods for drawing geometric primitives and other colored shapes onto Surfaces. Some methods require a specific version of SDL_gfx, most notably filled_pie

The base methods (e.g. circle), draw the outline of the shape, without any color inside of it.

Most shapes also have an anti-aliased version (e.g. aacircle), which draws smooth outlines with no "jaggies" or "stairsteps". Please note that anti-aliased shapes take considerably longer to draw than aliased shapes.

Most shapes also have a filled version (e.g. filled_circle), which draws a solid shape filled with color.

At this time, there are no methods to draw shapes which are both filled and anti-aliased. For some shapes, it may be possible to approximate this effect by drawing a filled shape, then an anti-aliased outline in the same position.

Methods

Public Class methods

As circle, but the outline is anti-aliased.

As ellipse, but the ellipse border is anti-aliased.

As line, but the line will be anti-aliased.

As polygon, but the lines are anti-aliased.

Draw a non-filled box (rectangle) on a surface, given the coordinates of its top-left corner and bottom-right corner. See also filled_box.

This method takes these arguments:

surface:the target surface to draw on.
point1:the coordinates of top-left corner, in the form [x,y].
point2:the coordinates of bottom-right corner, in the form [x,y].
color:the color of the shape, in the form [r,g,b,a]. If alpha is omitted, it is drawn at full opacity.

Draw an empty circle on a surface, given the coordinates of its center and its radius. See also aacircle and filled_circle.

This method takes these arguments:

surface:the target surface to draw on.
center:the coordinates of circle‘s center, in the form [x,y].
radius:the radius (pixels) of the circle.
color:the color of the shape, in the form [r,g,b,a]. If alpha is omitted, it is drawn at full opacity.

Draw an empty ellipse (i.e. an oval) on a surface, given the coordinates of its center and its horizontal and vertical radii. See also aaellipse and filled_ellipse.

This method takes these arguments:

surface:the target surface to draw on.
center:the coordinates of ellipse‘s center, in the form [x,y].
radii:the x and y radii (pixels), in the form [xr,yr].
color:the color of the shape, in the form [r,g,b,a]. If alpha is omitted, it is drawn at full opacity.

As box, but the shape is solid, not an outline. (You may find using Surface#fill to be more convenient, and perhaps faster than this method.)

As circle, but the shape is solid, not an outline.

As ellipse, but the shape is solid, not an outline.

As pie, but the shape is solid, not an outline. (This method does not require SDL_gfx 2.0.11 as pie does.)

As polygon, but the shape is solid, not an outline.

Draw a line segment between two points on a surface. See also aaline.

This method takes these arguments:

surface:the target surface to draw on.
point1:the coordinates of one end of the line, in the form [x,y].
point2:the coordinates of the other end of the line, as above.
color:the color of the shape, in the form [r,g,b,a]. If alpha is omitted, it is drawn at full opacity.

Draw a non-filled pie shape (i.e. an arc), given the coordinates of its center and its radius, and its starting and ending angles. The shape is that of a circle with a "slice" removed, as if it were a pie. (Think P*cm*n.) See also filled_pie.

This function can only be used if Rubygame was compiled with at least version 2.0.11 of SDL_gfx. Otherwise, it will issue a warning and return nil. (filled_pie does not require version 2.0.11).

This method takes these arguments:

surface:the target surface to draw on.
center:the coordinates of circle‘s center, in the form [x,y].
radius:the radius (pixels) of the circle.
angles:the start and end angles (in degrees) of the arc, in the form [start,end]. Angles are given CLOCKWISE from the positive x (remember that the positive Y direction is down, rather than up).
color:the color of the shape, in the form [r,g,b,a]. If alpha is omitted, it is drawn at full opacity.

Draw an empty polygon, given the coordinates of its vertices, in the order that they are connected. This is essentially a series of connected dots.

This method takes these arguments:

surface:the target surface to draw on.
points:an Array containing the coordinate pairs for each vertex of the polygon, in the order that they are connected, e.g. [ [x1,y1], [x2,y2], …, [xn,yn] ]. To draw a closed shape, the final coordinate pair should match the first.
color:the color of the shape, in the form [r,g,b,a]. If alpha is omitted, it is drawn at full opacity.

Returns true if the feature(s) associated with this module/class are available for use. This means that Rubygame was compiled and linked against the C library which provides the feature, i.e. SDL_gfx, SDL_image, or SDL_ttf.

If the features are not available (for example, if the libraries were not installed or detected when Rubygame was compiled), returns false.

Return the major, minor, and patch numbers for the version of SDL_gfx that Rubygame was compiled with. If Rubygame was not compiled with SDL_gfx, all version numbers will be 0 (zero), and you should not attempt to use the Draw module.

This allows for more flexible detection of the capabilities of the Draw module‘s base library, SDL_gfx. See also usable?.

[Validate]