Gosu::Image
Constructors
Loads an image from a file or an Gosu::ImageBlob image.
NOTE: For Windows Bitmap (BMP) images, magenta (FF00FF, often called "magic pink" in this context) is treated as a chroma key and all pixels of that color are automatically rendered fully transparent.
source the filename or RMagick image to load from.
retro if true, the image will not be interpolated when it is scaled up or down. When :retro it set, :tileable has no effect.
tileable if true, the Image will not have soft edges when scaled
See: #load_tiles
See: #from_text
NOTE: https://github.com/gosu/gosu/wiki/Basic-Concepts#tileability Tileability explained in the Gosu Wiki
Class methods
Creates a new image with the given dimensions and RGBA pixel data.
width Width of the image in pixels.
height Height of the image in pixels.
rgba A string containing raw binary image data, with one byte ('uint8') per RGBA component.
Like #from_text, but supports the following markup tags: bold, italic, and <c=rrggbb>colors</c>.
Creates a reusable image from one or more lines of text.
NOTE: The text is always rendered in white. To draw it in a different color, use the color parameter of {#draw}, et al.
line_height the line height, in pixels.
font the name of a system font, or a path to a TrueType Font (TTF) file. A path must contain at least one '/' character to distinguish it from a system font.
width the width of the image, in pixels. Long lines will be automatically wrapped around to avoid overflow, but overlong words will be truncated. If this option is omitted, lines will not be wrapped, and :align and :spacing will be ignored as well.
spacing the spacing between lines, in pixels.
:align the text alignment, [left, :right, :center, :justify].
retro if true, the image will not be interpolated when it is scaled up or down.
SEE: Gosu::Font
NOTE: https://github.com/gosu/gosu/wiki/Basic-Concepts#drawing-with-colours Drawing with colors, explained in the Gosu Wiki
Loads an image from a file or an RMagick image, then divides the image into an array of equal-sized tiles.
NOTE: For Windows Bitmap (BMP) images, magenta (FF00FF, often called "magic pink" in this context) is treated as a chroma key and all pixels of that color are automatically rendered fully transparent.
tile_width If positive, this is the width of the individual tiles; if negative, the image is divided into -tile_width columns.
tile_height If positive, this is the height of the individual tiles; if negative, the image is divided into -tile_height rows.
retro if true, the image will not be interpolated when it is scaled up or down. When :retro it set, :tileable has no effect.
tileable if true, the Image will not have soft edges when scaled
NOTE: https://github.com/gosu/gosu/wiki/Basic-Concepts#tileability Tileability explained in the Gosu Wiki
Instance methods
Draws the image with its top left corner at (x, y).
x the X coordinate.
y the Y coordinate.
z the Z-order.
scale_x the horizontal scaling factor.
scale_y the vertical scaling factor.
color a Gosu::Color or UInt32
mode [:default, :additive] the blending mode to use.
See draw_rot
See draw_as_quad
NOTE: https://github.com/gosu/gosu/wiki/Basic-Concepts#drawing-with-colours Drawing with colors, explained in the Gosu Wiki
NOTE: https://github.com/gosu/gosu/wiki/Basic-Concepts#z-ordering Z-ordering explained in the Gosu Wiki
Draws the image as an arbitrary quad. This method can be used for advanced non-rectangular drawing techniques, e.g., faking perspective or isometric projection.
See #draw
See Gosu.draw_quad
NOTE: https://github.com/gosu/gosu/wiki/Basic-Concepts#drawing-with-colours Drawing with colors, explained in the Gosu Wiki
NOTE: https://github.com/gosu/gosu/wiki/Basic-Concepts#order-of-corners The order of corners explained in the Gosu Wiki
NOTE: https://github.com/gosu/gosu/wiki/Basic-Concepts#z-ordering Z-ordering explained in the Gosu Wiki
Draws the image rotated, with its rotational center at (x, y).
center_x the relative horizontal rotation origin.
center_y the relative vertical rotation origin.
See #draw
NOTE: https://github.com/gosu/gosu/wiki/Basic-Concepts#drawing-with-colours Drawing with colors, explained in the Gosu Wiki
NOTE: https://github.com/gosu/gosu/wiki/Basic-Concepts#z-ordering Z-ordering explained in the Gosu Wiki
Returns an object that holds information about the underlying OpenGL texture and UV coordinates of the image.
NOTE: Some images may be too large to fit on a single texture; this method returns nil in those cases.
See Gosu::GLTexInfo
Overwrites part of the image with the contents of another. If the source image is partially out of bounds, it will be clipped to fit.
This can be used to e.g. overwrite parts of a landscape.
source the filename, Gosu::Image, or Gosu::ImageBlob image to load from.
x the X coordinate of the top left corner.
y the Y coordinate of the top left corner.
Saves the image to a file. The file format is determined from the file extension.
Useful for, e.g., pre-rendering text on a development machine where the necessary fonts are known to be available.
filename the path to save the file under.
Returns an image that is a smaller, rectangular view of this Gosu::Image.
This is a very fast operation, and no new textures will be allocated.
If you update this Gosu::Image or the #subimage using #insert, the other Gosu::Image will be affected as well.
Caveats:
- If you stretch or rotate a
#subimage, the pixels adjacent to it might bleed into it, as Gosu does not manage the 'tileability' of subimages.