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

            _trans_dir.Transform(ref xt, ref yt);
            int    x1 = AggMath.iround(xt * SUBPIXEL_SCALE);
            int    y1 = AggMath.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;
            _trans_inv.Transform(ref dx, ref dy);
            dx -= x;
            dy -= y;
            int sx1 = (int)AggMath.uround(SUBPIXEL_SCALE / Math.Sqrt(dx * dx + dy * dy)) >> SUBPIXEL_SHIFT;

            // Calculate scale by Y at x1,y1
            dx = xt;
            dy = yt + delta;
            _trans_inv.Transform(ref dx, ref dy);
            dx -= x;
            dy -= y;
            int sy1 = (int)AggMath.uround(SUBPIXEL_SCALE / Math.Sqrt(dx * dx + dy * dy)) >> SUBPIXEL_SHIFT;

            // Calculate transformed coordinates at x2,y2
            x += len;
            xt = x;
            yt = y;
            _trans_dir.Transform(ref xt, ref yt);
            int x2 = AggMath.iround(xt * SUBPIXEL_SCALE);
            int y2 = AggMath.iround(yt * SUBPIXEL_SCALE);

            // Calculate scale by X at x2,y2
            dx = xt + delta;
            dy = yt;
            _trans_inv.Transform(ref dx, ref dy);
            dx -= x;
            dy -= y;
            int sx2 = (int)AggMath.uround(SUBPIXEL_SCALE / Math.Sqrt(dx * dx + dy * dy)) >> SUBPIXEL_SHIFT;

            // Calculate scale by Y at x2,y2
            dx = xt;
            dy = yt + delta;
            _trans_inv.Transform(ref dx, ref dy);
            dx -= x;
            dy -= y;
            int sy2 = (int)AggMath.uround(SUBPIXEL_SCALE / Math.Sqrt(dx * dx + dy * dy)) >> SUBPIXEL_SHIFT;

            // Initialize the interpolators
            _coord_x = new LineInterpolatorDDA2(x1, x2, len);
            _coord_y = new LineInterpolatorDDA2(y1, y2, len);
            _scale_x = new LineInterpolatorDDA2(sx1, sx2, len);
            _scale_y = new LineInterpolatorDDA2(sy1, sy2, len);
        }
        public static VertexStore TransformToVxs(this Perspective perspecitveTx, VertexStoreSnap snap, VertexStore vxs)
        {
            var       vsnapIter = snap.GetVertexSnapIter();
            double    x, y;
            VertexCmd cmd;

            do
            {
                cmd = vsnapIter.GetNextVertex(out x, out y);
                perspecitveTx.Transform(ref x, ref y);
                vxs.AddVertex(x, y, cmd);
            } while (!VertexHelper.IsEmpty(cmd));
            return(vxs);
        }
        public static VertexStore TransformToVxs(this Perspective perspecitveTx, VertexStore src, VertexStore vxs)
        {
            VertexCmd cmd;
            double    x, y;
            int       count = src.Count;

            for (int i = 0; i < count; ++i)
            {
                cmd = src.GetVertex(i, out x, out y);
                perspecitveTx.Transform(ref x, ref y);
                vxs.AddVertex(x, y, cmd);
            }
            return(vxs);
        }