Files
Minint/Minint.Core/Models/MinintLayer.cs
2026-03-29 15:34:33 +03:00

43 lines
1.2 KiB
C#

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 string Name { get; set; }
public bool IsVisible { get; set; }
/// <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; }
/// <summary>
/// Palette indices, length must equal container Width * Height.
/// Index 0 = transparent by convention.
/// </summary>
public int[] Pixels { get; }
public MinintLayer(string name, int pixelCount)
{
Name = name;
IsVisible = true;
Opacity = 255;
Pixels = new int[pixelCount];
}
/// <summary>
/// Constructor for deserialization — accepts a pre-filled pixel buffer.
/// </summary>
public MinintLayer(string name, bool isVisible, byte opacity, int[] pixels)
{
Name = name;
IsVisible = isVisible;
Opacity = opacity;
Pixels = pixels;
}
}