Files
OpenBK7231T_App/src/sim/Rect.cpp
2022-12-05 07:47:39 +01:00

52 lines
974 B
C++

#ifdef WINDOWS
#include "Rect.h"
CShape *CRect::cloneShape() {
CRect *n = new CRect();
n->pos = this->pos;
n->w = this->w;
n->h = this->h;
this->cloneShapeTo(n);
return n;
}
void CRect::drawShape() {
if (bFill) {
glColor3fv(getFillColor());
glBegin(GL_QUADS);
glVertex2f(getX(), getY());
glVertex2f(getX() + w, getY());
glVertex2f(getX() + w, getY() + h);
glVertex2f(getX(), getY() + h);
glEnd();
}
else {
g_style_shapes.apply();
glBegin(GL_LINE_LOOP);
glVertex2f(getX(), getY());
glVertex2f(getX() + w, getY());
glVertex2f(getX() + w, getY() + h);
glVertex2f(getX(), getY() + h);
glEnd();
}
}
void CRect::rotateDegreesAround_internal(float f, const Coord &p) {
Coord a = getPosition();
Coord b = getCorner();
a = a.rotateDegreesAround(f, p);
b = b.rotateDegreesAround(f, p);
setFromTwoPoints(a, b);
}
void CRect::recalcBoundsSelf() {
bounds.clear();
bounds.addPoint(Coord(0, 0));
bounds.addPoint(Coord(w, h));
}
#endif