Module ggez::graphics [] [src]

The graphics module performs the actual drawing of images, text, and other objects with the Drawable trait. It also handles basic loading of images and text.

This module also manages graphics state, coordinate systems, etc. The default coordinate system has the origin in the upper-left corner of the screen.

Modules

pipe

Structs

Color

A RGBA color.

DrawParam

A struct containing all the necessary info for drawing a Drawable.

Globals

Internal structure containing global shader state.

GraphicsContextGeneric

A structure that contains graphics state. For instance, background and foreground colors, window info, DPI, rendering pipeline state, etc.

ImageGeneric

Generic in-GPU-memory image data available to be drawn on the screen.

Mesh

2D polygon mesh

Point

A simple 2D point.

Rect

A simple 2D rectangle.

RectProperties

Internal structure containing values that are different for each rect.

Text

Drawable text created from a Font.

Vertex

Internal structure containing vertex data.

WindowMode

A builder structure containing flags for defining window settings.

Enums

DrawMode

Specifies whether a shape should be drawn filled or as an outline.

FilterMode

Specifies what blending method to use when scaling up/down images.

Font

A font that defines the shape of characters drawn on the screen. Can be created from a .ttf file or from an image (bitmap fonts).

Constants

BLACK
WHITE

Traits

Drawable

All types that can be drawn on the screen implement the Drawable trait.

Functions

circle

Draw a circle.

clear

Clear the screen to the background color.

draw

Draws the given Drawable object to the screen by calling its draw() method.

draw_ex

Draws the given Drawable object to the screen by calling its draw_ex() method.

ellipse

Draw an ellipse.

get_background_color

Returns the current background color.

get_color

Returns the current foreground color.

get_default_filter

Get the default filter mode for new images.

get_display_count

Returns the number of connected displays.

get_fullscreen_modes

Returns a Vec of (width, height) tuples describing what fullscreen resolutions are available for the given display.

get_line_width

Get the current width for drawing lines and stroked polygons.

get_point_size

Get the current size for drawing points.

get_renderer_info

Returns a string that tells a little about the obtained rendering mode. It is supposed to be human-readable and will change; do not try to parse information out of it!

get_screen_coordinates

Returns a rectangle defining the coordinate system of the screen. It will be Rect { x: left, y: bottom, w: width, h: height }

line

Draws a line of one or more connected segments.

points

Draws points.

polygon

Draws a closed polygon

present

Tells the graphics system to actually put everything on the screen. Call this at the end of your EventHandler's draw() method.

rectangle

Draws a rectangle.

set_background_color

Sets the background color. Default: blue.

set_color

Sets the foreground color, which will be used for drawing rectangles, lines, etc. Default: white.

set_default_filter

Sets the default filter mode used to scale images.

set_line_width

Set the current width for drawing lines and stroked polygons.

set_mode

Sets the window mode, such as the size and other properties.

set_point_size

Set the current size for drawing points.

set_screen_coordinates

Sets the bounds of the screen viewport.

Type Definitions

FullscreenType
GraphicsContext

A concrete graphics context for GL rendering.

Image

In-GPU-memory image data available to be drawn on the screen, using the OpenGL backend.

WrapMode

Specifies how to wrap textures.