Ejemplo n.º 1
0
        public Panel(SceneGraph graph, bool flipVertically, bool movable)
            : base(graph)
        {
            _rectangle = Quadrilateral <V> .Rectangle(1f, 1f).Translate(0.5f, -0.5f);

            _flipVertically = flipVertically;
            _movable        = movable;
        }
Ejemplo n.º 2
0
 public void TestQuadNoNegativeSides()
 {
     Quadrilateral myquad = new Quadrilateral();
     myquad.Top = 2;
     myquad.Right = 2;
     myquad.Left = -2;
     myquad.Bottom = 2;
 }
Ejemplo n.º 3
0
        public void TestRectangleArea()
        {
            var testRectangle = new Quadrilateral(12, 15);

            /* Rectangle with dimensions of 12, 15 should always have an area of 180
             * when rounded to 2 decimal places */
            Assert.AreEqual(testRectangle.Area, 180);
        }
Ejemplo n.º 4
0
        public void TestSquarePerimeter()
        {
            var testSqaure = new Quadrilateral(12, 12);

            /* Square with dimensions of 12, 12 should always have an perimeter of 48
             * when rounded to 2 decimal places */
            Assert.AreEqual(testSqaure.Perimeter, 48);
        }
Ejemplo n.º 5
0
        public void TestSquareArea()
        {
            var testSquare = new Quadrilateral(12, 12);

            /* Sqaure with dimensions of 12, 12 should always have an area of 144
             * when rounded to 2 decimal places */
            Assert.AreEqual(testSquare.Area, 144);
        }
Ejemplo n.º 6
0
        public void TestRectanglePerimeter()
        {
            var testRectangle = new Quadrilateral(12, 15);

            /* Rectangle with dimensions of 12, 15 should always have an perimeter of 54
             * when rounded to 2 decimal places */
            Assert.AreEqual(testRectangle.Perimeter, 54);
        }
Ejemplo n.º 7
0
        public static double FindPerimetr(Quadrilateral item)
        {
            double ab = FindSideLength(item.Top1, item.Top2);
            double bc = FindSideLength(item.Top2, item.Top3);
            double cd = FindSideLength(item.Top3, item.Top4);
            double ad = FindSideLength(item.Top1, item.Top4);

            return(ab + bc + cd + ad);
        }
Ejemplo n.º 8
0
        private float GetBarcodeHeight(Quadrilateral predictedLocation)
        {
            var topLeft     = picker.ConvertPoint(predictedLocation.topLeft);
            var bottomLeft  = picker.ConvertPoint(predictedLocation.bottomLeft);
            var topRight    = picker.ConvertPoint(predictedLocation.topRight);
            var bottomRight = picker.ConvertPoint(predictedLocation.bottomRight);

            return((float)Math.Max(bottomLeft.Y - topLeft.Y, bottomRight.Y - topRight.Y));
        }
Ejemplo n.º 9
0
 public AppForm()
 {
     InitializeComponent();
     graphics            = panelMain.CreateGraphics();
     quadrilaterals      = new List <Quadrilateral>();
     quadrilateralToDraw = new Quadrilateral();
     isFigureChecked     = false;
     doubleClickCounter  = 0;
 }
Ejemplo n.º 10
0
 public void TestQuadCanComputePerimeter()
 {
     Quadrilateral myquad = new Quadrilateral();
     myquad.Top = 2;
     myquad.Right = 2;
     myquad.Left = 2;
     myquad.Bottom = 2;
     Assert.AreEqual(8, myquad.Perimeter());
 }
Ejemplo n.º 11
0
        public Quadrilateral <Vector2> GetCoordinates(Point32 sheetSize)
        {
            var width  = (float)sheetSize.X;
            var height = (float)sheetSize.Y;

            return(Quadrilateral.Create(
                       new Vector2(x0 / width, y0 / height),
                       new Vector2(x1 / width, y1 / height)));
        }
Ejemplo n.º 12
0
 public void TestQuadPerimetersAreTheSame()
 {
     Quadrilateral myquad1 = new Quadrilateral();
     myquad1.Top = 2;
     myquad1.Right = 2;
     myquad1.Left = 2;
     myquad1.Bottom = 2;
     Quadrilateral myquad2 = new Quadrilateral(2, 2, 2, 2);
     Assert.AreEqual(myquad1.Perimeter(), myquad2.Perimeter());
 }
Ejemplo n.º 13
0
        public void QuadScalingUpTest()
        {
            Quadrilateral myquad = new Quadrilateral(2, 2, 2, 2);

            myquad.Scale(50);
            Assert.AreEqual(3, myquad.Top);
            Assert.AreEqual(3, myquad.Bottom);
            Assert.AreEqual(3, myquad.Left);
            Assert.AreEqual(3, myquad.Right);
        }
        // We want to show the bubble overlay only if the barcode takes >= 10% of the screen width.
        public bool IsBarcodeLargeEnoughForBubble(Quadrilateral barcodeLocation)
        {
            float topRightX    = barcodeLocation.TopRight.X;
            float topLeftX     = barcodeLocation.TopLeft.X;
            float bottomRightX = barcodeLocation.BottomRight.X;
            float bottomLeftX  = barcodeLocation.BottomLeft.X;
            float avgWidth     = ((topRightX - bottomLeftX) + (bottomRightX - topLeftX)) / 2;

            return((avgWidth / displayWidth) >= ScreenPercentageWidthRequired);
        }
Ejemplo n.º 15
0
        public void TestQuadCanComputeArea()
        {
            Quadrilateral myquad = new Quadrilateral();

            myquad.Top    = 3;
            myquad.Right  = 3;
            myquad.Left   = 3;
            myquad.Bottom = 3;
            Assert.AreEqual(9, myquad.Area());
        }
Ejemplo n.º 16
0
        public void TestRectangleDimensions()
        {
            var testRectangle = new Quadrilateral(12, 15);

            /* Quadrilateral Height and Width should equal constructor params
             * and not each other */
            Assert.AreNotEqual(testRectangle.Height, testRectangle.Width);
            Assert.AreEqual(testRectangle.Height, 12);
            Assert.AreEqual(testRectangle.Width, 15);
        }
Ejemplo n.º 17
0
 public void TestQuadScalingDownTest()
 {
     //negative scaling
     Quadrilateral myquad = new Quadrilateral(10, 10, 10, 10);
     myquad.Scale(-50);
     Assert.AreEqual(5, myquad.Top);
     Assert.AreEqual(5, myquad.Bottom);
     Assert.AreEqual(5, myquad.Left);
     Assert.AreEqual(5, myquad.Right);
 }
Ejemplo n.º 18
0
        private static Geometry <EntityVertex> Roof(out Vec3 tag)
        {
            var trapezoid = Quadrilateral <EntityVertex> .Trapezoid(20f, 1f, 0f, 1f);

            tag = trapezoid.Vertices.Furthest(Dir3D.Down).Furthest(Dir3D.Right).Single().position;
            var leftPane  = trapezoid.Extrude(30f).RotateZ(MathHelper.PiOver4);
            var rightPane = leftPane.ReflectX();

            return(Composite.Create(Stacking.StackRight(leftPane, rightPane)));
        }
Ejemplo n.º 19
0
        public void TestQuadrilateralCanComputePerimeter()
        {
            Quadrilateral myQuadrilateral = new Quadrilateral();

            myQuadrilateral.Top    = 2;
            myQuadrilateral.Right  = 4;
            myQuadrilateral.Bottom = 99;
            myQuadrilateral.Left   = 6;
            Assert.AreEqual(myQuadrilateral.Perimeter(), 111);
        }
Ejemplo n.º 20
0
        // Demonstration of theorem "Median of a trapezoid is half the sum of the bases"

        /*
         *         D_______E
         *         /       \
         * L______/M________\N
         *       /           \
         *      /_____________\
         *     A               B
         */

        public Page174Theorem416_2(bool onoff, bool complete)
            : base(onoff, complete)
        {
            problemName = "Page 174 Theorem 4-16 Part 2";


            Point a = new Point("A", 0, 0); points.Add(a);
            Point b = new Point("B", 10, 0); points.Add(b);
            Point c = new Point("C", 8, 4); points.Add(c);
            Point d = new Point("D", 2, 4); points.Add(d);

            Point l = new Point("L", -7, 2); points.Add(l);
            Point m = new Point("M", 1, 2); points.Add(m);
            Point n = new Point("N", 9, 2); points.Add(n);

            Segment ab = new Segment(a, b); segments.Add(ab);
            Segment cd = new Segment(c, d); segments.Add(cd);

            List <Point> pts = new List <Point>();

            pts.Add(a);
            pts.Add(m);
            pts.Add(d);
            collinear.Add(new Collinear(pts));

            pts = new List <Point>();
            pts.Add(b);
            pts.Add(n);
            pts.Add(c);
            collinear.Add(new Collinear(pts));

            pts = new List <Point>();
            pts.Add(l);
            pts.Add(m);
            pts.Add(n);
            collinear.Add(new Collinear(pts));

            parser = new LiveGeometry.TutorParser.HardCodedParserMain(points, collinear, segments, circles, onoff);

            Segment       ad   = (Segment)parser.Get(new Segment(a, d));
            Segment       bc   = (Segment)parser.Get(new Segment(b, c));
            Segment       ln   = (Segment)parser.Get(new Segment(l, n));
            Quadrilateral quad = (Quadrilateral)parser.Get(new Quadrilateral(ad, bc, cd, ab));
            Addition      sum  = new Addition(ab, cd);

            //If segment MN is the median of the trapezoid, and segment LN is congruent to the sum of AB and CD, then
            //segment AD must bisect segment LN

            given.Add(new Strengthened(quad, new Trapezoid(quad)));
            given.Add(new SegmentBisector(parser.GetIntersection(ln, ad), ln));
            given.Add(new SegmentBisector(parser.GetIntersection(ln, bc), ln));
            given.Add(new GeometricSegmentEquation(ln, sum));

            goals.Add(new SegmentBisector(parser.GetIntersection(ad, ln), ad));
        }
Ejemplo n.º 21
0
        public WpfkProb2(bool onoff, bool complete)
            : base(onoff, complete)
        {
            double r = System.Math.Sqrt(13);

            Point a = new Point("A", 0, r); points.Add(a);
            Point b = new Point("B", 0, 2); points.Add(b);
            Point c = new Point("C", 0, 0); points.Add(c);
            Point d = new Point("D", 3, 0); points.Add(d);
            Point e = new Point("E", r, 0); points.Add(e);
            Point f = new Point("F", 3, 2); points.Add(f);

            Segment bf = new Segment(b, f); segments.Add(bf);
            Segment fd = new Segment(f, d); segments.Add(fd);
            Segment cf = new Segment(c, f); segments.Add(cf);

            List <Point> pnts = new List <Point>();

            pnts.Add(c);
            pnts.Add(b);
            pnts.Add(a);
            collinear.Add(new Collinear(pnts));

            pnts = new List <Point>();
            pnts.Add(c);
            pnts.Add(d);
            pnts.Add(e);
            collinear.Add(new Collinear(pnts));

            circles.Add(new Circle(c, r));

            parser = new GeometryTutorLib.TutorParser.HardCodedParserMain(points, collinear, segments, circles, onoff);

            Quadrilateral quad = (Quadrilateral)parser.Get(new Quadrilateral(
                                                               (Segment)parser.Get(new Segment(b, c)), fd,
                                                               bf, (Segment)parser.Get(new Segment(c, d))));

            given.Add(new Strengthened(quad, new Rectangle(quad)));

            known.AddSegmentLength((Segment)parser.Get(new Segment(b, c)), 2);
            known.AddSegmentLength((Segment)parser.Get(new Segment(c, d)), 3);

            List <Point> wanted = new List <Point>();

            wanted.Add(new Point("", 1, 2.5));
            wanted.Add(new Point("", 3.2, 0.2));
            wanted.Add(new Point("", 2, ((2 - r) / 3.0) * 2 + r + 0.1));
            wanted.Add(new Point("", 3.3, 1.43));
            goalRegions = parser.implied.GetAtomicRegionsByPoints(wanted);

            SetSolutionArea(3.25 * System.Math.PI - 6);

            problemName = "Word Problems For Kids - Grade 11 Prob 2";
            GeometryTutorLib.EngineUIBridge.HardCodedProblemsToUI.AddProblem(problemName, points, circles, segments);
        }
Ejemplo n.º 22
0
        //
        // Polygons only.
        //
        public Page207(bool onoff, bool complete) : base(onoff, complete)
        {
            Point a = new Point("A", 0, 8);  points.Add(a);
            Point b = new Point("B", 8, 8);  points.Add(b);
            Point c = new Point("C", 8, 0);  points.Add(c);
            Point d = new Point("D", 0, 0);  points.Add(d);
            Point e = new Point("E", 3, 0);  points.Add(e);
            Point f = new Point("F", 5, 0);  points.Add(f);
            Point g = new Point("G", 5, 8);  points.Add(g);
            Point h = new Point("H", 3, 8);  points.Add(h);

            Segment ad = new Segment(a, d); segments.Add(ad);
            Segment bc = new Segment(b, c); segments.Add(bc);
            Segment he = new Segment(h, e); segments.Add(he);
            Segment fg = new Segment(f, g); segments.Add(fg);

            List <Point> pts = new List <Point>();

            pts.Add(a);
            pts.Add(h);
            pts.Add(g);
            pts.Add(b);
            collinear.Add(new Collinear(pts));

            pts = new List <Point>();
            pts.Add(d);
            pts.Add(e);
            pts.Add(f);
            pts.Add(c);
            collinear.Add(new Collinear(pts));

            parser = new LiveGeometry.TutorParser.HardCodedParserMain(points, collinear, segments, circles, onoff);

            Quadrilateral abcd = (Quadrilateral)parser.Get(new Quadrilateral(ad, bc, (Segment)parser.Get(new Segment(a, b)), (Segment)parser.Get(new Segment(c, d))));

            given.Add(new Strengthened(abcd, new Square(abcd)));

            Quadrilateral efgh = (Quadrilateral)parser.Get(new Quadrilateral(he, fg, (Segment)parser.Get(new Segment(g, h)), (Segment)parser.Get(new Segment(e, f))));

            given.Add(new Strengthened(efgh, new Rectangle(efgh)));

            known.AddSegmentLength((Segment)parser.Get(new Segment(a, g)), 5);
            known.AddSegmentLength((Segment)parser.Get(new Segment(e, c)), 5);
            known.AddSegmentLength(ad, 8);

            List <Point> wanted = new List <Point>();

            wanted.Add(new Point("", 4, 4));
            goalRegions = parser.implied.GetAtomicRegionsByPoints(wanted);

            SetSolutionArea(24);

            problemName = "Singapore Problem Page 207";
            GeometryTutorLib.EngineUIBridge.HardCodedProblemsToUI.AddProblem(problemName, points, circles, segments);
        }
Ejemplo n.º 23
0
        public Page3Prob25(bool onoff, bool complete)
            : base(onoff, complete)
        {
            Point a = new Point("A", 0, 0); points.Add(a);
            Point b = new Point("B", 0, 4); points.Add(b);
            Point c = new Point("C", 4, 4); points.Add(c);
            Point d = new Point("D", 4, 0); points.Add(d);
            Point p = new Point("P", 0, 2); points.Add(p);
            Point q = new Point("Q", 2, 4); points.Add(q);
            Point r = new Point("R", 4, 2); points.Add(r);
            Point s = new Point("S", 2, 0); points.Add(s);
            Point o = new Point("O", 2, 2); points.Add(o);

            List <Point> pts = new List <Point>();

            pts.Add(a);
            pts.Add(p);
            pts.Add(b);

            pts.Add(b);
            pts.Add(q);
            pts.Add(c);

            pts.Add(c);
            pts.Add(r);
            pts.Add(d);

            pts.Add(d);
            pts.Add(s);
            pts.Add(a);
            collinear.Add(new Collinear(pts));

            circles.Add(new Circle(p, 2.0));
            circles.Add(new Circle(q, 2.0));
            circles.Add(new Circle(r, 2.0));
            circles.Add(new Circle(s, 2.0));

            parser = new LiveGeometry.TutorParser.HardCodedParserMain(points, collinear, segments, circles, onoff);

            Quadrilateral quad = (Quadrilateral)parser.Get(new Quadrilateral((Segment)parser.Get(new Segment(a, b)), (Segment)parser.Get(new Segment(b, c)), (Segment)parser.Get(new Segment(c, d)), (Segment)parser.Get(new Segment(d, a))));

            given.Add(new Strengthened(quad, new Square(quad)));

            known.AddSegmentLength((Segment)parser.Get(new Segment(o, r)), 2);

            List <Point> wanted = new List <Point>();

            wanted.Add(new Point("", 3, 3));
            wanted.Add(new Point("", 1, 1));
            wanted.Add(new Point("", 1, 3));
            wanted.Add(new Point("", 3, 1));
            goalRegions = parser.implied.GetAtomicRegionsByPoints(wanted);

            SetSolutionArea(8 * System.Math.PI - 16);
        }
Ejemplo n.º 24
0
        public static double FindSquare(Quadrilateral item)
        {
            double p   = FindPerimetr(item) / 2;
            double ab  = FindSideLength(item.Top1, item.Top2);
            double bc  = FindSideLength(item.Top2, item.Top3);
            double cd  = FindSideLength(item.Top3, item.Top4);
            double ad  = FindSideLength(item.Top1, item.Top4);
            double sqr = Math.Sqrt((p - ab) * (p - bc) * (p - cd) * (p - ad));

            return(sqr);
        }
Ejemplo n.º 25
0
        public void AddPointTest()
        {
            Quadrilateral quadrilateral = new Quadrilateral();

            for (int i = 0; i < 3; i++)
            {
                Assert.AreEqual(true, quadrilateral.AddPoint(new Point(0, i)));
            }
            Assert.IsFalse(quadrilateral.IsCompleted());
            Assert.AreEqual(false, quadrilateral.AddPoint(new Point(0, 1234)));
            Assert.IsTrue(quadrilateral.IsCompleted());
        }
Ejemplo n.º 26
0
        public void CalculateStrengthening()
        {
            //
            // Can a quadrilateral be strenghtened? Quad -> trapezoid, Quad -> Parallelogram?, etc.
            //
            foreach (Quadrilateral quad in quadrilaterals)
            {
                strengthened.AddRange(Quadrilateral.CanBeStrengthened(quad));
            }

            //
            // Can a triangle be strenghtened? Scalene -> Isosceles -> Equilateral?
            //
            foreach (Triangle t in triangles)
            {
                strengthened.AddRange(Triangle.CanBeStrengthened(t));
            }

            //
            // Can an inMiddle relationship be classified as a Midpoint?
            //
            foreach (InMiddle im in inMiddles)
            {
                Strengthened s = im.CanBeStrengthened();
                if (s != null)
                {
                    strengthened.Add(s);
                }
            }

            //
            // Right Angles
            //
            foreach (Angle angle in angles)
            {
                if (Utilities.CompareValues(angle.measure, 90))
                {
                    strengthened.Add(new Strengthened(angle, new RightAngle(angle)));
                }
            }

            //
            // Dumping the Strengthening
            //
            if (Utilities.DEBUG)
            {
                System.Diagnostics.Debug.WriteLine("Precomputed Strengthening");
                foreach (ConcreteAST.Strengthened s in strengthened)
                {
                    System.Diagnostics.Debug.WriteLine(s.ToString());
                }
            }
        }
        public void AddPointTest()
        {
            var quadrilateral = new Quadrilateral();

            for (var i = 0; i < 3; i++)
            {
                Assert.Equal(true, quadrilateral.AddPoint(new Point(0, i)));
            }
            Assert.False(quadrilateral.IsCompleted());
            Assert.Equal(false, quadrilateral.AddPoint(new Point(0, 1234)));
            Assert.True(quadrilateral.IsCompleted());
        }
Ejemplo n.º 28
0
        private void CreateQuadrilateral()
        {
            List <Point> pointsOnImage = new List <Point>();

            foreach (Point point in Points)
            {
                //The stored points store the marker position on the window. For the quadrilateral the position on the image is needed.
                //This is why the points must be divided with the drawn height and width of the image.
                pointsOnImage.Add(new Point((point.X / _adjustedWidth) * Image.Width, (point.Y / _adjustedHeight) * Image.Height));
            }
            Quadrilateral = new Quadrilateral(pointsOnImage);
        }
Ejemplo n.º 29
0
        public void QuadScaleDownTest()
        {
            // Negative scaling
            // Likewise, 10 - 5 (50% of 10) = 5
            Quadrilateral myquad = new Quadrilateral(10, 10, 10, 10);

            myquad.Scale(-50);
            Assert.AreEqual(5, myquad.Top);
            Assert.AreEqual(5, myquad.Bottom);
            Assert.AreEqual(5, myquad.Left);
            Assert.AreEqual(5, myquad.Right);
        }
Ejemplo n.º 30
0
        private static Geometry <EntityVertex> WallsAndGables(Geometry <EntityVertex> roof,
                                                              Geometry <EntityVertex> gables, Vec3 roofSnapTag, Vec3 gableTopTag)
        {
            var walls = Quadrilateral <EntityVertex>
                        .Rectangle(gables.BoundingBox.Size.X, gables.BoundingBox.Size.Z)
                        .Extrude(12f, false).RotateX(MathHelper.PiOver2);

            var wallsAndGables = Composite.Create(Stacking.StackUp(walls, gables)
                                                  .Align(Alignment.Center, Alignment.None, Alignment.Center));

            return(wallsAndGables.SnapTo(gableTopTag, roofSnapTag, Axes.All));
        }
Ejemplo n.º 31
0
        public void TestMove()
        {
            Point tl, tr, br, bl, src, dst;
            Quadrilateral q;

            bl = new Point (1, 1);
            br = new Point (10, 4);
            tl = new Point (3, 20);
            tr = new Point (12, 15);
            q = new Quadrilateral (tl, tr, bl, br);

            src = new Point (4, 5);
            dst = new Point (7, 3);
            q.Move (SelectionPosition.All, dst, src);
            Assert.AreEqual (1 + 3, bl.X);
            Assert.AreEqual (10 + 3, br.X);
            Assert.AreEqual (3 + 3, tl.X);
            Assert.AreEqual (12 + 3, tr.X);

            Assert.AreEqual (1 - 2, bl.Y);
            Assert.AreEqual (4 - 2, br.Y);
            Assert.AreEqual (20 - 2, tl.Y);
            Assert.AreEqual (15 - 2, tr.Y);

            bl = new Point (1, 1);
            q.Move (SelectionPosition.BottomLeft, bl, null);
            Assert.AreEqual (bl, q.BottomLeft);
            br = new Point (10, 4);
            q.Move (SelectionPosition.BottomRight, br, null);
            Assert.AreEqual (br, q.BottomRight);
            tl = new Point (3, 20);
            q.Move (SelectionPosition.TopLeft, tl, null);
            Assert.AreEqual (tl, q.TopLeft);
            tr = new Point (12, 15);
            q.Move (SelectionPosition.TopRight, tr, null);
            Assert.AreEqual (tr, q.TopRight);
        }
Ejemplo n.º 32
0
        public void TestGetSelection()
        {
            Point tl, tr, br, bl;
            Quadrilateral q;
            Selection s;

            tl = new Point (1, 1);
            tr = new Point (10, 4);
            bl = new Point (3, 20);
            br = new Point (12, 15);
            q = new Quadrilateral (tl, tr, bl, br);

            s = q.GetSelection (bl, 1);
            Assert.AreEqual (SelectionPosition.BottomLeft, s.Position);
            s = q.GetSelection (br, 1);
            Assert.AreEqual (SelectionPosition.BottomRight, s.Position);
            s = q.GetSelection (tl, 1);
            Assert.AreEqual (SelectionPosition.TopLeft, s.Position);
            s = q.GetSelection (tr, 1);
            Assert.AreEqual (SelectionPosition.TopRight, s.Position);

            /* rectangle
             *  1,20   12,20
             *  1,1    12, 1
             */
            s = q.GetSelection (new Point (0, 1), 0.5);
            Assert.IsNull (s);
            s = q.GetSelection (new Point (1, 21), 0.5);
            Assert.IsNull (s);
            s = q.GetSelection (new Point (13, 5), 0.5);
            Assert.IsNull (s);
            s = q.GetSelection (new Point (4, 0), 0.5);
            Assert.IsNull (s);

            s = q.GetSelection (new Point (4, 5), 0);
            Assert.AreEqual (SelectionPosition.All, s.Position);
        }
Ejemplo n.º 33
0
        public void TestSerialization()
        {
            Point tl, tr, br, bl;
            Quadrilateral q, nq;

            bl = new Point (1, 1);
            br = new Point (10, 4);
            tl = new Point (3, 20);
            tr = new Point (12, 15);
            q = new Quadrilateral (tl, tr, bl, br);
            Utils.CheckSerialization (q);
            nq = Utils.SerializeDeserialize (q);
            Assert.AreEqual (q.BottomLeft, nq.BottomLeft);
            Assert.AreEqual (q.BottomRight, nq.BottomRight);
            Assert.AreEqual (q.TopLeft, nq.TopLeft);
            Assert.AreEqual (q.TopRight, nq.TopRight);
        }
Ejemplo n.º 34
0
        public void ResizeImage(string destination, string fileName, Quadrilateral quadrilateral, ImageFormat imageFormatOverride = null, CroppedDetails croppedDetails = null)
        {
            var imageFromFile = this.Image;

            if (croppedDetails != null)
            {
                var croppedTile = new Bitmap(croppedDetails.Width, croppedDetails.Height);

                croppedTile.SetResolution(this.Image.HorizontalResolution, this.Image.VerticalResolution);

                var croppedGraphic = Graphics.FromImage(croppedTile);

                var croppedArea = new Rectangle(croppedDetails.X1, croppedDetails.Y1, croppedDetails.Width, croppedDetails.Height);

                croppedGraphic.DrawImage(this.Image, 0, 0, croppedArea, GraphicsUnit.Pixel);

                imageFromFile = croppedTile;
            }

            var newImage = new Bitmap(quadrilateral.Width, quadrilateral.Height);

            newImage.SetResolution(imageFromFile.HorizontalResolution, imageFromFile.VerticalResolution);

            Graphics.FromImage(newImage)
                    .DrawImage(imageFromFile, 0, 0, quadrilateral.Width, quadrilateral.Height);

            if (imageFormatOverride == null)
            {
                var fileNameNew = string.Concat(destination, "//", fileName, this.Extension);
                newImage.Save(fileNameNew, this.ImageFormat);
            }
            else
            {
                var extension = this.ToExension(imageFormatOverride);
                var fileNameNew = string.Concat(destination, "//", fileName, extension);
                newImage.Save(fileNameNew, imageFormatOverride);
            }
        }
Ejemplo n.º 35
0
 /// <summary>
 ///   Initializes start and end pie slice sides.
 /// </summary>
 /// <param name="startSideExists">
 ///   Does start side exists.
 /// </param>
 /// <param name="endSideExists">
 ///   Does end side exists.
 /// </param>
 private void InitializeSides(bool startSideExists = true, bool endSideExists = true)
 {
     m_startSide = startSideExists
         ? new Quadrilateral(m_center, m_pointStart, m_pointStartBelow, m_centerBelow,
             Math.Abs(SweepAngle - 180) > float.Epsilon)
         : new Quadrilateral();
     m_endSide = endSideExists
         ? new Quadrilateral(m_center, m_pointEnd, m_pointEndBelow, m_centerBelow,
             Math.Abs(SweepAngle - 180) > float.Epsilon)
         : new Quadrilateral();
 }
Ejemplo n.º 36
0
 /// <summary>
 ///   Initializes start and end pie slice sides.
 /// </summary>
 private void InitializeSides()
 {
     if (StartAngle > 90 && StartAngle < 270)
         StartSide =
             new Quadrilateral(Center, PointStart, PointStartBelow, CenterBelow,
                               SweepAngle != 180);
     else
         StartSide = Quadrilateral.Empty;
     if (EndAngle > 270 || EndAngle < 90)
         EndSide = new Quadrilateral(Center, PointEnd, PointEndBelow, CenterBelow,
                                     SweepAngle != 180);
     else
         EndSide = Quadrilateral.Empty;
 }
Ejemplo n.º 37
0
        public void ScaleImage(string destination, string fileName, Quadrilateral quadrilateral, ImageFormat imageFormatOverride = null, CroppedDetails croppedDetails = null)
        {
            var newQuadrilateral = quadrilateral.Scale(this.Image.Width, this.Image.Height);

            this.ResizeImage(destination, fileName, newQuadrilateral, imageFormatOverride, croppedDetails);
        }
Ejemplo n.º 38
0
 /// <summary>
 ///   Initializes start and end pie slice sides.
 /// </summary>
 /// <param name="startSideExists">
 ///   Does start side exists.
 /// </param>
 /// <param name="endSideExists">
 ///   Does end side exists.
 /// </param>
 private void InitializeSides(bool startSideExists, bool endSideExists) {
     if (startSideExists)
         m_startSide = new Quadrilateral(m_center, m_pointStart, m_pointStartBelow, m_centerBelow, m_sweepAngle != 180);
     else
         m_startSide = Quadrilateral.Empty;
     if (endSideExists)
         m_endSide = new Quadrilateral(m_center, m_pointEnd, m_pointEndBelow, m_centerBelow, m_sweepAngle != 180);
     else
         m_endSide = Quadrilateral.Empty;
 }