X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fcanvas%2Fcurve.cc;h=de988ee4b255bba524f85a28951ca585b07d83c0;hb=ffdf3ed01763197781a403d45c3b63f653045994;hp=5bbd33799deb1dd55f46cb977bd8e962418de0e4;hpb=59da788793186d90c30b10654bcfd4d20a7d6eb3;p=ardour.git diff --git a/libs/canvas/curve.cc b/libs/canvas/curve.cc index 5bbd33799d..de988ee4b2 100644 --- a/libs/canvas/curve.cc +++ b/libs/canvas/curve.cc @@ -209,3 +209,25 @@ Curve::solve (std::vector const & rhs) return x; } + +bool +Curve::covers (Duple const & pc) const +{ + Duple point = canvas_to_item (pc); + + /* XXX Hellaciously expensive ... */ + + for (Points::const_iterator p = _points.begin(); p != _points.end(); ++p) { + + const Coord dx = point.x - (*p).x; + const Coord dy = point.y - (*p).y; + const Coord dx2 = dx * dx; + const Coord dy2 = dy * dy; + + if ((dx2 < 2.0 && dy2 < 2.0) || (dx2 + dy2 < 4.0)) { + return true; + } + } + + return false; +}