示例#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>
  *   Moves the drawing pointer of this layer to the specified position.
  * <para>
  * </para>
  * </summary>
  * <param name="x">
  *   the distance from left of layer, in pixels
  * </param>
  * <param name="y">
  *   the distance from top of layer, 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 moveTo(int x, int y)
 {
     return(_objptr.moveTo(x, y));
 }