2D Graphics Canvas More...

#include <canvas.h>

Public Member Functions

 Canvas ()
 Constructs a null instance. More...
 
 Canvas (Canvas &canvas, FrameBuffer &framebuffer)
 Constructs a Canvas based on a framebuffer. (based on the copy of the canvas) More...
 
 Canvas (DisplayWindow &window)
 Constructs a Canvas. More...
 
 ~Canvas ()
 
void clear (const Colorf &color=StandardColorf::black())
 Clears the whole context using the specified color. More...
 
void clear_depth (float value=0)
 Clear the depth buffer. More...
 
void clear_stencil (int value=0)
 Clear the stencil buffer. More...
 
Canvas create ()
 Create a copy of a canvas. More...
 
void draw_box (float x1, float y1, float x2, float y2, const Colorf &color=StandardColorf::white())
 Draw a box / rectangle. More...
 
void draw_box (const Pointf &start, const Pointf &end, const Colorf &color=StandardColorf::white())
 Box. More...
 
void draw_box (const Rectf &rect, const Colorf &color)
 Box. More...
 
void draw_line (float x1, float y1, float x2, float y2, const Colorf &color=StandardColorf::white())
 Draw a line. More...
 
void draw_line (const Pointf &start, const Pointf &end, const Colorf &color=StandardColorf::white())
 Line. More...
 
void draw_line (const LineSegment2f &line_segment, const Colorf &color=StandardColorf::white())
 Line. More...
 
void draw_line_strip (const Vec2f *positions, int num_vertices, const Colorf &color=StandardColorf::white())
 Line Strip. More...
 
void draw_lines (const Vec2f *positions, int num_vertices, const Colorf &color=StandardColorf::white())
 Lines. More...
 
void draw_lines (const Vec2f *line_positions, const Vec2f *texture_positions, int num_vertices, const Texture2D &texture, const Colorf &line_color=StandardColorf::white())
 Lines. More...
 
void draw_point (float x1, float y1, const Colorf &color)
 Draw a point. More...
 
void draw_point (const Pointf &point, const Colorf &color)
 Point. More...
 
void fill_circle (float center_x, float center_y, float radius, const Colorf &color=StandardColorf::white())
 Draw a circle. More...
 
void fill_circle (const Pointf &center, float radius, const Colorf &color=StandardColorf::white())
 Circle. More...
 
void fill_circle (const Pointf &center, float radius, const Gradient &gradient)
 Gradient circle. More...
 
void fill_circle (const Pointf &center, const Pointf &centergradient, float radius, const Gradient &gradient)
 Gradient circle. More...
 
void fill_ellipse (const Pointf &center, float radius_x, float radius_y, const Colorf &color=StandardColorf::white())
 Draw a filled ellipse. More...
 
void fill_ellipse (const Pointf &center, float radius_x, float radius_y, const Gradient &gradient)
 Draw a gradient filled ellipse. More...
 
void fill_rect (float x1, float y1, float x2, float y2, const Colorf &color=StandardColorf::white())
 Draw a filled box / rectangle. More...
 
void fill_rect (const Pointf &start, const Pointf &end, const Colorf &color=StandardColorf::white())
 Fill. More...
 
void fill_rect (const Rectf &rect, const Colorf &color)
 Fill. More...
 
void fill_rect (float x1, float y1, float x2, float y2, const Gradient &color)
 Gradient fill. More...
 
void fill_rect (const Pointf &start, const Pointf &end, const Gradient &gradient)
 Gradient fill. More...
 
void fill_rect (const Rectf &rect, const Gradient &gradient)
 Gradient fill. More...
 
void fill_triangle (const Pointf &a, const Pointf &b, const Pointf &c, const Colorf &color=StandardColorf::white())
 Draw a triangle. More...
 
void fill_triangle (const Trianglef &dest_triangle, const Colorf &color=StandardColorf::white())
 Draw a triangle. More...
 
void fill_triangles (const Vec2f *triangle_positions, int num_vertices, const Colorf &color=StandardColorf::white())
 Draw triangles. More...
 
void fill_triangles (const Vec2f *triangle_positions, int num_vertices, const Gradient &gradient)
 Draw triangles. More...
 
void fill_triangles (const Vec2f *triangle_positions, const Colorf *colors, int num_vertices)
 Draw triangles. More...
 
void fill_triangles (const std::vector< Vec2f > &triangles, const Colorf *colors)
 Draw triangles. More...
 
void fill_triangles (const std::vector< Vec2f > &triangles, const Colorf &color=StandardColorf::white())
 Draw triangles. More...
 
void fill_triangles (const std::vector< Vec2f > &triangles, const Gradient &gradient)
 Draw triangles. More...
 
void fill_triangles (const Vec2f *positions, const Vec2f *texture_positions, int num_vertices, const Texture2D &texture, const Colorf &color=StandardColorf::white())
 Draw triangles. More...
 
void fill_triangles (const Vec2f *positions, const Vec2f *texture_positions, int num_vertices, const Texture2D &texture, const Colorf *colors)
 Draw triangles. More...
 
void fill_triangles (const std::vector< Vec2f > &positions, const std::vector< Vec2f > &texture_positions, const Texture2D &texture, const Colorf &color=StandardColorf::white())
 Draw triangles. More...
 
void fill_triangles (const std::vector< Vec2f > &positions, const std::vector< Vec2f > &texture_positions, const Texture2D &texture, const std::vector< Colorf > &colors)
 Draw triangles. More...
 
void fill_triangles (const std::vector< Vec2f > &positions, const Texture2D &texture, const Colorf &color=StandardColorf::white())
 Draw triangles. More...
 
void fill_triangles (const std::vector< Vec2f > &positions, const Texture2D &texture, const Rect &texture_rect, const Colorf &color=StandardColorf::white())
 Draw triangles. More...
 
void fill_triangles (const Vec2f *triangle_positions, int num_vertices, const Texture2D &texture, const Colorf &color=StandardColorf::white())
 Draw triangles. More...
 
void fill_triangles (const Vec2f *triangle_positions, int num_vertices, const Texture2D &texture, const Rect &texture_rect, const Colorf &color=StandardColorf::white())
 Draw triangles. More...
 
void fill_triangles (const std::vector< Vec2f > &positions, const Texture2D &texture, const Gradient &gradient)
 Draw triangles. More...
 
void fill_triangles (const std::vector< Vec2f > &positions, const Texture2D &texture, const Rect &texture_rect, const Gradient &gradient)
 Draw triangles. More...
 
void fill_triangles (const Vec2f *triangle_positions, int num_vertices, const Texture2D &texture, const Gradient &gradient)
 Draw triangles. More...
 
void fill_triangles (const Vec2f *triangle_positions, int num_vertices, const Texture2D &texture, const Rect &texture_rect, const Gradient &gradient)
 Draw triangles. More...
 
void flush ()
 Flushes the render batcher currently active. More...
 
Rectf get_cliprect () const
 Returns the current clipping rectangle. More...
 
GraphicContextget_gc () const
 Get gc. More...
 
float get_height () const
 Returns the current height of the context. More...
 
Mat4fget_inverse_transform ()
 Returns the inverse of the current effective transform matrix. More...
 
float get_pixel_ratio () const
 
PixelBuffer get_pixeldata (const Rect &rect, TextureFormat texture_format=tf_rgba8, bool clamp=true)
 Return the content of the read buffer into a pixel buffer. More...
 
PixelBuffer get_pixeldata (TextureFormat texture_format=tf_rgba8, bool clamp=true)
 Return the content of the read buffer into a pixel buffer. More...
 
const Mat4fget_projection () const
 Returns the current effective projection matrix. More...
 
Sizef get_size () const
 Returns the current size of the context. More...
 
const Mat4fget_transform () const
 Returns the current effective transform matrix. More...
 
float get_width () const
 Returns the current width of the context. More...
 
Pointf grid_fit (const Pointf &pos)
 Snaps the point to the nearest pixel corner. More...
 
bool is_null () const
 Returns true if this object is invalid. More...
 
void mult_transform (const Mat4f &matrix)
 Multiplies the passed matrix onto the transform matrix. More...
 
 operator bool () const
 
 operator GraphicContext & () const
 
void pop_cliprect ()
 Pop current clipping rectangle from the stack. More...
 
void push_cliprect (const Rectf &rect)
 Push current clipping rectangle to stack. More...
 
void push_cliprect ()
 Push cliprect. More...
 
void reset_blend_state ()
 Set active blend state. More...
 
void reset_cliprect ()
 Removes the set clipping rectangle and empties the cliprect stack. More...
 
void reset_depth_stencil_state ()
 Set active depth stencil state. More...
 
void reset_rasterizer_state ()
 Set active rasterizer state. More...
 
void set_batcher (RenderBatcher *batcher)
 Specifies which render batcher is to be currently active. More...
 
void set_blend_state (const BlendState &state, const Colorf &blend_color=StandardColorf::white(), unsigned int sample_mask=0xffffffff)
 Set active blend state. More...
 
void set_cliprect (const Rectf &rect)
 Set the current clipping rectangle. More...
 
void set_depth_stencil_state (const DepthStencilState &state, int stencil_ref=0)
 Set active depth stencil state. More...
 
void set_map_mode (MapMode mode)
 Set the projection mapping mode. More...
 
void set_program_object (StandardProgram standard_program)
 Set active program object to the standard program specified. More...
 
void set_projection (const Mat4f &matrix)
 Set the projection matrix to be used in user projection map mode. More...
 
void set_rasterizer_state (const RasterizerState &state)
 Set active rasterizer state. More...
 
void set_transform (const Mat4f &matrix)
 Sets the transform matrix to a new matrix. More...
 
void set_viewport (const Rectf &viewport)
 
void throw_if_null () const
 Throw an exception if this object is invalid. More...
 

Friends

class Font_DrawFlat
 
class Font_DrawScaled
 
class Font_DrawSubPixel
 
class Font_Impl
 
class Image
 
class Path
 
class Sprite_Impl
 

Detailed Description

2D Graphics Canvas

Constructor & Destructor Documentation

clan::Canvas::Canvas ( )

Constructs a null instance.

clan::Canvas::Canvas ( Canvas canvas,
FrameBuffer framebuffer 
)

Constructs a Canvas based on a framebuffer. (based on the copy of the canvas)

clan::Canvas::Canvas ( DisplayWindow window)
explicit

Constructs a Canvas.

clan::Canvas::~Canvas ( )

Member Function Documentation

void clan::Canvas::clear ( const Colorf color = StandardColorf::black())

Clears the whole context using the specified color.

void clan::Canvas::clear_depth ( float  value = 0)

Clear the depth buffer.

Parameters
valuevalue to clear to. Range 0.0 - 1.0.
void clan::Canvas::clear_stencil ( int  value = 0)

Clear the stencil buffer.

Parameters
valuevalue to clear to.
Canvas clan::Canvas::create ( )

Create a copy of a canvas.

void clan::Canvas::draw_box ( float  x1,
float  y1,
float  x2,
float  y2,
const Colorf color = StandardColorf::white() 
)

Draw a box / rectangle.

void clan::Canvas::draw_box ( const Pointf start,
const Pointf end,
const Colorf color = StandardColorf::white() 
)

Box.

Parameters
gc= Graphic Context
start= Pointf
end= Pointf
color= Colorf
void clan::Canvas::draw_box ( const Rectf rect,
const Colorf color 
)

Box.

Parameters
gc= Graphic Context
rect= Rectf
color= Colorf
void clan::Canvas::draw_line ( float  x1,
float  y1,
float  x2,
float  y2,
const Colorf color = StandardColorf::white() 
)

Draw a line.

void clan::Canvas::draw_line ( const Pointf start,
const Pointf end,
const Colorf color = StandardColorf::white() 
)

Line.

Parameters
gc= Graphic Context
start= Pointf
end= Pointf
color= Colorf
void clan::Canvas::draw_line ( const LineSegment2f line_segment,
const Colorf color = StandardColorf::white() 
)

Line.

Parameters
gc= Graphic Context
line_segment= The line
color= Colorf
void clan::Canvas::draw_line_strip ( const Vec2f positions,
int  num_vertices,
const Colorf color = StandardColorf::white() 
)

Line Strip.

void clan::Canvas::draw_lines ( const Vec2f positions,
int  num_vertices,
const Colorf color = StandardColorf::white() 
)

Lines.

void clan::Canvas::draw_lines ( const Vec2f line_positions,
const Vec2f texture_positions,
int  num_vertices,
const Texture2D texture,
const Colorf line_color = StandardColorf::white() 
)

Lines.

void clan::Canvas::draw_point ( float  x1,
float  y1,
const Colorf color 
)

Draw a point.

void clan::Canvas::draw_point ( const Pointf point,
const Colorf color 
)

Point.

Parameters
gc= Graphic Context
point= Pointf
color= Colorf
void clan::Canvas::fill_circle ( float  center_x,
float  center_y,
float  radius,
const Colorf color = StandardColorf::white() 
)

Draw a circle.

void clan::Canvas::fill_circle ( const Pointf center,
float  radius,
const Colorf color = StandardColorf::white() 
)

Circle.

Parameters
gc= Graphic Context
center= Pointf
radius= value
color= Colorf
void clan::Canvas::fill_circle ( const Pointf center,
float  radius,
const Gradient gradient 
)

Gradient circle.

Parameters
gc= Graphic Context
center= Pointf
radius= value
gradient= Gradient
void clan::Canvas::fill_circle ( const Pointf center,
const Pointf centergradient,
float  radius,
const Gradient gradient 
)

Gradient circle.

Parameters
gc= Graphic Context
center= Pointf
centergradient= Pointf
radius= value
gradient= Gradient
void clan::Canvas::fill_ellipse ( const Pointf center,
float  radius_x,
float  radius_y,
const Colorf color = StandardColorf::white() 
)

Draw a filled ellipse.

void clan::Canvas::fill_ellipse ( const Pointf center,
float  radius_x,
float  radius_y,
const Gradient gradient 
)

Draw a gradient filled ellipse.

void clan::Canvas::fill_rect ( float  x1,
float  y1,
float  x2,
float  y2,
const Colorf color = StandardColorf::white() 
)

Draw a filled box / rectangle.

void clan::Canvas::fill_rect ( const Pointf start,
const Pointf end,
const Colorf color = StandardColorf::white() 
)

Fill.

Parameters
gc= Graphic Context
start= Pointf
end= Pointf
color= Colorf
void clan::Canvas::fill_rect ( const Rectf rect,
const Colorf color 
)

Fill.

Parameters
gc= Graphic Context
rect= Rectf
color= Colorf
void clan::Canvas::fill_rect ( float  x1,
float  y1,
float  x2,
float  y2,
const Gradient color 
)

Gradient fill.

Parameters
gc= Graphic Context
x1= value
y1= value
x2= value
y2= value
color= Gradient
void clan::Canvas::fill_rect ( const Pointf start,
const Pointf end,
const Gradient gradient 
)

Gradient fill.

Parameters
gc= Graphic Context
start= Pointf
end= Pointf
gradient= Gradient
void clan::Canvas::fill_rect ( const Rectf rect,
const Gradient gradient 
)

Gradient fill.

Parameters
gc= Graphic Context
rect= Rectf
gradient= Gradient
void clan::Canvas::fill_triangle ( const Pointf a,
const Pointf b,
const Pointf c,
const Colorf color = StandardColorf::white() 
)

Draw a triangle.

void clan::Canvas::fill_triangle ( const Trianglef dest_triangle,
const Colorf color = StandardColorf::white() 
)

Draw a triangle.

void clan::Canvas::fill_triangles ( const Vec2f triangle_positions,
int  num_vertices,
const Colorf color = StandardColorf::white() 
)

Draw triangles.

void clan::Canvas::fill_triangles ( const Vec2f triangle_positions,
int  num_vertices,
const Gradient gradient 
)

Draw triangles.

void clan::Canvas::fill_triangles ( const Vec2f triangle_positions,
const Colorf colors,
int  num_vertices 
)

Draw triangles.

void clan::Canvas::fill_triangles ( const std::vector< Vec2f > &  triangles,
const Colorf colors 
)

Draw triangles.

void clan::Canvas::fill_triangles ( const std::vector< Vec2f > &  triangles,
const Colorf color = StandardColorf::white() 
)

Draw triangles.

void clan::Canvas::fill_triangles ( const std::vector< Vec2f > &  triangles,
const Gradient gradient 
)

Draw triangles.

void clan::Canvas::fill_triangles ( const Vec2f positions,
const Vec2f texture_positions,
int  num_vertices,
const Texture2D texture,
const Colorf color = StandardColorf::white() 
)

Draw triangles.

void clan::Canvas::fill_triangles ( const Vec2f positions,
const Vec2f texture_positions,
int  num_vertices,
const Texture2D texture,
const Colorf colors 
)

Draw triangles.

void clan::Canvas::fill_triangles ( const std::vector< Vec2f > &  positions,
const std::vector< Vec2f > &  texture_positions,
const Texture2D texture,
const Colorf color = StandardColorf::white() 
)

Draw triangles.

void clan::Canvas::fill_triangles ( const std::vector< Vec2f > &  positions,
const std::vector< Vec2f > &  texture_positions,
const Texture2D texture,
const std::vector< Colorf > &  colors 
)

Draw triangles.

void clan::Canvas::fill_triangles ( const std::vector< Vec2f > &  positions,
const Texture2D texture,
const Colorf color = StandardColorf::white() 
)

Draw triangles.

void clan::Canvas::fill_triangles ( const std::vector< Vec2f > &  positions,
const Texture2D texture,
const Rect texture_rect,
const Colorf color = StandardColorf::white() 
)

Draw triangles.

void clan::Canvas::fill_triangles ( const Vec2f triangle_positions,
int  num_vertices,
const Texture2D texture,
const Colorf color = StandardColorf::white() 
)

Draw triangles.

void clan::Canvas::fill_triangles ( const Vec2f triangle_positions,
int  num_vertices,
const Texture2D texture,
const Rect texture_rect,
const Colorf color = StandardColorf::white() 
)

Draw triangles.

void clan::Canvas::fill_triangles ( const std::vector< Vec2f > &  positions,
const Texture2D texture,
const Gradient gradient 
)

Draw triangles.

void clan::Canvas::fill_triangles ( const std::vector< Vec2f > &  positions,
const Texture2D texture,
const Rect texture_rect,
const Gradient gradient 
)

Draw triangles.

void clan::Canvas::fill_triangles ( const Vec2f triangle_positions,
int  num_vertices,
const Texture2D texture,
const Gradient gradient 
)

Draw triangles.

void clan::Canvas::fill_triangles ( const Vec2f triangle_positions,
int  num_vertices,
const Texture2D texture,
const Rect texture_rect,
const Gradient gradient 
)

Draw triangles.

void clan::Canvas::flush ( )

Flushes the render batcher currently active.

Rectf clan::Canvas::get_cliprect ( ) const

Returns the current clipping rectangle.

GraphicContext& clan::Canvas::get_gc ( ) const

Get gc.

Returns
Graphic Context

Referenced by get_height(), get_pixel_ratio(), get_size(), get_width(), and operator GraphicContext &().

float clan::Canvas::get_height ( ) const
inline

Returns the current height of the context.

References clan::GraphicContext::get_dip_height(), and get_gc().

Mat4f& clan::Canvas::get_inverse_transform ( )

Returns the inverse of the current effective transform matrix.

This is cached

float clan::Canvas::get_pixel_ratio ( ) const
inline

Retrieves the display pixel ratio of the context. Resolution Independence

References get_gc(), and clan::GraphicContext::get_pixel_ratio().

PixelBuffer clan::Canvas::get_pixeldata ( const Rect rect,
TextureFormat  texture_format = tf_rgba8,
bool  clamp = true 
)

Return the content of the read buffer into a pixel buffer.

PixelBuffer clan::Canvas::get_pixeldata ( TextureFormat  texture_format = tf_rgba8,
bool  clamp = true 
)

Return the content of the read buffer into a pixel buffer.

const Mat4f& clan::Canvas::get_projection ( ) const

Returns the current effective projection matrix.

Sizef clan::Canvas::get_size ( ) const
inline

Returns the current size of the context.

References clan::GraphicContext::get_dip_size(), and get_gc().

Referenced by clan::ClipRectState::~ClipRectState().

const Mat4f& clan::Canvas::get_transform ( ) const

Returns the current effective transform matrix.

float clan::Canvas::get_width ( ) const
inline

Returns the current width of the context.

References clan::GraphicContext::get_dip_width(), and get_gc().

Pointf clan::Canvas::grid_fit ( const Pointf pos)

Snaps the point to the nearest pixel corner.

bool clan::Canvas::is_null ( ) const
inline

Returns true if this object is invalid.

void clan::Canvas::mult_transform ( const Mat4f matrix)

Multiplies the passed matrix onto the transform matrix.

clan::Canvas::operator bool ( ) const
inlineexplicit
clan::Canvas::operator GraphicContext & ( ) const
inline

References get_gc().

void clan::Canvas::pop_cliprect ( )

Pop current clipping rectangle from the stack.

Referenced by clan::ClipRectStack::pop_cliprect(), and clan::ClipRectStack::~ClipRectStack().

void clan::Canvas::push_cliprect ( const Rectf rect)

Push current clipping rectangle to stack.

If a rectangle is passed, it afterwards sets clipping rectangle to the union of the current rectangle and the passed rectangle.

Referenced by clan::ClipRectStack::push_cliprect().

void clan::Canvas::push_cliprect ( )

Push cliprect.

void clan::Canvas::reset_blend_state ( )

Set active blend state.

void clan::Canvas::reset_cliprect ( )

Removes the set clipping rectangle and empties the cliprect stack.

Referenced by clan::ClipRectState::~ClipRectState().

void clan::Canvas::reset_depth_stencil_state ( )

Set active depth stencil state.

void clan::Canvas::reset_rasterizer_state ( )

Set active rasterizer state.

void clan::Canvas::set_batcher ( RenderBatcher batcher)

Specifies which render batcher is to be currently active.

If the render batcher is already active, nothing happens. If a different render batcher is currently active, it is flushed before the new batcher is made active.

void clan::Canvas::set_blend_state ( const BlendState state,
const Colorf blend_color = StandardColorf::white(),
unsigned int  sample_mask = 0xffffffff 
)

Set active blend state.

void clan::Canvas::set_cliprect ( const Rectf rect)

Set the current clipping rectangle.

Referenced by clan::ClipRectState::~ClipRectState().

void clan::Canvas::set_depth_stencil_state ( const DepthStencilState state,
int  stencil_ref = 0 
)

Set active depth stencil state.

void clan::Canvas::set_map_mode ( MapMode  mode)

Set the projection mapping mode.

void clan::Canvas::set_program_object ( StandardProgram  standard_program)

Set active program object to the standard program specified.

void clan::Canvas::set_projection ( const Mat4f matrix)

Set the projection matrix to be used in user projection map mode.

void clan::Canvas::set_rasterizer_state ( const RasterizerState state)

Set active rasterizer state.

void clan::Canvas::set_transform ( const Mat4f matrix)

Sets the transform matrix to a new matrix.

Referenced by clan::TransformState::~TransformState().

void clan::Canvas::set_viewport ( const Rectf viewport)

Set the viewport to be used in user projection map mode.

Parameters
viewport= The viewport to set
void clan::Canvas::throw_if_null ( ) const

Throw an exception if this object is invalid.

Friends And Related Function Documentation

friend class Font_DrawFlat
friend
friend class Font_DrawScaled
friend
friend class Font_DrawSubPixel
friend
friend class Font_Impl
friend
friend class Image
friend
friend class Path
friend
friend class Sprite_Impl
friend

The documentation for this class was generated from the following file: