EraserTool.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. using System.Windows.Media;
  2. using PixiEditor.Models.DataHolders;
  3. using PixiEditor.Models.Layers;
  4. using PixiEditor.Models.Position;
  5. using PixiEditor.Models.Tools.ToolSettings.Settings;
  6. using PixiEditor.Models.Tools.ToolSettings.Toolbars;
  7. namespace PixiEditor.Models.Tools.Tools
  8. {
  9. public class EraserTool : BitmapOperationTool
  10. {
  11. public override ToolType ToolType => ToolType.Eraser;
  12. public EraserTool()
  13. {
  14. Tooltip = "Erasers color from pixel (E)";
  15. Toolbar = new BasicToolbar();
  16. }
  17. public override LayerChange[] Use(Layer layer, Coordinates[] coordinates, Color color)
  18. {
  19. return Erase(layer, coordinates, Toolbar.GetSetting<SizeSetting>("ToolSize").Value);
  20. }
  21. public LayerChange[] Erase(Layer layer, Coordinates[] coordinates, int toolSize)
  22. {
  23. Coordinates startingCords = coordinates.Length > 1 ? coordinates[1] : coordinates[0];
  24. PenTool pen = new PenTool();
  25. var pixels = pen.Draw(startingCords, coordinates[0], System.Windows.Media.Colors.Transparent, toolSize);
  26. return new[] {new LayerChange(pixels, layer)};
  27. }
  28. }
  29. }