コード例 #1
0
        public virtual void TransformPathTest()
        {
            Line        inLine        = new Line(new Point(0, 0), new Point(10, 10));
            BezierCurve inBezierCurve = new BezierCurve(JavaUtil.ArraysAsList(new Point(0, 0), new Point(0, 5), new Point
                                                                                  (5, 5), new Point(5, 0)));
            Subpath inSubpath = new Subpath();

            inSubpath.AddSegment(inLine);
            inSubpath.AddSegment(inBezierCurve);
            Path        inPath         = new Path(JavaUtil.ArraysAsList(inSubpath));
            Matrix      ctm            = new Matrix(1, 0, 0, 1, 5, 5);
            Path        outPath        = ShapeTransformUtil.TransformPath(inPath, ctm);
            Line        cmpLine        = new Line(new Point(-5, -5), new Point(5, 5));
            BezierCurve cmpBezierCurve = new BezierCurve(JavaUtil.ArraysAsList(new Point(-5, -5), new Point(-5, 0), new
                                                                               Point(0, 0), new Point(0, -5)));
            Subpath cmpSubpath = new Subpath();

            inSubpath.AddSegment(cmpLine);
            inSubpath.AddSegment(cmpBezierCurve);
            Path cmpPath = new Path(JavaUtil.ArraysAsList(cmpSubpath));

            for (int i = 0; i < cmpPath.GetSubpaths().Count; i++)
            {
                Subpath subpath = cmpPath.GetSubpaths()[i];
                for (int j = 0; j < subpath.GetSegments().Count; j++)
                {
                    IShape cmpShape = subpath.GetSegments()[j];
                    IShape outShape = outPath.GetSubpaths()[i].GetSegments()[j];
                    NUnit.Framework.Assert.AreEqual(cmpShape.GetBasePoints().ToArray(), outShape.GetBasePoints().ToArray());
                }
            }
        }
コード例 #2
0
        /// <summary>Approximates a given Path with a List of Point objects</summary>
        /// <param name="path">input path</param>
        private static IList <Point> GetPathApproximation(Path path)
        {
            IList <Point> approx = new ApproxPoints();

            foreach (Subpath subpath in path.GetSubpaths())
            {
                approx.AddAll(subpath.GetPiecewiseLinearApproximation());
            }
            return(approx);
        }
コード例 #3
0
        /// <summary>Method for transforming a path.</summary>
        /// <remarks>
        /// Method for transforming a path.
        /// The method creates a new transformed path without changing the original path.
        /// </remarks>
        /// <param name="path">the source path for transformation</param>
        /// <param name="ctm">the transformation matrix</param>
        /// <returns>the new transformed path</returns>
        public static Path TransformPath(Path path, Matrix ctm)
        {
            Path newPath = new Path();

            foreach (Subpath subpath in path.GetSubpaths())
            {
                Subpath transformedSubpath = TransformSubpath(subpath, ctm);
                newPath.AddSubpath(transformedSubpath);
            }
            return(newPath);
        }