Esempio n. 1
0
        /// <summary>
        /// Configured desired shapes in the cartesian plane
        /// </summary>
        /// <returns></returns>
        private CartesianPlane CreateNewCartesianPlaneOn60X60GridWithIsoscelesRightTriangles()
        {
            int maxX = 60;
            int maxY = 60;
            int nonHypotenuseSideLengthInPixels = 10;

            var strategyProperties = new IsoscelesTriangleCreatorStrategyProperties();

            strategyProperties.NonHypotenuseSideLengthInPixels = nonHypotenuseSideLengthInPixels;
            strategyProperties.GridMaxXCoordinateInPixels      = maxX;
            strategyProperties.GridMaxYCoordinateInPixels      = maxY;
            strategyProperties.IncreaseCountOn = IsoscelesTriangleCreatorStrategyProperties.IncreaseCountOns
                                                 .IncreaseCountOnRightTriangle;
            strategyProperties.TriangleHypotenusePosition = IsoscelesTriangleCreatorStrategyProperties
                                                            .TriangleHypotenusePositions.BackslashHypotenuse;
            strategyProperties.StartRowOption =
                IsoscelesTriangleCreatorStrategyProperties.StartRowOptions.StartRowAtMaxY;

            var strategy = new IsoscelesTriangleCreatorStrategy(strategyProperties);

            var plane = new CartesianPlane(maxX, maxY);

            plane.AddShapes(strategy.GenerateShapes());
            return(plane);
        }
Esempio n. 2
0
 public void Constructor_ThrowsNotSupportedException_WhenMaxXOrMaxYAreNegatives(int maxXCoordinate,
                                                                                int maxYCoordinate)
 {
     Assert.Throws <NotSupportedException>(() =>
     {
         var plane = new CartesianPlane(maxXCoordinate, maxYCoordinate);                 //should throw exception
     });
 }
    void Awake()
    {
        SharedPlane     = this;
        origin          = transform;
        originLineIndex = (numGridLines - 1) / 2;

        gridCanvas   = GameObject.Find("Grid Canvas").GetComponent <Canvas>();
        gridMaterial = Instantiate(Resources.Load("Materials/Grid") as Material);
        gridTexture  = Resources.Load("Textures/ThinLine") as Texture;
    }
Esempio n. 4
0
        public void AddShapes_ExecutesSuccessfully(int shapesCount)
        {
            var plane  = new CartesianPlane(10, 10);
            var shapes = new List <Shape>();

            for (int i = 0; i < shapesCount; i++)
            {
                shapes.Add(new Shape(new List <Coordinate> {
                    new Coordinate(i, i)
                }, $"A{i}"));
            }
            plane.AddShapes(shapes);
            plane.ShapesCount.Should().Be(shapesCount);
        }
        /// <summary>
        /// Adds <see href="http://en.wikipedia.org/wiki/Cartesian_coordinate_system">
        /// Cartesian Plane</see> to shape collection
        /// </summary>
        /// <param name="region">region of the arc</param>
        /// <param name="penColor">Color of the pen</param>
        /// <param name="fillColor">Fill color</param>
        /// <param name="penWidth">Width of the pen</param>
        public void AddCartesianPlane(Region region, Color penColor, Color fillColor, float penWidth)
        {
            region.FixSize(MinimumSize);
            this.DeSelect();

            CartesianPlane corPlane = new CartesianPlane();

            corPlane.Region    = region;
            corPlane.PenColor  = penColor;
            corPlane.PenWidth  = penWidth;
            corPlane.FillColor = fillColor;

            this.shapes.Add(corPlane);
            StoreInBuffer(BufferOperation.Insert, corPlane);
            handlerCol           = new ShapeHandlerCollection(corPlane);
            this.selectedElement = corPlane;
            this.selectedElement.Select();
        }