Beispiel #1
0
        //----------------------------------------------------------------
        public void begin(double x, double y, int len)
        {
            // Calculate transformed coordinates at x1,y1
            double xt = x;
            double yt = y;

            m_trans_dir.transform(ref xt, ref yt);
            int x1 = agg_basics.iround(xt * subpixel_scale);
            int y1 = agg_basics.iround(yt * subpixel_scale);

            double dx;
            double dy;
            double delta = 1 / (double)subpixel_scale;

            // Calculate scale by X at x1,y1
            dx = xt + delta;
            dy = yt;
            m_trans_inv.transform(ref dx, ref dy);
            dx -= x;
            dy -= y;
            int sx1 = (int)agg_basics.uround(subpixel_scale / Math.Sqrt(dx * dx + dy * dy)) >> subpixel_shift;

            // Calculate scale by Y at x1,y1
            dx = xt;
            dy = yt + delta;
            m_trans_inv.transform(ref dx, ref dy);
            dx -= x;
            dy -= y;
            int sy1 = (int)agg_basics.uround(subpixel_scale / Math.Sqrt(dx * dx + dy * dy)) >> subpixel_shift;

            // Calculate transformed coordinates at x2,y2
            x += len;
            xt = x;
            yt = y;
            m_trans_dir.transform(ref xt, ref yt);
            int x2 = agg_basics.iround(xt * subpixel_scale);
            int y2 = agg_basics.iround(yt * subpixel_scale);

            // Calculate scale by X at x2,y2
            dx = xt + delta;
            dy = yt;
            m_trans_inv.transform(ref dx, ref dy);
            dx -= x;
            dy -= y;
            int sx2 = (int)agg_basics.uround(subpixel_scale / Math.Sqrt(dx * dx + dy * dy)) >> subpixel_shift;

            // Calculate scale by Y at x2,y2
            dx = xt;
            dy = yt + delta;
            m_trans_inv.transform(ref dx, ref dy);
            dx -= x;
            dy -= y;
            int sy2 = (int)agg_basics.uround(subpixel_scale / Math.Sqrt(dx * dx + dy * dy)) >> subpixel_shift;

            // Initialize the interpolators
            m_coord_x = new dda2_line_interpolator(x1, x2, (int)len);
            m_coord_y = new dda2_line_interpolator(y1, y2, (int)len);
            m_scale_x = new dda2_line_interpolator(sx1, sx2, (int)len);
            m_scale_y = new dda2_line_interpolator(sy1, sy2, (int)len);
        }
Beispiel #2
0
        public void scaling(out double x, out double y)
        {
            double      x1 = 0.0;
            double      y1 = 0.0;
            double      x2 = 1.0;
            double      y2 = 1.0;
            Perspective t  = new Perspective(this);

            t *= Affine.NewRotation(-rotation());
            t.transform(ref x1, ref y1);
            t.transform(ref x2, ref y2);
            x = x2 - x1;
            y = y2 - y1;
        }
Beispiel #3
0
        // Inverse transformation of x and y. It works slow because
        // it explicitly inverts the matrix on every call. For massive
        // operations it's better to invert() the matrix and then use
        // direct transformations.
        public void inverse_transform(ref double x, ref double y)
        {
            Perspective t = new Perspective(this);

            if (t.invert())
            {
                t.transform(ref x, ref y);
            }
        }
Beispiel #4
0
 public void scaling(out double x, out double y)
 {
     double x1 = 0.0;
     double y1 = 0.0;
     double x2 = 1.0;
     double y2 = 1.0;
     Perspective t=new Perspective(this);
     t *= Affine.NewRotation(-rotation());
     t.transform(ref x1, ref y1);
     t.transform(ref x2, ref y2);
     x = x2 - x1;
     y = y2 - y1;
 }
Beispiel #5
0
 // Inverse transformation of x and y. It works slow because
 // it explicitly inverts the matrix on every call. For massive 
 // operations it's better to invert() the matrix and then use 
 // direct transformations. 
 public void inverse_transform(ref double x, ref double y)
 {
     Perspective t = new Perspective(this);
     if(t.invert()) t.transform(ref x, ref y);
 }