using namespace std;
using namespace ArdourCanvas;
-void
-ArdourCanvas::set_source_rgba (Cairo::RefPtr<Cairo::Context> context, Color color)
-{
- context->set_source_rgba (
- ((color >> 24) & 0xff) / 255.0,
- ((color >> 16) & 0xff) / 255.0,
- ((color >> 8) & 0xff) / 255.0,
- ((color >> 0) & 0xff) / 255.0
- );
-}
-
-void
-ArdourCanvas::set_source_rgb_a (Cairo::RefPtr<Cairo::Context> context, Color color, float alpha)
-{
- context->set_source_rgba (
- ((color >> 24) & 0xff) / 255.0,
- ((color >> 16) & 0xff) / 255.0,
- ((color >> 8) & 0xff) / 255.0,
- alpha
- );
-}
-
-void
-ArdourCanvas::set_source_rgba (cairo_t *cr, Color color)
-{
- cairo_set_source_rgba ( cr,
- ((color >> 24) & 0xff) / 255.0,
- ((color >> 16) & 0xff) / 255.0,
- ((color >> 8) & 0xff) / 255.0,
- ((color >> 0) & 0xff) / 255.0
- );
-}
-
-void
-ArdourCanvas::set_source_rgb_a (cairo_t *cr, Color color, float alpha)
-{
- cairo_set_source_rgba ( cr,
- ((color >> 24) & 0xff) / 255.0,
- ((color >> 16) & 0xff) / 255.0,
- ((color >> 8) & 0xff) / 255.0,
- alpha
- );
-}
-
ArdourCanvas::Distance
ArdourCanvas::distance_to_segment_squared (Duple const & p, Duple const & p1, Duple const & p2, double& t, Duple& at)
{
at = p1;
t = 0.0;
return ((dp1x * dp1x) + (dp1y * dp1y));
- }
+ }
// Project a line from p to the segment [p1,p2]. By considering the line
// extending the segment, parameterized as p1 + (t * (p2 - p1)),
- // we find projection of point p onto the line.
+ // we find projection of point p onto the line.
// It falls where t = [(p - p1) . (p2 - p1)] / |p2 - p1|^2
-
+
t = ((dp1x * dx) + (dp1y * dy)) / segLenSquared;
if (t < kEpsilon) {
return ((dpqx * dpqx) + (dpqy * dpqy));
}
-