📄 rectangleshape.cpp
字号:
// RectangleShape.cpp: implementation of the RectangleShape class.
//
//////////////////////////////////////////////////////////////////////
#include <assert.h>
#include "ezwin.h"
#include "WindowObject.h"
#include "Shape.h"
#include "RectangleShape.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
RectangleShape::RectangleShape(SimpleWindow &Window,
const Position &Center, const color &c, float w,
float h) : Shape(Window, Center, c),
Width(w), Height(h) {
// No code needed
}
RectangleShape::RectangleShape(SimpleWindow &Window,
float XPosition, float YPosition,
const color &c, float w, float h) : Shape(Window,
Position(XPosition, YPosition), c),
Width(w), Height(h) {
// No code needed
}
float RectangleShape::GetWidth() const {
return Width;
}
float RectangleShape::GetHeight() const {
return Height;
}
void RectangleShape::GetSize(float &W, float &H) const {
W = Width;
H = Height;
return;
}
void RectangleShape::Draw() {
const Position Center = GetPosition();
const float Width = GetWidth();
const float Height = GetHeight();
const Position UpperLeft = Center
+ Position(-.5f * Width, -.5f * Height);
const Position LowerRight = Center
+ Position(.5f * Width, .5f * Height);
GetWindow().RenderRectangle(UpperLeft, LowerRight,
GetColor(), HasBorder());
return;
}
void RectangleShape::SetSize(float W, float H) {
Width = W;
Height = H;
return;
}
void RectangleShape::Erase() {
const Position Center = GetPosition();
const float Width = GetWidth();
const float Height = GetHeight();
const Position UpperLeft = Center
+ Position(-.5f * Width, -.5f * Height);
const Position LowerRight = Center
+ Position(.5f * Width, .5f * Height);
GetWindow().RenderRectangle(UpperLeft, LowerRight,
White, HasBorder());
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -