Gradient Class Reference

#include <gradient.hpp>

Inherits GameObject.

List of all members.

Public Member Functions

 Gradient ()
 Gradient (const Reader &reader)
virtual ~Gradient ()
void set_gradient (Color top, Color bottom)
Color get_gradient_top () const
Color get_gradient_bottom () const
virtual void update (float elapsed_time)
 This function is called once per frame and allows the object to update it's state.
virtual void draw (DrawingContext &context)
 The GameObject should draw itself onto the provided DrawingContext if this function is called.

Private Attributes

int layer
Color gradient_top
Color gradient_bottom


Detailed Description

Definition at line 26 of file gradient.hpp.


Constructor & Destructor Documentation

Gradient::Gradient (  ) 

Definition at line 23 of file gradient.cpp.

00023                    :
00024   layer(LAYER_BACKGROUND0),
00025   gradient_top(),
00026   gradient_bottom()
00027 {
00028 }

Gradient::Gradient ( const Reader reader  ) 

Definition at line 30 of file gradient.cpp.

References lisp::Lisp::get(), gradient_bottom, gradient_top, layer, LAYER_BACKGROUND0, and reader_get_layer().

00030                                        :
00031   layer(LAYER_BACKGROUND0),
00032   gradient_top(),
00033   gradient_bottom()
00034 {
00035   layer = reader_get_layer (reader, /* default = */ LAYER_BACKGROUND0);
00036   std::vector<float> bkgd_top_color, bkgd_bottom_color;
00037   if(!reader.get("top_color", bkgd_top_color) ||
00038      !reader.get("bottom_color", bkgd_bottom_color))
00039     throw std::runtime_error("Must specify top_color and bottom_color in gradient");
00040 
00041   gradient_top = Color(bkgd_top_color);
00042   gradient_bottom = Color(bkgd_bottom_color);
00043 }

Gradient::~Gradient (  )  [virtual]

Definition at line 45 of file gradient.cpp.

00046 {
00047 }


Member Function Documentation

void Gradient::set_gradient ( Color  top,
Color  bottom 
)

Definition at line 55 of file gradient.cpp.

References Color::alpha, Color::blue, gradient_bottom, gradient_top, Color::green, log_warning, and Color::red.

Referenced by Sector::parse(), and Sector::parse_old_format().

00056 {
00057   gradient_top = top;
00058   gradient_bottom = bottom;
00059 
00060   if (gradient_top.red > 1.0 || gradient_top.green > 1.0
00061       || gradient_top.blue > 1.0 || gradient_top.alpha > 1.0)
00062     log_warning << "top gradient color has values above 1.0" << std::endl;
00063   if (gradient_bottom.red > 1.0 || gradient_bottom.green > 1.0
00064       || gradient_bottom.blue > 1.0 || gradient_bottom.alpha > 1.0)
00065     log_warning << "bottom gradient color has values above 1.0" << std::endl;
00066 }

Color Gradient::get_gradient_top (  )  const [inline]

Definition at line 35 of file gradient.hpp.

References gradient_top.

00036   { return gradient_top; }

Color Gradient::get_gradient_bottom (  )  const [inline]

Definition at line 38 of file gradient.hpp.

References gradient_bottom.

00039   { return gradient_bottom; }

void Gradient::update ( float  elapsed_time  )  [virtual]

This function is called once per frame and allows the object to update it's state.

The elapsed_time is the time since the last frame in seconds and should be the base for all timed calculations (don't use SDL_GetTicks directly as this will fail in pause mode)

Implements GameObject.

Definition at line 50 of file gradient.cpp.

00051 {
00052 }

void Gradient::draw ( DrawingContext context  )  [virtual]

The GameObject should draw itself onto the provided DrawingContext if this function is called.

Implements GameObject.

Definition at line 69 of file gradient.cpp.

References DrawingContext::draw_gradient(), gradient_bottom, gradient_top, layer, DrawingContext::pop_transform(), DrawingContext::push_transform(), and DrawingContext::set_translation().

00070 {
00071   context.push_transform();
00072   context.set_translation(Vector(0, 0));
00073   context.draw_gradient(gradient_top, gradient_bottom, layer);
00074   context.pop_transform();
00075 }


Member Data Documentation

int Gradient::layer [private]

Definition at line 46 of file gradient.hpp.

Referenced by draw(), and Gradient().

Color Gradient::gradient_top [private]

Definition at line 47 of file gradient.hpp.

Referenced by draw(), get_gradient_top(), Gradient(), and set_gradient().

Color Gradient::gradient_bottom [private]

Definition at line 48 of file gradient.hpp.

Referenced by draw(), get_gradient_bottom(), Gradient(), and set_gradient().


The documentation for this class was generated from the following files:
Generated on Mon Jun 9 03:38:31 2014 for SuperTux by  doxygen 1.5.1