diff --git a/Shapes/ShapeGenerator.cs b/Shapes/ShapeGenerator.cs index 50494c6..0a7664d 100644 --- a/Shapes/ShapeGenerator.cs +++ b/Shapes/ShapeGenerator.cs @@ -1,5 +1,7 @@ using System.Diagnostics; +using System.Numerics; using Avalonia; +using Avalonia.Media; using Shapes.Shapes; namespace Shapes; @@ -15,6 +17,18 @@ public sealed class ShapeGenerator private readonly double _maxY; private readonly Random _random; private int _nextShape; + + private static readonly IBrush[] colors = + { + Brushes.Blue, + Brushes.Cyan, + Brushes.DarkGreen, + Brushes.Firebrick, + Brushes.Lime, + Brushes.Orange, + Brushes.Plum, + Brushes.Yellow + }; /// /// Creates a new generator which will create random shapes within the canvas area @@ -45,10 +59,20 @@ public sealed class ShapeGenerator { _nextShape = MinShapeIdx; } + + var randomSize = new Point(_random.NextDouble() * _maxX, _random.NextDouble() * _maxY); + var randomThickness = _random.NextDouble() * 3 + 1; + var randomColor = colors[_random.Next(colors.Length)]; + + Shape generatedShape = shape switch + { + 1 => new Circle(atLocation, randomSize, randomThickness, randomColor, randomColor), + 2 => new Rectangle(atLocation, randomSize, randomThickness, randomColor, randomColor), + 3 => new Square(atLocation, randomSize, randomThickness, randomColor, randomColor), + 4 => new Triangle(atLocation, randomSize, randomThickness, randomColor, randomColor), + _ => new Square(atLocation, randomSize, randomThickness, randomColor, randomColor) + }; - // TODO - return null!; + return generatedShape; } - - // TODO -} +} \ No newline at end of file