예제 #1
0
        /// <summary>
        /// Draws a series of cubic Beziér splines each defined by start, end and two control points.
        /// The ending point of the previous curve is used as starting point for the next.
        /// Therefore the initial curve needs four points and the subsequent 3 (2 control and 1 end point).
        /// </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, cx1, cy1, cx2, cy2, x2, y2, cx3, cx4 ..., xn, yn).</param>
        /// <param name="color">The color for the spline.</param>
        public static void DrawBeziers(this BitmapBuffer bmp, int[] points, int color)
        {
            int x1 = points[0];
            int y1 = points[1];
            int x2, y2;

            for (int i = 2; i + 5 < points.Length; i += 6)
            {
                x2 = points[i + 4];
                y2 = points[i + 5];
                bmp.DrawBezier(x1, y1, points[i], points[i + 1], points[i + 2], points[i + 3], x2, y2, color);
                x1 = x2;
                y1 = y2;
            }
        }
예제 #2
0
 /// <summary>
 /// Draws a cubic Beziér spline defined by start, end and two control points.
 /// </summary>
 /// <param name="bmp">The WriteableBitmap.</param>
 /// <param name="x1">The x-coordinate of the start point.</param>
 /// <param name="y1">The y-coordinate of the start point.</param>
 /// <param name="cx1">The x-coordinate of the 1st control point.</param>
 /// <param name="cy1">The y-coordinate of the 1st control point.</param>
 /// <param name="cx2">The x-coordinate of the 2nd control point.</param>
 /// <param name="cy2">The y-coordinate of the 2nd control point.</param>
 /// <param name="x2">The x-coordinate of the end point.</param>
 /// <param name="y2">The y-coordinate of the end point.</param>
 /// <param name="color">The color.</param>
 public static void DrawBezier(this BitmapBuffer bmp, int x1, int y1, int cx1, int cy1, int cx2, int cy2, int x2, int y2, ColorInt color)
 {
     bmp.DrawBezier(x1, y1, cx1, cy1, cx2, cy2, x2, y2, color.ToPreMultAlphaColor());
 }