37 const std::string& text) {
41 const ImVec2 size = ImGui::CalcTextSize(text.c_str());
42 draw_list->AddRectFilled(ImVec2(pos.x - 2, pos.y - 1),
43 ImVec2(pos.x + size.x + 2, pos.y + size.y + 1),
44 IM_COL32(0, 0, 0, 170), 3.0f);
45 draw_list->AddText(pos, color, text.c_str());
53 const ImU32 text = IM_COL32(255, 255, 255, 255);
54 auto to_screen = [&](
float x,
float y) {
55 return ImVec2(room_origin.x + x * scale, room_origin.y + y * scale);
60 const ImVec2 p0 = to_screen(r.x0, r.y0);
61 const ImVec2 p1 = to_screen(r.x1, r.y1);
62 draw_list->AddRectFilled(p0, p1, fill);
63 draw_list->AddRect(p0, p1, stroke, 0.0f, 0, 2.0f);
69 std::vector<ImVec2> points;
70 points.reserve(shape.
tiles.size());
71 for (
const auto& tile : shape.
tiles) {
74 points.push_back(to_screen(x, y));
76 const float thickness = std::max(2.0f, 3.0f * scale);
77 draw_list->AddPolyline(points.data(),
static_cast<int>(points.size()),
78 stroke, ImDrawFlags_None, thickness);
80 const ImVec2 a = points[points.size() - 2];
81 const ImVec2 b = points.back();
82 const float dx = b.x - a.x;
83 const float dy = b.y - a.y;
84 const float len = std::max(0.001f, std::sqrt(dx * dx + dy * dy));
85 const float ux = dx / len;
86 const float uy = dy / len;
87 const float head = std::max(7.0f, 7.0f * scale);
88 draw_list->AddTriangleFilled(b,
89 ImVec2(b.x - ux * head - uy * head * 0.6f,
90 b.y - uy * head + ux * head * 0.6f),
91 ImVec2(b.x - ux * head + uy * head * 0.6f,
92 b.y - uy * head - ux * head * 0.6f),
94 if (!shape.
label.empty()) {
95 const ImVec2 mid((a.x + b.x) * 0.5f, (a.y + b.y) * 0.5f);
104 const ImVec2 c = to_screen(x, y);
105 const float radius = std::max(5.0f, 5.0f * scale);
106 draw_list->AddCircleFilled(c, radius, stroke);
107 draw_list->AddCircle(c, radius, IM_COL32(255, 255, 255, 230), 0, 1.5f);
115 const ImVec2 c = to_screen(x, y);
116 const float r = std::max(6.0f, 6.0f * scale);
117 const float thickness = std::max(2.0f, 2.5f * scale);
118 draw_list->AddCircle(c, r + 2.0f, stroke, 0, thickness * 0.6f);
119 draw_list->AddLine(ImVec2(c.x - r, c.y - r), ImVec2(c.x + r, c.y + r),
121 draw_list->AddLine(ImVec2(c.x - r, c.y + r), ImVec2(c.x + r, c.y - r),