SimpleCxxLib
packageclass GRect : public GObject
int main() { GWindow gw; cout << "This program draws a red rectangle at (0, 0)." << endl; GRect *rect = new GRect(0, 0, 200, 100); rect->setFilled(true); rect->setColor("RED"); gw.add(rect); return 0; }
Constructor | |
GRect(x, y, width, height) | Constructs a rectangle with the specified width and height. |
Methods | |
Returns the color used to display the filled region of this rectangle. | |
Returns true if the rectangle is filled. | |
setBounds(x, y, width, height) | Changes the bounds of this rectangle to the specified values. |
Sets the color used to display the filled region of this rectangle. | |
Sets the fill status for the rectangle, where false is outlined and true is filled. | |
setSize(width, height) | Changes the size of this rectangle to the specified width and height. |
GRect(double width, double height); GRect(double x, double y, double width, double height);
x
and y
.
Usage:
GRect *rect = new GRect(width, height); GRect *rect = new GRect(x, y, width, height);
void setSize(const GDimension & size); void setSize(double width, double height);
Usage:
rect->setSize(size); rect->setSize(width, height);
void setBounds(const GRectangle & size); void setBounds(double x, double y, double width, double height);
Usage:
rect->setBounds(rect); rect->setBounds(x, y, width, height);
void setFilled(bool flag);
false
is
outlined and true
is filled.
Usage:
rect->setFilled(flag);
bool isFilled() const;
true
if the rectangle is filled.
Usage:
if (rect->isFilled()) ...
void setFillColor(string color); void setFillColor(int rgb);
Usage:
rect->setFillColor(color);
string getFillColor() const;
getFillColor
returns the empty string.
Usage:
string color = rect->getFillColor();