Ejemplo n.º 1
0
 private void DrawCardinal()
 {
     if (points.Count > 2)
     {
         writeableBmp.DrawCurve(GetPointArray(), Tension, Colors.Yellow);
     }
 }
Ejemplo n.º 2
0
 private void DrawCardinal(WriteableBitmap writeableBmp)
 {
     if (points.Count > 2)
     {
         writeableBmp.DrawCurve(GetPointArray(), Tension, Colors.Red);
     }
 }
        /// <summary>
        /// Draws a Cardinal spline (cubic) defined by a point collection.
        /// The cardinal spline passes through each point in the collection.
        /// </summary>
        /// <param name="bmp">The WriteableBitmap.</param>
        /// <param name="points">The points for the curve in x and y pairs, therefore the array is interpreted as (x1, y1, x2, y2, x3, y3, x4, y4, x1, x2 ..., xn, yn).</param>
        /// <param name="tension">The tension of the curve defines the shape. Usually between 0 and 1. 0 would be a straight line.</param>
        /// <param name="color">The color for the spline.</param>
        public static void DrawCurve(this WriteableBitmap bmp, int[] points, float tension, Color color)
        {
            // Add one to use mul and cheap bit shift for multiplicaltion
            int a   = color.A + 1;
            int col = (color.A << 24)
                      | ((byte)((color.R * a) >> 8) << 16)
                      | ((byte)((color.G * a) >> 8) << 8)
                      | ((byte)((color.B * a) >> 8));

            bmp.DrawCurve(points, tension, col);
        }
Ejemplo n.º 4
0
        private void Draw(WriteableBitmap writeableBmp, Branch branch)
        {
            int[] pts = new int[]
            {
                branch.Start.X, branch.Start.Y,
                branch.Middle.X, branch.Middle.Y,
                branch.End.X, branch.End.Y,
            };

            // Draw with cardinal spline
            writeableBmp.DrawCurve(pts, Tension, this.Color);

            foreach (var b in branch.Branches)
            {
                Draw(writeableBmp, b);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Draws a Cardinal spline (cubic) defined by a point collection.
        /// The cardinal spline passes through each point in the collection.
        /// </summary>
        /// <param name="bmp">The WriteableBitmap.</param>
        /// <param name="points">The points for the curve in x and y pairs, therefore the array is interpreted as (x1, y1, x2, y2, x3, y3, x4, y4, x1, x2 ..., xn, yn).</param>
        /// <param name="tension">The tension of the curve defines the shape. Usually between 0 and 1. 0 would be a straight line.</param>
        /// <param name="color">The color for the spline.</param>
        public static void DrawCurve(this WriteableBitmap bmp, int[] points, float tension, Color color)
        {
            var col = ConvertColor(color);

            bmp.DrawCurve(points, tension, col);
        }