summaryrefslogtreecommitdiffstats
path: root/Project/Element.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Project/Element.cpp')
-rw-r--r--Project/Element.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/Project/Element.cpp b/Project/Element.cpp
index e5304a0..984eb65 100644
--- a/Project/Element.cpp
+++ b/Project/Element.cpp
@@ -35,3 +35,31 @@ void Element::DrawRectangle(wxPoint2DDouble position, double width, double heigh
glVertex2d(position.m_x + width / 2.0, position.m_y - height / 2.0);
glEnd();
}
+
+void Element::DrawRectangle(wxPoint2DDouble* points, GLenum mode) const
+{
+ glBegin(mode); // TODO: GL_QUADS é obsoleto (OpenGL 3.0+), encontrar outra solução.
+ glVertex2d(points[0].m_x, points[0].m_y);
+ glVertex2d(points[1].m_x, points[1].m_y);
+ glVertex2d(points[2].m_x, points[2].m_y);
+ glVertex2d(points[3].m_x, points[3].m_y);
+ glEnd();
+}
+
+void Element::DrawPickbox(wxPoint2DDouble position) const
+{
+ glColor4d(1.0, 1.0, 1.0, 0.8);
+ DrawRectangle(position, 8.0, 8.0);
+ glColor4d(0.0, 0.0, 0.0, 1.0);
+ DrawRectangle(position, 8.0, 8.0, GL_LINE_LOOP);
+}
+
+wxPoint2DDouble Element::RotateAtPosition(wxPoint2DDouble pointToRotate, double angle, bool degrees) const
+{
+ double radAngle = angle;
+ if(degrees) radAngle = wxDegToRad(angle);
+ return wxPoint2DDouble(std::cos(radAngle) * (pointToRotate.m_x - m_position.m_x) -
+ std::sin(radAngle) * (pointToRotate.m_y - m_position.m_y) + m_position.m_x,
+ std::sin(radAngle) * (pointToRotate.m_x - m_position.m_x) +
+ std::cos(radAngle) * (pointToRotate.m_y - m_position.m_y) + m_position.m_y);
+}