Этап 8

This commit is contained in:
2026-03-29 16:51:43 +03:00
parent 25e30416a3
commit c3961fcba7
5 changed files with 452 additions and 34 deletions

View File

@@ -1,19 +1,39 @@
using System.ComponentModel;
using System.Runtime.CompilerServices;
namespace Minint.Core.Models;
/// <summary>
/// A single raster layer. Pixels are indices into the parent document's palette.
/// Array layout is row-major: Pixels[y * width + x].
/// </summary>
public sealed class MinintLayer
public sealed class MinintLayer : INotifyPropertyChanged
{
public string Name { get; set; }
public bool IsVisible { get; set; }
private string _name;
private bool _isVisible;
private byte _opacity;
public string Name
{
get => _name;
set { if (_name != value) { _name = value; Notify(); } }
}
public bool IsVisible
{
get => _isVisible;
set { if (_isVisible != value) { _isVisible = value; Notify(); } }
}
/// <summary>
/// Per-layer opacity (0 = fully transparent, 255 = fully opaque).
/// Used during compositing: effective alpha = paletteColor.A * Opacity / 255.
/// </summary>
public byte Opacity { get; set; }
public byte Opacity
{
get => _opacity;
set { if (_opacity != value) { _opacity = value; Notify(); } }
}
/// <summary>
/// Palette indices, length must equal container Width * Height.
@@ -23,9 +43,9 @@ public sealed class MinintLayer
public MinintLayer(string name, int pixelCount)
{
Name = name;
IsVisible = true;
Opacity = 255;
_name = name;
_isVisible = true;
_opacity = 255;
Pixels = new int[pixelCount];
}
@@ -34,9 +54,13 @@ public sealed class MinintLayer
/// </summary>
public MinintLayer(string name, bool isVisible, byte opacity, int[] pixels)
{
Name = name;
IsVisible = isVisible;
Opacity = opacity;
_name = name;
_isVisible = isVisible;
_opacity = opacity;
Pixels = pixels;
}
public event PropertyChangedEventHandler? PropertyChanged;
private void Notify([CallerMemberName] string? prop = null)
=> PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(prop));
}