4 // Copyright (C) 2006 Matthias Braun <matze@braunis.de>
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 #ifndef __SURFACE_HPP__
21 #define __SURFACE_HPP__
27 #include "math/vector.hpp"
28 #include "file_system.hpp"
29 #include <unison/video/Texture.hpp>
31 /// bitset for drawing effects
33 /** Don't apply anything */
35 /** Draw the Surface upside down */
37 /** Draw the Surface from left to down */
43 * A rectangular image.
44 * The class basically holds a reference to a texture with additional UV
45 * coordinates that specify a rectangular area on this texture
50 Unison::Video::TextureSection texture;
54 Surface(const std::string& file) :
55 texture(FileSystem::normalize(file)),
60 Surface(const std::string& file, int x, int y, int w, int h) :
61 texture(FileSystem::normalize(file), Unison::Video::Rect(x, y, w, h)),
66 Surface(const Surface& other) :
67 texture(other.texture),
76 /** flip the surface horizontally */
82 bool get_flipx() const
87 const Surface& operator= (const Surface& other)
89 texture = other.texture;
93 Unison::Video::TextureSection get_texture() const
100 return texture.clip_rect.pos.x;
105 return texture.clip_rect.pos.y;
108 int get_width() const
110 return texture.clip_rect.size.x ? texture.clip_rect.size.x : texture.image.get_size().x;
113 int get_height() const
115 return texture.clip_rect.size.y ? texture.clip_rect.size.y : texture.image.get_size().y;
118 Vector get_position() const
119 { return Vector(get_x(), get_y()); }
122 * returns a vector containing width and height
124 Vector get_size() const
125 { return Vector(get_width(), get_height()); }