Esempio n. 1
0
        private Shape CreateRectangle(ShapeArgumentsHandler argsHandler)
        {
            if (argsHandler.ArgumentsLeft < 4)
            {
                throw new ArgumentException("Invalid number of arguments to create rectangle", "rectangleArgs");
            }

            var leftTop     = new Point(argsHandler.GetNextFloatArg(), argsHandler.GetNextFloatArg());
            var rightBottom = new Point(argsHandler.GetNextFloatArg(), argsHandler.GetNextFloatArg());
            var color       = argsHandler.ShapeColor;

            return(new Rectangle(leftTop, rightBottom, color));
        }
Esempio n. 2
0
        Shape CreateRegularPolygon(ShapeArgumentsHandler argsHandler)
        {
            if (argsHandler.ArgumentsLeft < 4)
            {
                throw new ArgumentException("Invalid number of arguments to create polygon", "polygonArgs");
            }

            var vertexCount = argsHandler.GetNextIntArg();
            var center      = new Point(argsHandler.GetNextFloatArg(), argsHandler.GetNextFloatArg());
            var radius      = argsHandler.GetNextFloatArg();
            var color       = argsHandler.ShapeColor;

            return(new RegularPolygon(vertexCount, center, radius, color));
        }
Esempio n. 3
0
        Shape CreateEllipse(ShapeArgumentsHandler argsHandler)
        {
            if (argsHandler.ArgumentsLeft < 4)
            {
                throw new ArgumentException("Invalid number of arguments to create ellipse", "ellipseArgs");
            }

            var center           = new Point(argsHandler.GetNextFloatArg(), argsHandler.GetNextFloatArg());
            var horizontalRadius = argsHandler.GetNextFloatArg();
            var verticalRadius   = argsHandler.GetNextFloatArg();
            var color            = argsHandler.ShapeColor;

            return(new Ellipse(center, horizontalRadius, verticalRadius, color));
        }
Esempio n. 4
0
        Shape CreateTriangle(ShapeArgumentsHandler argsHandler)
        {
            if (argsHandler.ArgumentsLeft < 6)
            {
                throw new ArgumentException("Invalid number of arguments to create triangle", "triangleArgs");
            }

            var v1    = new Point(argsHandler.GetNextFloatArg(), argsHandler.GetNextFloatArg());
            var v2    = new Point(argsHandler.GetNextFloatArg(), argsHandler.GetNextFloatArg());
            var v3    = new Point(argsHandler.GetNextFloatArg(), argsHandler.GetNextFloatArg());
            var color = argsHandler.ShapeColor;

            return(new Triangle(v1, v2, v3, color));
        }