public void Oval()
        {
            var points = new[]
            {
                CurvePointUtils.CurvePoint(new[]
                {
                    0.5, 1, 0.77614237490000004, 1, 0.22385762510000001, 1
                }),
                CurvePointUtils.CurvePoint(new[]
                {
                    1, 0.5, 1, 0.22385762510000001, 1, 0.77614237490000004
                }),
                CurvePointUtils.CurvePoint(new[]
                {
                    0.5, 0, 0.22385762510000001, 0, 0.77614237490000004, 0
                }),
                CurvePointUtils.CurvePoint(new[]
                {
                    0, 0.5, 0, 0.77614237490000004, 0, 0.22385762510000001
                }),
            };

            var oval = new SketchPath(points, true);
            var svg  = SketchCurvePointsToSvg.ToSvgString(oval);

            Assert.That(svg, Does.Match("^M 0.5 1 C 0.7761423749 1 1 0.7761423749 1 0.5 C 1 0.2238576251 0.7761423749 0 0.5 0 C 0.2238576251 0 0 0.2238576251 0 0.5 C 0 0.7761423749 0.2238576251 1 0.5 1$"));
        }
示例#2
0
 public static SketchRectangle Rectangle(string name)
 {
     return(new SketchRectangle(
                SketchLayer(id: Guid.NewGuid(), name: name, frame: Frame),
                new SketchPath(CurvePointUtils.RectanglePath(new CornerRadius(0)),
                               true),
                SketchBooleanOperation.NoOperation));
 }
示例#3
0
        public void PathWithMoreThanFourPointsIsNotRectangle()
        {
            var points = CurvePointUtils.RectanglePath(new CornerRadius(0));

            points.Add(CurvePointUtils.LinePoint(0.5, 0.5));
            var path = new SketchPath(points, true);

            Assert.That(Geometry.IsAxisAlignedRectangle(path), Is.False);
        }
示例#4
0
        [TestCase(new [] { 0.0, 0.0 }, new [] { 5.0, 0.0 }, new [] { 5.0 + 3.0, 4.0 }, new [] { 3.0, 4.0 })] // rhombus (pythagoras <3)
        public void QuadrilateralIsNotRectangle(double [] p1, double [] p2, double [] p3, double [] p4)
        {
            var points = new List <SketchCurvePoint>
            {
                CurvePointUtils.LinePoint(p1[0], p1[1]),
                CurvePointUtils.LinePoint(p2[0], p2[1]),
                CurvePointUtils.LinePoint(p3[0], p3[1]),
                CurvePointUtils.LinePoint(p4[0], p4[1]),
            };

            Assert.That(Geometry.EdgesAreAxisAligned(points), Is.False);
        }
        public void StartWithCurve()
        {
            var points = new[]
            {
                CurvePointUtils.CurvePoint(new [] { 0.0, 100, 0, 0, 0, 200 }),
                CurvePointUtils.LinePoint(50, 0),
                CurvePointUtils.LinePoint(100, 100)
            };
            var curve = new SketchPath(points, false);
            var svg   = SketchCurvePointsToSvg.ToSvgString(curve);

            Console.WriteLine(svg);
            Assert.That(svg, Does.Match("^M 0 100 C 0 33.33333333333 16.66666666667 0 50 0 L 100 100$"));
        }
        public void EndWithCurve()
        {
            var points = new[]
            {
                CurvePointUtils.LinePoint(0, 100),
                CurvePointUtils.LinePoint(50, 0),
                CurvePointUtils.CurvePoint(new [] { 100.0, 100, 100, 200, 100, 0 })
            };

            var curve = new SketchPath(points, false);
            var svg   = SketchCurvePointsToSvg.ToSvgString(curve);

            Console.WriteLine(svg);
            Assert.That(svg, Does.Match("M 0 100 L 50 0 C 83.33333333333 0 100 33.33333333333 100 100$"));
        }
        public void CurveFromFirstPoint()
        {
            var points = new[]
            {
                CurvePointUtils.CurvePoint(new[] { 0.0, 0.0 },
                                           new[] { 123.20975114271207, 8.196425347535656 },
                                           new[] { -123.20975114271207, -8.1964253475356769 }),
                CurvePointUtils.LinePoint(94.613074518933793, 99)
            };

            var curve = new SketchPath(points, false);
            var svg   = SketchCurvePointsToSvg.ToSvgString(curve);

            Console.WriteLine(svg);
            Assert.That(svg, Does.Match("^M 0 0 C 82.13983409514 5.464283565024 113.6775256015 38.46428356502 94.61307451893 99$"));
        }
        public void ClosedStarPolygon()
        {
            var points = new[]
            {
                CurvePointUtils.LinePoint(0.5, 0.75),
                CurvePointUtils.LinePoint(0.20610737385376349, 0.90450849718747373),
                CurvePointUtils.LinePoint(0.26223587092621159, 0.57725424859373686),
                CurvePointUtils.LinePoint(0.024471741852423179, 0.34549150281252639),
                CurvePointUtils.LinePoint(0.35305368692688166, 0.29774575140626314),
                CurvePointUtils.LinePoint(0.49999999999999989, 0),
                CurvePointUtils.LinePoint(0.64694631307311823, 0.29774575140626314),
                CurvePointUtils.LinePoint(0.97552825814757682, 0.34549150281252616),
                CurvePointUtils.LinePoint(0.73776412907378841, 0.57725424859373675),
                CurvePointUtils.LinePoint(0.79389262614623668, 0.90450849718747361),
            };
            var path = new SketchPath(points, true);

            var svg = SketchCurvePointsToSvg.ToSvgString(path);

            Assert.That(svg, Does.Match("^M 0.5 0.75 L 0.2061073738538 0.9045084971875 L 0.2622358709262 0.5772542485937 L 0.02447174185242 0.3454915028125 L 0.3530536869269 0.2977457514063 L 0.5 0 L 0.6469463130731 0.2977457514063 L 0.9755282581476 0.3454915028125 L 0.7377641290738 0.5772542485937 L 0.7938926261462 0.9045084971875 L 0.5 0.75$"));
        }
示例#9
0
        public void BuildUxForSketchShapeGroupWithoutMaskingGivesNoWarnings()
        {
            var rectangle = new SketchRectangle(
                CreateLayer(5, 5),
                new SketchPath(CurvePointUtils.RectanglePath(new CornerRadius(2)), true),
                SketchBooleanOperation.NoOperation);

            var parentGroup =
                new SketchGroup(
                    new SketchLayer(
                        new SketchLayer(
                            Guid.Empty,
                            new SketchLayer(
                                CreateLayer(20, 20),
                                new List <SketchLayer>()),
                            new SketchRect(0, 0, 10, 10, false),
                            "Dummy",
                            false,
                            DummyAlignment(),
                            0, false, false,
                            Optional.None(),
                            new List <SketchLayer>()),
                        new List <SketchLayer> {
                rectangle
            }));

            rectangle.Parent = parentGroup;

            var log       = new MessageListLogger();
            var uxBuilder = new UxBuilder(new SymbolClassNameBuilder(), Substitute.For <IAssetEmitter>(), log);

            var uxNode = uxBuilder.BuildLayer(parentGroup);

            Assert.That(uxNode, Is.Not.Null);

            var ux = uxNode.SerializeUx(new UxSerializerContext());

            Assert.That(ux, Is.EqualTo("<Panel Width=\"50%\" Height=\"50%\" Alignment=\"TopLeft\" Margin=\"0\">\n\t<!-- Dummy -->\n\t<Rectangle CornerRadius=\"2\" Width=\"50%\" Height=\"50%\" Alignment=\"TopLeft\" Margin=\"0\">\n\t\t<!-- Dummy -->\n\t</Rectangle>\n</Panel>"));
            Assert.That(log.ErrorsAndWarnings(), Is.Empty);
        }
示例#10
0
        public static SketchSymbolMaster SketchSymbolMaster(string symbolName)
        {
            var sketchPath =
                new SketchPath(
                    CurvePointUtils.RectanglePath(
                        new CornerRadius(0)),
                    true);
            var rectangle = new SketchRectangle(
                SketchLayer(frame: Frame),
                sketchPath, SketchBooleanOperation.NoOperation);

            var sketchSymbolMaster = new SketchSymbolMaster(
                SketchLayer(id: Guid.NewGuid(), name: symbolName, frame: Frame,
                            children: new List <SketchLayer> {
                rectangle
            }),
                Guid.NewGuid()
                );

            rectangle.Parent = sketchSymbolMaster;
            return(sketchSymbolMaster);
        }
示例#11
0
        public void ClosedAxisAlignedPathWithFourPointsIsARectangle()
        {
            var rectangle = new SketchPath(CurvePointUtils.RectanglePath(new CornerRadius(0)), true);

            Assert.That(Geometry.IsAxisAlignedRectangle(rectangle), Is.True);
        }