|
|
|
|
@ -269,12 +269,30 @@ namespace lunarium
|
|
|
|
|
|
|
|
|
|
void Renderer2D::DrawBox(Rectangle box, Color color, float thickness, float angle)
|
|
|
|
|
{
|
|
|
|
|
// TODO: Use DrawLine to make a box
|
|
|
|
|
DrawLine(glm::vec2(box.left(), box.top()), glm::vec2(box.right(), box.top()), color, thickness, angle);
|
|
|
|
|
DrawLine(glm::vec2(box.right(), box.top()), glm::vec2(box.right(), box.bottom()), color, thickness, angle);
|
|
|
|
|
DrawLine(glm::vec2(box.right(), box.bottom()), glm::vec2(box.left(), box.bottom()), color, thickness, angle);
|
|
|
|
|
DrawLine(glm::vec2(box.left(), box.bottom()), glm::vec2(box.left(), box.top()), color, thickness, angle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Renderer2D::DrawEllipse(glm::vec2 center_point, glm::vec2 radii, Color color, int resolution, float thickness, float angle)
|
|
|
|
|
{
|
|
|
|
|
// TODO: Use DrawLine to make ellipse
|
|
|
|
|
float stride = 362.0f / resolution;
|
|
|
|
|
float cur_deg = 0.0f;
|
|
|
|
|
float rad = cur_deg * 3.14159f / 180.0f;
|
|
|
|
|
glm::vec2 prev_point = glm::vec2(center_point.x + (radii.x * cos(rad)), center_point.y + (radii.y * sin(rad)));
|
|
|
|
|
glm::vec2 first_point = prev_point;
|
|
|
|
|
cur_deg += stride;
|
|
|
|
|
for (int i = 1; i <= resolution; i++, cur_deg += stride)
|
|
|
|
|
{
|
|
|
|
|
rad = cur_deg * 3.14159f / 180.0f;
|
|
|
|
|
glm::vec2 cur_point(center_point.x + (radii.x * cos(rad)), center_point.y + (radii.y * sin(rad)));
|
|
|
|
|
|
|
|
|
|
DrawLine(prev_point, cur_point, color, thickness, angle);
|
|
|
|
|
prev_point = cur_point;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DrawLine(prev_point, first_point, color, thickness, angle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Renderer2D::DrawEllipseFilled(glm::vec2 center_point, glm::vec2 radii, Color color, int resolution, float angle)
|
|
|
|
|
|