示例#1
0
        // this is the recusive function to draw 1/3nd of the Von Koch flake
        static void recursiveLine(YDisplayLayer layer, double x0, double y0, double x1, double y1,
                                  int deep)
        {
            double dx, dy, mx, my;

            if (deep <= 0)
            {
                layer.moveTo((int)(x0 + 0.5), (int)(y0 + 0.5));
                layer.lineTo((int)(x1 + 0.5), (int)(y1 + 0.5));
            }
            else
            {
                dx = (x1 - x0) / 3;
                dy = (y1 - y0) / 3;
                mx = ((x0 + x1) / 2) + (0.87 * (y1 - y0) / 3);
                my = ((y0 + y1) / 2) - (0.87 * (x1 - x0) / 3);
                recursiveLine(layer, x0, y0, x0 + dx, y0 + dy, deep - 1);
                recursiveLine(layer, x0 + dx, y0 + dy, mx, my, deep - 1);
                recursiveLine(layer, mx, my, x1 - dx, y1 - dy, deep - 1);
                recursiveLine(layer, x1 - dx, y1 - dy, x1, y1, deep - 1);
            }
        }
示例#2
0
 /**
  * <summary>
  *   Draws a line from current drawing pointer position to the specified position.
  * <para>
  *   The specified destination pixel is included in the line. The pointer position
  *   is then moved to the end point of the line.
  * </para>
  * </summary>
  * <param name="x">
  *   the distance from left of layer to the end point of the line, in pixels
  * </param>
  * <param name="y">
  *   the distance from top of layer to the end point of the line, in pixels
  * </param>
  * <returns>
  *   <c>0</c> if the call succeeds.
  * </returns>
  * <para>
  *   On failure, throws an exception or returns a negative error code.
  * </para>
  */
 public virtual int lineTo(int x, int y)
 {
     return(_objptr.lineTo(x, y));
 }