UGDK
src/ugdk/math/frame.h
Go to the documentation of this file.
00001 #ifndef HORUSEYE_FRAMEWORK_FRAME_H_
00002 #define HORUSEYE_FRAMEWORK_FRAME_H_
00003 
00004 namespace ugdk {
00005 
00006 // Representa um quadro (retangulo) na tela e/ou numa imagem.
00007 // Util para trabalhar com animacoes, detectar colisoes
00008 // (bounding box), etc.
00009 //
00010 // left, top, right e bottom sao usados para determinar as
00011 // coordenadas do retangulo.
00012 //
00013 //   (left,top)
00014 //        +------------------+
00015 //        |                  |
00016 //        |                  |
00017 //        +------------------+
00018 //                        (right,bottom)
00019 
00028 class Frame {
00029   public:
00030     // Construtores e destrutores
00032     Frame() : left_(0), top_(0), right_(0), bottom_(0) { }
00034 
00040     Frame(double left, double top, double right, double bottom) :
00041         left_(left), top_(top), right_(right), bottom_(bottom) { }
00042     ~Frame() { }
00043 
00044     // Utilidades inline
00046     double width() const { return right_ - left_; }
00048     double height() const { return bottom_ - top_; }
00049 
00050     // Accessors e mutators
00055     double left() const { return left_; }
00056     void set_left(double left) { left_ = left; }
00057     double top() const { return top_; }
00058     void set_top(double top) { top_ = top; }
00059     double right() const { return right_; }
00060     void set_right(double right) { right_ = right; }
00061     double bottom() const { return bottom_; }
00062     void set_bottom(double bottom) {bottom_ = bottom; }
00065     // Devolve true se houver colisao entre
00066     // 'frame' e este retangulo.
00068     bool Collides(const Frame& frame) const;
00069 
00070   private:
00071     double left_, top_, right_, bottom_;
00072 };
00073 
00074 }  // namespace ugdk
00075 
00076 #endif  // HORUSEYE_FRAMEWORK_FRAME_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines