Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
nom::Gradient Class Reference

Rectangle fill class with dithered, linear gradient colors. More...

#include <Gradient.hpp>

Inheritance diagram for nom::Gradient:
[legend]
Collaboration diagram for nom::Gradient:
[legend]

Public Types

enum  FillDirection { Top = 0, Bottom, Left, Right }
 
typedef std::shared_ptr< Gradient > SharedPtr
 
typedef std::unique_ptr< Gradient > UniquePtr
 
typedef Gradient * RawPtr
 
- Public Types inherited from nom::IDrawable
typedef std::unique_ptr
< IDrawable > 
UniquePtr
 std::unique_ptr definition type for your convenience, sir!
 
typedef std::shared_ptr
< IDrawable > 
SharedPtr
 std::shared_ptr definition type at your leisure, sir!
 
typedef std::vector
< std::shared_ptr< IDrawable > > 
SharedDrawables
 Vector of std::shared_ptr definition type for the brotherhood, sir!
 
typedef std::vector
< std::unique_ptr< IDrawable > > 
UniqueDrawables
 std::unique_ptr vector container type
 
typedef const Window & RenderTarget
 

Public Member Functions

 Gradient (void)
 
 Gradient (Color gradient_color[2], const Coords &bounds, int32 x_margin, int32 y_margin, Gradient::FillDirection direction)
 
virtual ~Gradient (void)
 Destructor; OK to inherit me.
 
void initialize (Color gradient_color[2], const Coords &bounds, int32 x_margin, int32 y_margin, Gradient::FillDirection direction)
 Fully initialize this object.
 
const Coords getPosition (void) const
 
const Coords getSize (void) const
 
Color getStartColor (void) const
 
Color getEndColor (void) const
 
Gradient::FillDirection getFillDirection (void) const
 
bool dithering (void) const
 
void setStartColor (const Color &starting_color)
 
void setEndColor (const Color &ending_color)
 
void reverseColors (void)
 
void setFillDirection (Gradient::FillDirection direction)
 
void setPosition (int32 x, int32 y)
 
void setSize (int32 width, int32 height)
 
void setMargins (int32 x, int32 y)
 
void enableDithering (bool toggle)
 
void update (void)
 
void draw (RenderTarget target) const
 Render the object onto the primary video buffer – your visible screen.
 
- Public Member Functions inherited from nom::IDrawable
 IDrawable (void)
 Do nothing at all default constructor.
 
virtual ~IDrawable (void)
 Do nothing at all destructor.
 

Private Member Functions

void strategyTopDown (void)
 
void strategyLeftToRight (void)
 

Private Attributes

IDrawable::UniqueDrawables rectangles
 
Color gradient [2]
 
Coords coords
 Rendering coordinates (X, Y, width & height)
 
int32 x_margin
 x coordinate offset
 
int32 y_margin
 y coordinate offset
 
enum Gradient::FillDirection fill_direction
 Color fill axis – X or Y increment.
 
bool enable_dithering
 Toggle automatic dithering of colors.
 

Detailed Description

Rectangle fill class with dithered, linear gradient colors.

nom::Gradient is a beautiful class that paints as rectangle coordinates would, but with dithered, linear gradient effects applied. Color range and fill direction are the two likely features of your interest.

Usage example:

* #include <nomlib/graphics.hpp>
*
* nom::Gradient linear;
*
* this->linear.setSize ( 64, 64 );
* this->linear.setMargins ( 4, 4 );
* this->linear.setFillDirection ( nom::FillDirection::Top );
* this->linear.setStartColor ( nom::Color ( 208, 223, 255 ) );
* this->linear.setEndColor ( nom::Color ( 50, 59, 114 ) );
* this->linear.setPosition ( 96, 16 );
* this->linear.Update();
* this->linear.Draw ( video_buffer );
*
*

Definition at line 48 of file Gradient.hpp.

Member Enumeration Documentation

Todo:
Rename me – Direction seems fitting? Jeffrey Carpenter jeffr.nosp@m.ey.c.nosp@m.arp@g.nosp@m.mail.nosp@m..com @ 2013-10-05

Definition at line 60 of file Gradient.hpp.

Constructor & Destructor Documentation

nom::Gradient::Gradient ( void  )

Default construct for initializing instance variables to their respective defaults.

Definition at line 33 of file Gradient.cpp.

Here is the call graph for this function:

nom::Gradient::Gradient ( Color  gradient_color[2],
const Coords &  bounds,
int32  x_margin,
int32  y_margin,
Gradient::FillDirection  direction 
)

Construct an object, fully initializing it.

Definition at line 45 of file Gradient.cpp.

Member Function Documentation

void nom::Gradient::update ( void  )
virtual

Intended to be used internally by the class re-implementing this method; for use in preparing the buffer to be drawn using the draw method call. Whereas both Update & Draw are typically publicly exposed to the end-user, only the Draw method call should be expected of the end-user to be explicitly called.

Todo:
Not all the interfaced (inherited) IDrawable objects in this library conform to the expectations stated above. We need to first figure out if we wish to stay on this course (of expectation), or diverge all together. Undecided. Jeffrey Carpenter jeffr.nosp@m.ey.c.nosp@m.arp@g.nosp@m.mail.nosp@m..com @ 2013-10-03

Implements nom::IDrawable.

Definition at line 209 of file Gradient.cpp.

Member Data Documentation

Color nom::Gradient::gradient[2]
private

The starting & ending colors (nom::Color objects) used in the gradient.

Todo:
Expand this into a dynamic array – std::vector – so we (should) be able to increase dithering capabilities higher. Perhaps increasing this threshold will also allow us to start thinking about other gradient types? Jeffrey Carpenter jeffr.nosp@m.ey.c.nosp@m.arp@g.nosp@m.mail.nosp@m..com @ 2013-10-03

Definition at line 129 of file Gradient.hpp.

IDrawable::UniqueDrawables nom::Gradient::rectangles
private

Drawables vector containing rectangle objects to be blit

Todo:
Yes, you heard me right! We are using a rectangle function to draw what are one pixel wide / high line segments in a row single row iteration. Imaginably, performance would hardly measure a difference, but nevertheless.

Definition at line 120 of file Gradient.hpp.


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