 |
Gorgon Game Engine
|
Go to the documentation of this file.
14 namespace Gorgon {
namespace Geometry {
29 basic_Rectangle(
const T_ &left,
const T_ &top,
const T_ &width,
const T_ &height) :
50 X(topleft.
X),
Y(topleft.
Y),
70 while(*s==
' ' || *s==
'\t') s++;
74 X=String::To<T_>(&str[s-str.begin()]);
76 while(*s!=
',' && s!=str.end()) s++;
80 Y=String::To<T_>(&str[s-str.begin()]);
82 while(*s!=
' ' && s!=str.end()) s++;
83 while(*s==
' ' || *s==
'\t') s++;
85 Width=String::To<T_>(&str[s-str.begin()]);
87 while(*s!=
'x' && s!=str.end()) s++;
91 Height=String::To<T_>(&str[s-str.begin()]);
97 static char tospace[] =
",<>x";
99 std::string::size_type pos;
100 while((pos=s.find_first_of(tospace)) != std::string::npos) {
106 std::istringstream is(s);
113 throw std::runtime_error(
"Input string is not properly formatted");
126 explicit operator std::string()
const {
187 void Move(
const T_ &x,
const T_ &y) {
378 while(in.peek()==
' ' || in.peek()==
'<')
382 std::stringstream ss;
384 while(in.peek()!=
',' && !in.eof())
385 s.append(1, (
char)in.get());
394 while(in.peek()==
' ' || in.peek()==
'\t')
397 while(in.peek()!=
',' && !in.eof())
398 s.append(1, (
char)in.get());
408 while(in.peek()==
' ' || in.peek()==
'\t')
411 while(in.peek()!=
',' && in.peek()!=
'x' && !in.eof())
412 s.append(1, (
char)in.get());
422 while(in.peek()==
' ' || in.peek()==
'\t')
425 while(in.peek()!=
'>' && in.peek()!=
' ' && in.peek()!=
'\t' && in.peek()!=
'\n' && in.peek()!=
'\r' && !in.eof())
426 s.append(1, in.get());
basic_Rectangle(const std::string &str)
Conversion from string.
Definition: Rectangle.h:67
basic_Point< T_ > TopLeft() const
Returns the top left coordinates of the rectangle.
Definition: Rectangle.h:198
This class represents boundaries of 2D objects.
Definition: Bounds.h:27
bool IsInside(const basic_Bounds< T_ > &b, const basic_Point< T_ > &p)
Checks whether the given point is inside this bounds.
Definition: Bounds.h:514
basic_Rectangle(const basic_Bounds< O_ > &bounds)
Converting constructor from bounds.
Definition: Rectangle.h:62
std::enable_if< decltype(gorgon__enum_tr_loc(T_()))::isupgradedenum, std::string >::type From(const T_ &e)
Definition: Enum.h:303
basic_Rectangle operator*(const basic_Size< O_ > &amount) const
Scales this rectangle with the given size.
Definition: Rectangle.h:255
bool operator==(const basic_Rectangle &r) const
Compares two rectangles.
Definition: Rectangle.h:223
basic_Rectangle< Float > Rectanglef
Definition: Rectangle.h:446
T_ Right() const
Calculates and returns the rightmost coordinate.
Definition: Rectangle.h:143
void Move(const T_ &x, const T_ &y)
Changes the position of the rectangle.
Definition: Rectangle.h:187
basic_Rectangle< int > Rectangle
Definition: Rectangle.h:449
contains the Bounds class
T_ X
X coordinate.
Definition: Point.h:368
T_ X
X coordinate of the top left corner of this rectangle.
Definition: Rectangle.h:354
basic_Rectangle & operator*=(const basic_Size< O_ > &amount)
Scales this rectangle with the given size.
Definition: Rectangle.h:316
T_ Height
Height of this size object.
Definition: Size.h:261
basic_Point< T_ > Center() const
Returns the center point of the rectangle.
Definition: Rectangle.h:193
basic_Rectangle()
Default constructor, does not initialize stored values.
Definition: Rectangle.h:26
basic_Rectangle(const T_ &left, const T_ &top, const T_ &width, const T_ &height)
Filling constructor using values for top left corner and size.
Definition: Rectangle.h:29
std::istream & operator>>(std::istream &in, basic_Bounds< T_ > &bounds)
Stream extractor for bounds.
Definition: Bounds.h:423
T_ Width
Width of the rectangle.
Definition: Rectangle.h:360
basic_Size< T_ > GetSize() const
Returns the size of the rectangle.
Definition: Rectangle.h:218
static basic_Rectangle Parse(std::string s)
Properly parses a rectangle, throwing errors when necessary.
Definition: Rectangle.h:96
Root namespace for Gorgon Game Engine.
Definition: Any.h:19
This class represents a 2D geometric size.
Definition: Size.h:23
void Move(const basic_Point< T_ > &p)
Changes the position of the rectangle.
Definition: Rectangle.h:181
void Resize(const basic_Size< T_ > &s)
Resizes the rectangle.
Definition: Rectangle.h:175
T_ BaseType
Base type of the rectangle elements.
Definition: Rectangle.h:22
T_ Bottom() const
Calculates and returns the bottommost coordinate.
Definition: Rectangle.h:146
void SetRight(const T_ &right)
Moves the rectangle by changing its rightmost coordinate.
Definition: Rectangle.h:149
basic_Point< T_ > TopRight() const
Returns the top right coordinates of the rectangle.
Definition: Rectangle.h:203
This class represents a 2D point.
Definition: Point.h:32
basic_Rectangle(const T_ &left, const T_ &top, const basic_Size< T_ > &size)
Filling constructor using values for top left corner and size.
Definition: Rectangle.h:39
basic_Rectangle operator+(const basic_Point< T_ > &amount) const
Adds a point to this rectangle, effectively translating it.
Definition: Rectangle.h:233
void Resize(const T_ &w, const T_ &h)
Resizes the rectangle.
Definition: Rectangle.h:169
void SetBottom(const T_ &bottom)
Moves the rectangle by changing its bottommost coordinate.
Definition: Rectangle.h:159
T_ Y
Y coordinate of the top left corner of this rectangle.
Definition: Rectangle.h:357
basic_Rectangle(const basic_Point< T_ > &position, const basic_Size< T_ > &size)
Filling constructor using values for top left corner and size.
Definition: Rectangle.h:34
basic_Rectangle & operator-=(const basic_Point< T_ > &amount)
Subtracts a point to this rectangle, effectively translating it.
Definition: Rectangle.h:298
T_ Height
Height of the rectangle.
Definition: Rectangle.h:363
basic_Rectangle & operator/=(const basic_Size< O_ > &amount)
Scales this rectangle with the given size.
Definition: Rectangle.h:326
T_ Y
Y coordinate.
Definition: Point.h:371
std::ostream & operator<<(std::ostream &out, const basic_Bounds< T_ > &bounds)
Allows streaming of bounds.
Definition: Bounds.h:415
basic_Point< T_ > BottomLeft() const
Returns the bottom left coordinates of the rectangle.
Definition: Rectangle.h:208
T_ Width
Width of this size object.
Definition: Size.h:258
basic_Point< T_ > BottomRight() const
Returns the bottom right coordinates of the rectangle.
Definition: Rectangle.h:213
basic_Rectangle operator-(const basic_Point< T_ > &amount) const
Subtracts a point from this rectangle, effectively translating it.
Definition: Rectangle.h:243
basic_Rectangle(const basic_Point< T_ > &position, T_ width, T_ height)
Filling constructor using values for top left corner and size.
Definition: Rectangle.h:44
bool operator!=(const basic_Rectangle &r) const
Compares two rectangles.
Definition: Rectangle.h:228
Represents a rectangle in a 2D space.
Definition: Rectangle.h:19
basic_Rectangle & operator+=(const basic_Point< T_ > &amount)
Adds a point to this rectangle, effectively translating it.
Definition: Rectangle.h:282
basic_Rectangle operator/(const basic_Size< O_ > &amount) const
Scales this rectangle with the given size.
Definition: Rectangle.h:262
basic_Rectangle(const basic_Rectangle< O_ > &rect)
Converting constructor from a different typed rectangle.
Definition: Rectangle.h:56
basic_Rectangle(const basic_Point< T_ > &topleft, const basic_Point< T_ > &bottomright)
Filling constructor using values for top left and bottom right corners.
Definition: Rectangle.h:49