The Battle for Wesnoth  1.17.0-dev
Public Member Functions | Private Attributes | List of all members
gui2::circle_shape Class Reference

Definition of a circle. More...

#include <canvas_private.hpp>

Inheritance diagram for gui2::circle_shape:

Public Member Functions

 circle_shape (const config &cfg)
 Constructor. More...
 
void draw (surface &canvas, SDL_Renderer *renderer, const SDL_Rect &viewport, wfl::map_formula_callable &variables) override
 Draws the canvas. More...
 
- Public Member Functions inherited from gui2::canvas::shape
 shape (const config &cfg)
 
virtual ~shape ()
 
bool immutable () const
 

Private Attributes

typed_formula< unsigned > x_
 The center x coordinate of the circle. More...
 
typed_formula< unsigned > y_
 The center y coordinate of the circle. More...
 
typed_formula< unsigned > radius_
 The radius of the circle. More...
 
typed_formula< color_tborder_color_
 The border color of the circle. More...
 
typed_formula< color_tfill_color_
 The fill color of the circle. More...
 
unsigned int border_thickness_
 The border thickness of the circle. More...
 

Detailed Description

Definition of a circle.

When drawing a circle it doesn't get blended on the surface but replaces the pixels instead. A blitting flag might be added later if needed.

Keys:

Key Type DefaultDescription
x f_unsigned0 The x coordinate of the center.
y f_unsigned0 The y coordinate of the center.
radius f_unsigned0 The radius of the circle; if 0 nothing is drawn.
color color "" The color of the circle.
debug string "" Debug message to show upon creation this message is not stored.

Variables: see line_shape

Drawing outside the area will result in unpredictable results including crashing. (That should be fixed, when encountered.)

Definition at line 293 of file canvas_private.hpp.

Constructor & Destructor Documentation

◆ circle_shape()

gui2::circle_shape::circle_shape ( const config cfg)
explicit

Constructor.

Parameters
cfgThe config object to define the circle.

Definition at line 438 of file canvas.cpp.

References DBG_GUI_P, and debug.

Member Function Documentation

◆ draw()

void gui2::circle_shape::draw ( surface canvas,
SDL_Renderer *  renderer,
const SDL_Rect &  view_bounds,
wfl::map_formula_callable variables 
)
overridevirtual

Draws the canvas.

Parameters
canvasThe resulting image will be blitted upon this canvas.
rendererThe SDL_Renderer to use.
view_boundsPart of the shape to render - this is the location of canvas within the coordinates of the shape.
variablesThe canvas can have formulas in it's definition, this parameter contains the values for these formulas.
Todo:
formulas are now recalculated every draw cycle which is a bit silly unless there has been a resize. So to optimize we should use an extra flag or do the calculation in a separate routine.

Implements gui2::canvas::shape.

Definition at line 453 of file canvas.cpp.

References border_color_, border_thickness_, DBG_GUI_D, fill_color_, i, color_t::null(), radius_, x_, and y_.

Member Data Documentation

◆ border_color_

typed_formula<color_t> gui2::circle_shape::border_color_
private

The border color of the circle.

Definition at line 313 of file canvas_private.hpp.

Referenced by draw().

◆ border_thickness_

unsigned int gui2::circle_shape::border_thickness_
private

The border thickness of the circle.

Definition at line 316 of file canvas_private.hpp.

Referenced by draw().

◆ fill_color_

typed_formula<color_t> gui2::circle_shape::fill_color_
private

The fill color of the circle.

Definition at line 313 of file canvas_private.hpp.

Referenced by draw().

◆ radius_

typed_formula<unsigned> gui2::circle_shape::radius_
private

The radius of the circle.

Definition at line 308 of file canvas_private.hpp.

Referenced by draw().

◆ x_

typed_formula<unsigned> gui2::circle_shape::x_
private

The center x coordinate of the circle.

Definition at line 308 of file canvas_private.hpp.

Referenced by draw().

◆ y_

typed_formula<unsigned> gui2::circle_shape::y_
private

The center y coordinate of the circle.

Definition at line 308 of file canvas_private.hpp.

Referenced by draw().


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