private int GetValueFromY(double py) { Rectangle rect = GradientRectangle; Rectangle all = Allocation.ToCairoRectangle (); py -= all.Y + ypad * all.Height; return ((int)(255 * (rect.Height - py) / rect.Height)); }