Example #1
0
 public void CMD_Refit(Rect64 target, bool stretch, IEnumerable <int> handles)
 {
     command_buffer.Enqueue(new Command()
     {
         Call = cmd_refit, param = new object[] { target, stretch, handles }
     });
 }
Example #2
0
        public static void GetRefitTransform(IEnumerable <Vector64> points, Rect64 target, bool stretch, out Vector64 scale, out Vector64 shift)
        {
            Rect64 bds = GetBounds(points);

            scale = new Vector64(target.Width() / bds.Width(), target.Height() / bds.Height());

            if (!stretch)
            {
                double s = Math.Min(scale.X, scale.Y);
                scale = new Vector64(s, s);
            }

            shift = new Vector64(-bds.left, -bds.bottom) * scale
                    + new Vector64(Math.Min(target.left, target.right), Math.Min(target.bottom, target.top));
        }
Example #3
0
        private void cmd_refit(params object[] param)
        {
            Rect64        target  = (Rect64)param[0];
            bool          stretch = (bool)param[1];
            HashSet <int> unique  = PreprocessHandles(param[2] as IEnumerable <int>);

            HashSet <Vector64> points = new HashSet <Vector64>();

            foreach (int i in unique)
            {
                points.UnionWith(polygon_lib[i].poly[0].Select(p => polygon_lib[i].trans * new Vector64(p.X, p.Y)));
            }

            Vector64 scale, trans;

            GeomUtility.GetRefitTransform(points, target, stretch, out scale, out trans);

            foreach (int i in unique)
            {
                cmd_scale(i, scale.X, scale.Y);
                cmd_translate(i, trans.X, trans.Y);
            }
        }
Example #4
0
 public static IntRect ToIntRect(this Rect64 rec)
 {
     return(new IntRect((long)rec.left, (long)rec.top, (long)rec.right, (long)rec.bottom));
 }
Example #5
0
        public int AddCanvasFitPolygon(Rect64 canvas, int pattern_handle)
        {
            IntRect c = new IntRect((long)canvas.left, (long)canvas.top, (long)canvas.right, (long)canvas.bottom);

            return(AddCanvasFitPolygon(c, pattern_handle));
        }