29#ifndef NOMLIB_SDL2_GRADIENT_HPP
30#define NOMLIB_SDL2_GRADIENT_HPP
37#include "nomlib/config.hpp"
38#include "nomlib/math/Size2.hpp"
39#include "nomlib/math/Transformable.hpp"
40#include "nomlib/math/Color4.hpp"
41#include "nomlib/graphics/IDrawable.hpp"
42#include "nomlib/graphics/shapes/Rectangle.hpp"
43#include "nomlib/core/unique_ptr.hpp"
56 typedef Transformable derived_class;
58 typedef self_type* raw_ptr;
59 typedef std::unique_ptr<self_type> unique_ptr;
60 typedef std::shared_ptr<self_type> shared_ptr;
85 const Color4iColors&
colors,
88 const Point2i& margin,
128 bool dithering(
void )
const;
129 const Point2i& margins (
void )
const;
132 const Color4iColors&
colors(
void )
const;
156 void set_margins (
const Point2i& margin );
157 void set_dithering(
bool state );
169 void strategy_top_down(
void );
170 void strategy_left_right(
void );
virtual ~Gradient(void)
Destructor.
enum Gradient::FillDirection fill_direction_
Color fill axis – X or Y increment.
ObjectTypeInfo type(void) const
Re-implements the IObject::type method.
void draw(RenderTarget &target) const
Implements the IDrawable::draw method.
void set_size(const Size2i &size)
Re-implements the Transformable::set_size method.
std::shared_ptr< Texture > texture_
Render cache for the gradient.
Gradient(void)
Default constructor; initialize the object to an invalid state.
const Color4i & end_color(void) const
Get the last (ending) color used in the gradient fill.
std::vector< Rectangle > rectangles_
Rectangles cache; this is used to build the texture cache.
const Color4iColors & colors(void) const
Get the gradient colors container.
Texture * texture() const
Get the underlying texture of the rendered gradient.
void set_position(const Point2i &coords)
Re-implements the Transformable::set_position method.
void set_colors(const Color4iColors &colors)
Set the gradient colors used in the rendering of the gradient fill.
Gradient(const Color4iColors &colors, const Point2i &pos, const Size2i &size, const Point2i &margin, Gradient::FillDirection direction)
Construct a complete object state.
bool valid(void) const
Query the validity of the object.
bool dithering_
Dithering (of gradient colors) state.
bool update_cache()
Synchronize the texture cache with the generated rectangles.
Color4iColors gradient_
The starting & ending colors used in the gradient fill.
const Color4i & start_color(void) const
Get the first (starting) color used in the gradient fill.
void update(void)
Implements the IDrawable::update method.
void reverse_colors(void)
Swap the first and last color used in the gradient fill.
Point2i margins_
Additional offset coordinates, in pixels.
IDrawable::raw_ptr clone(void) const
Implements the required IDrawable::clone method.
self_type * raw_ptr
A type definition for a C pointer – raw pointer – to an IDrawable object.
const RenderWindow RenderTarget
Run-time type information (RTTI) container class.