Simple Game Graphics Library
1.0
|
#include <graphics.h>
Data Fields | |
float | fill_color [3] = {1.f,1.f,1.f} |
float | fill_secondary_color [3] = { 1.f,1.f,1.f } |
float | fill_opacity = 1.0f |
float | fill_secondary_opacity = 1.f |
float | outline_color [3] = { 1.f,1.f,1.f } |
float | outline_opacity = 1.f |
float | outline_width = 1.0f |
std::string | texture = "" |
bool | gradient = false |
float | gradient_dir_u = 0.0f |
float | gradient_dir_v = 1.0f |
Encapsulates the superset of drawing attributes for all supported primitives and draw calls. These include the primary fill color, the use of gradient fill or not, the secondary fill color and fill direction used by the gradient, a texture image to be blended with the underlying color, the outline color and width and the opacity for the fill and outline colors. The use of these attributes is demonstrated in the example image below:
float graphics::Brush::fill_color[3] = {1.f,1.f,1.f} |
The primary fill color for shapes.
float graphics::Brush::fill_opacity = 1.0f |
The opacity (1-transparency) of the primary fill color. A (maximum) value of 1.0f means "fully opaque", while a value of 0.0f means fully transparent (invisible).
float graphics::Brush::fill_secondary_color[3] = { 1.f,1.f,1.f } |
The fill color used as a secondary one when using a color gradient.
float graphics::Brush::fill_secondary_opacity = 1.f |
The opacity of the second fill color, used for the gradient.
bool graphics::Brush::gradient = false |
Enables or disables the gradient fill of a shape.
float graphics::Brush::gradient_dir_u = 0.0f |
The gradient by default uses the v dimension of the parametric shape. In practice though, the calculation is as follows: s = u*gradient_dir_u + v*gradient_dir_v, where s is the color mixing parameter, clamped to [0.0,1.0]. This means that we can change the linear parameters gradient_dir_u/v to bias the between the two parametric space axes. For example:
float graphics::Brush::gradient_dir_v = 1.0f |
float graphics::Brush::outline_color[3] = { 1.f,1.f,1.f } |
The color of the shape outline (where applicable). Most drawn shapes, like disks, line segments and rectangles use this property to set the outline stroke color.
float graphics::Brush::outline_opacity = 1.f |
The opacity of the outline. Maximum value is 1.0f (fully opaque), and the minimum value is 0.0f (fully transparent).
float graphics::Brush::outline_width = 1.0f |
The stroke width in pixel units. Can accept fractional values.
std::string graphics::Brush::texture = "" |
The filename of a bitmap to project over and blend with the underlying color of the fill. The image is multiplicatively combined with the entire fill motif, respecting also the opacity. Currently, only PNG images are supported, with transparency. Images of arbitrary size are supported but are internally upscaled to the nearest power of two in each dimension, using linear interpolation. The bitmap, regardless of its aspect ratio, covers the entire shape end to end, according to its own parameterization. This means that a square image drawn on a non-square rectangle will stretch the image. To avoid this, the drawn rectangle should follow the aspect ratio of the image. By default, no image is used. When an image filename is provided, it is loaded once and internally cached for repeated use.
Keep in mind that when using a bitmap on a drawable shape, the image parametric space (expressed as u,v coordinates in the image below) is mapped to corresponding parameters of the underlying shape. For example, for the disk shape, the horizontal axis of the image is mapped to the circumferance of the disk, while the height is mapped to the disk radius.