RectangleTool.cs 907 B

123456789101112131415161718192021222324
  1. using PixiEditor.Models.Layers;
  2. using PixiEditor.Models.Position;
  3. using System.Windows.Media;
  4. using System.Windows.Media.Imaging;
  5. namespace PixiEditor.Models.Tools.Tools
  6. {
  7. public class RectangleTool : ShapeTool
  8. {
  9. public override ToolType ToolType => ToolType.Rectangle;
  10. public override BitmapPixelChanges Use(Layer layer, Coordinates[] coordinates, Color color, int toolSize)
  11. {
  12. CreateRectangle(layer,coordinates[0], color, toolSize);
  13. return new BitmapPixelChanges();
  14. }
  15. public void CreateRectangle(Layer layer, Coordinates startingCoords, Color color, int toolSize)
  16. {
  17. DoubleCords coordinates = CalculateCoordinatesForShapeRotation(startingCoords);
  18. layer.LayerBitmap.DrawRectangle(coordinates.Coords1.X, coordinates.Coords1.Y, coordinates.Coords2.X, coordinates.Coords2.Y, color);
  19. }
  20. }
  21. }