ShapeData.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. using PixiEditor.DrawingApi.Core.ColorsImpl;
  2. using PixiEditor.DrawingApi.Core.Numerics;
  3. using PixiEditor.DrawingApi.Core.Surface;
  4. namespace ChunkyImageLib.DataHolders;
  5. public record struct ShapeData
  6. {
  7. public ShapeData(VecD center, VecD size, double rotation, int strokeWidth, Color strokeColor, Color fillColor, BlendMode blendMode = BlendMode.SrcOver)
  8. {
  9. StrokeColor = strokeColor;
  10. FillColor = fillColor;
  11. Center = center;
  12. Size = size;
  13. Angle = rotation;
  14. StrokeWidth = strokeWidth;
  15. BlendMode = blendMode;
  16. }
  17. public Color StrokeColor { get; }
  18. public Color FillColor { get; }
  19. public BlendMode BlendMode { get; }
  20. public VecD Center { get; }
  21. /// <summary>Can be negative to show flipping </summary>
  22. public VecD Size { get; }
  23. public double Angle { get; }
  24. public int StrokeWidth { get; }
  25. public ShapeData AsMirroredAcrossHorAxis(double horAxisY)
  26. => new ShapeData(Center.ReflectY(horAxisY), new(Size.X, -Size.Y), -Angle, StrokeWidth, StrokeColor, FillColor, BlendMode);
  27. public ShapeData AsMirroredAcrossVerAxis(double verAxisX)
  28. => new ShapeData(Center.ReflectX(verAxisX), new(-Size.X, Size.Y), -Angle, StrokeWidth, StrokeColor, FillColor, BlendMode);
  29. }