Ejemplo n.º 1
0
        public override void Draw(Context context)
        {
            if (curve != null)
            {
                foreach (Tuple <double, double> positions in Scalars.GetIntermediateValuesSymmetric(0, 1, SegmentCount + 1).GetRanges())
                {
                    double position = Enumerables.Average(positions.Item1, positions.Item2);

                    Vector2Double curvatureVector = CurveOptimizer.CurvatureMarkersFactor * curve.GetCurvature(position) * curve.GetNormalVector(position);

                    Krach.Graphics.Color lineColor = StretchColor(curve.GetSpeed(position) / basicSpecification.CurveLength);

                    Drawing.DrawLine(context, curve.GetPoint(position), curve.GetPoint(position) + curvatureVector, 0.5, Colors.Blue);
                    Drawing.DrawLine(context, curve.GetPoint(positions.Item1), curve.GetPoint(positions.Item2), 2, lineColor);
                }
            }

            base.Draw(context);
        }
Ejemplo n.º 2
0
        static Krach.Graphics.Color StretchColor(double stretchFactor)
        {
            Krach.Graphics.Color baseColor = Krach.Graphics.Color.FromHsv(0, 0, 0);

            OrderedRange <double> source      = new OrderedRange <double>(0.75, 1.0);
            OrderedRange <double> destination = new OrderedRange <double>(0.0, 1.0);

            IMap <double, double> amplifier = new RangeMap(source, destination, Mappers.Linear);

            if (stretchFactor < 1)
            {
                return(Krach.Graphics.Color.InterpolateRgb(Colors.Blue, baseColor, Scalars.InterpolateLinear, amplifier.Map((1.0 * stretchFactor).Clamp(source))));
            }
            if (stretchFactor > 1)
            {
                return(Krach.Graphics.Color.InterpolateRgb(Colors.Red, baseColor, Scalars.InterpolateLinear, amplifier.Map((1.0 / stretchFactor).Clamp(source))));
            }

            return(baseColor);
        }