#include "imgui_plot.h" namespace ImGui { bool is_inside_area(const ImVec2& P, const ImVector& V) { size_t cn = 0; // the crossing number counter size_t n = V.size(); if (n < 3) return false; size_t i = 0; size_t j = 1; while (i < n) { if (((V[i].y <= P.y) && (V[j].y > P.y)) || ((V[i].y > P.y) && (V[j].y <= P.y))) { float vt = (float)(P.y - V[i].y) / (V[j].y - V[i].y); if (P.x < V[i].x + vt * (V[j].x - V[i].x)) { // P.x < intersect ++cn; // a valid crossing of y=P.y right of P.x } } ++i; j = (i + 1) % n; } return cn % 2 != 0; // false if even (out), and true if odd (in) } }