mirror of
https://github.com/riegera2412/UVtools.git
synced 2026-07-11 19:12:31 +02:00
5d61e95331
- **File formats:** - (Add) CXDLP v2 - (Improved) GR1, MDLP, CXDLP decode and encode performance and memory optimization - (Remove) CXDLP v1 from available formats - (Add) Pixel editor - Drawing: New brushes of shapes/polygons - (Upgrade) .NET from 5.0.6 to 5.0.7 - (Fix) When there are issues on the list, executing any operation will navigate to the last layer - (Fix) PrusaSlicer printer: Rename "Creality HALOT-SKY CL-60" to "Creality HALOT-ONE CL-60"
115 lines
3.6 KiB
C#
115 lines
3.6 KiB
C#
/*
|
|
* GNU AFFERO GENERAL PUBLIC LICENSE
|
|
* Version 3, 19 November 2007
|
|
* Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
* Everyone is permitted to copy and distribute verbatim copies
|
|
* of this license document, but changing it is not allowed.
|
|
*/
|
|
using System;
|
|
using System.Drawing;
|
|
using Emgu.CV.CvEnum;
|
|
|
|
namespace UVtools.Core.PixelEditor
|
|
{
|
|
public class PixelDrawing : PixelOperation
|
|
{
|
|
private BrushShapeType _brushShape = BrushShapeType.Square;
|
|
private ushort _brushSize = 1;
|
|
private short _thickness = -1;
|
|
private byte _removePixelBrightness;
|
|
private double _rotationAngle;
|
|
public const byte MinRectangleBrush = 1;
|
|
public const byte MinCircleBrush = 7;
|
|
public enum BrushShapeType : byte
|
|
{
|
|
//Mask = 0,
|
|
Line = 1,
|
|
Triangle = 3,
|
|
Square = 4,
|
|
Pentagon = 5,
|
|
Hexagon = 6,
|
|
Heptagon = 7,
|
|
Octagon = 8,
|
|
Nonagon = 9,
|
|
Decagon = 10,
|
|
Hendecagon = 11,
|
|
Dodecagon = 12,
|
|
Circle = 100,
|
|
}
|
|
|
|
public override PixelOperationType OperationType => PixelOperationType.Drawing;
|
|
|
|
public static BrushShapeType[] BrushShapeTypes => (BrushShapeType[])Enum.GetValues(typeof(BrushShapeType));
|
|
|
|
public BrushShapeType BrushShape
|
|
{
|
|
get => _brushShape;
|
|
set
|
|
{
|
|
if (!RaiseAndSetIfChanged(ref _brushShape, value)) return;
|
|
if (_brushShape == BrushShapeType.Circle)
|
|
{
|
|
BrushSize = Math.Max(MinCircleBrush, BrushSize);
|
|
}
|
|
}
|
|
}
|
|
|
|
public double RotationAngle
|
|
{
|
|
get => _rotationAngle;
|
|
set => RaiseAndSetIfChanged(ref _rotationAngle, Math.Round(value, 2));
|
|
}
|
|
|
|
public ushort BrushSize
|
|
{
|
|
get => _brushSize;
|
|
set => RaiseAndSetIfChanged(ref _brushSize, value);
|
|
}
|
|
|
|
public short Thickness
|
|
{
|
|
get => _thickness;
|
|
set => RaiseAndSetIfChanged(ref _thickness, value);
|
|
}
|
|
|
|
public byte RemovePixelBrightness
|
|
{
|
|
get => _removePixelBrightness;
|
|
set
|
|
{
|
|
if (!RaiseAndSetIfChanged(ref _removePixelBrightness, value)) return;
|
|
RaisePropertyChanged(nameof(RemovePixelBrightnessPercent));
|
|
}
|
|
}
|
|
|
|
public decimal RemovePixelBrightnessPercent => Math.Round(_removePixelBrightness * 100M / 255M, 2);
|
|
|
|
public bool IsAdd { get; }
|
|
|
|
public byte Brightness => IsAdd ? _pixelBrightness : _removePixelBrightness;
|
|
|
|
public Rectangle Rectangle { get; }
|
|
|
|
public PixelDrawing()
|
|
{
|
|
|
|
}
|
|
|
|
public PixelDrawing(uint layerIndex, Point location, LineType lineType, BrushShapeType brushShape, double rotationAngle, ushort brushSize, short thickness, byte removePixelBrightness, byte pixelBrightness, bool isAdd) : base(layerIndex, location, lineType, pixelBrightness)
|
|
{
|
|
_brushShape = brushShape;
|
|
_rotationAngle = rotationAngle;
|
|
_brushSize = brushSize;
|
|
_thickness = thickness;
|
|
_removePixelBrightness = removePixelBrightness;
|
|
IsAdd = isAdd;
|
|
|
|
int shiftPos = brushSize / 2;
|
|
Rectangle = new Rectangle(Math.Max(0, location.X - shiftPos), Math.Max(0, location.Y - shiftPos), brushSize-1, brushSize-1);
|
|
Size = new Size(BrushSize, BrushSize);
|
|
}
|
|
|
|
|
|
}
|
|
}
|