private void SetFocusPosition <T>(PointList <T> coll, T value, double focuspos) where T : Point, IComparable <T> { if (coll == null || value == null) { throw new ArgumentNullException("coll or value"); } if (!ColorGradient.isValid(focuspos)) { throw new ArgumentException("focuspos"); } // T[] sorted = coll.SortedArray(); int i = Array.IndexOf <T>(sorted, value); if (i > 0) { //calculate focus double w = sorted[i].Position - sorted[i - 1].Position; if (w <= 0) { value.Focus = .5; } else { value.Focus = Math.Max(.0, Math.Min(1.0, (focuspos - sorted[i - 1].Position) / w)); } } }
/// <summary> /// ctor /// </summary> public AlphaPoint(double alpha, double focus, double point) : base(point, focus) { if (!ColorGradient.isValid(alpha)) { throw new ArgumentException("alpha"); } _alpha = alpha; }
/// <summary> /// ctor /// </summary> public Point(double position, double focus) { if (!ColorGradient.isValid(position) || !ColorGradient.isValid(focus)) { throw new ArgumentException("position or focus"); } _position = position; _focus = focus; }