MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / draw

Method draw

src/Core/Transform/Rect.cpp:65–114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63 }
64
65 void Rect::draw(Graphics::RenderTarget surface, int x, int y) const
66 {
67 int r = 6;
68
69 std::vector<Transform::UnitVector> drawPoints;
70 const UnitVector dPos(x, y, Transform::Units::ScenePixels);
71
72 const std::vector<Referential> fixDisplayOrder
73 = { Referential::TopLeft, Referential::Top, Referential::TopRight,
74 Referential::Right, Referential::BottomRight, Referential::Bottom,
75 Referential::BottomLeft, Referential::Left };
76
77 for (uint8_t i = 0; i < 8; ++i)
78 {
79 UnitVector pt;
80 this->transformRef(pt, fixDisplayOrder[i], ConversionType::From);
81
82 UnitVector world = (pt + dPos).to<Units::ScenePixels>();
83 drawPoints.push_back(world);
84 }
85
86 const double radAngle = Utils::Math::convertToRadian(-m_angle);
87 const double cosAngle = std::cos(radAngle);
88 const double sinAngle = std::sin(radAngle);
89 UnitVector topPos;
90 this->transformRef(topPos, Referential::Top, ConversionType::From);
91 topPos = topPos.to<Units::ScenePixels>();
92 topPos += dPos;
93 UnitVector vec = topPos;
94 UnitVector result;
95 const double dy = m_size.y / 4;
96 result.x = (-dy * sinAngle) * -1;
97 result.y = (dy * cosAngle) * -1;
98 vec += result;
99 Graphics::Utils::drawPoint(surface, vec.x - r, vec.y - r, r, sf::Color::White);
100 Graphics::Utils::drawLine(
101 surface, vec.x, vec.y, topPos.x, topPos.y, 2, sf::Color::White);
102
103 Graphics::Utils::drawPolygon(surface, drawPoints,
104 { { "lines", true }, { "points", true }, { "radius", r },
105 { "point_color", sf::Color::White }, { "point_color_0", sf::Color::Red },
106 { "point_color_1", sf::Color(255, 128, 0) },
107 { "point_color_2", sf::Color::Yellow },
108 { "point_color_3", sf::Color(128, 255, 0) },
109 { "point_color_4", sf::Color::Green },
110 { "point_color_5", sf::Color(0, 255, 128) },
111 { "point_color_6", sf::Color::Magenta },
112 { "point_color_7", sf::Color(0, 128, 255) },
113 { "point_color_8", sf::Color::White } });
114 }
115
116 double Rect::x() const
117 {

Callers

nothing calls this directly

Calls 7

transformRefMethod · 0.95
convertToRadianFunction · 0.85
drawPointFunction · 0.85
drawLineFunction · 0.85
drawPolygonFunction · 0.85
ColorClass · 0.85
push_backMethod · 0.45

Tested by

no test coverage detected