// Copyright (c) Six Labors. // Licensed under the Six Labors Split License. namespace SixLabors.Fonts.Tables.General.Colr { /// /// Abstract base class for all COLR v1 paint table nodes in the paint DAG. /// /// internal abstract class Paint { /// /// Gets the paint format number identifying the type of this paint node. /// public byte Format { get; init; } } /// /// Represents a COLR v1 PaintColrLayers (format 1), which references a contiguous range of paint /// layers in the LayerList to compose a multi-layer color glyph. /// /// internal sealed class PaintColrLayers : Paint { /// /// Gets the number of layers to compose. /// public byte NumLayers { get; init; } /// /// Gets the index of the first paint in the LayerList. /// public uint FirstLayerIndex { get; init; } } /// /// Represents a COLR v1 PaintSolid (format 2), which fills with a solid color from the CPAL palette. /// /// internal sealed class PaintSolid : Paint { /// /// Gets the CPAL palette entry index. A value of 0xFFFF indicates the foreground color. /// public ushort PaletteIndex { get; init; } /// /// Gets the alpha value as an F2DOT14 number. /// public float Alpha { get; init; } } /// /// Represents a COLR v1 PaintVarSolid (format 3), a variation-aware solid color fill. /// /// internal sealed class PaintVarSolid : Paint { /// /// Gets the CPAL palette entry index. A value of 0xFFFF indicates the foreground color. /// public ushort PaletteIndex { get; init; } /// /// Gets the alpha value as an F2DOT14 number (varied via VarIndexBase + 0). /// public float Alpha { get; init; } /// /// Gets the base index into the ItemVariationStore delta sets. /// public uint VarIndexBase { get; init; } } /// /// Represents a COLR v1 PaintLinearGradient (format 4), which fills with a linear gradient /// defined by three points and a color line. /// /// internal sealed class PaintLinearGradient : Paint { /// /// Gets the color line defining the gradient stops and extend mode. /// public required ColorLine ColorLine { get; init; } /// /// Gets the x-coordinate of the first gradient point (FWORD). /// public short X0 { get; init; } /// /// Gets the y-coordinate of the first gradient point (FWORD). /// public short Y0 { get; init; } /// /// Gets the x-coordinate of the second gradient point (FWORD). /// public short X1 { get; init; } /// /// Gets the y-coordinate of the second gradient point (FWORD). /// public short Y1 { get; init; } /// /// Gets the x-coordinate of the rotation point (FWORD). /// public short X2 { get; init; } /// /// Gets the y-coordinate of the rotation point (FWORD). /// public short Y2 { get; init; } } /// /// Represents a COLR v1 PaintVarLinearGradient (format 5), a variation-aware linear gradient. /// /// internal sealed class PaintVarLinearGradient : Paint { /// /// Gets the variable color line defining the gradient stops and extend mode. /// public required VarColorLine ColorLine { get; init; } /// /// Gets the x-coordinate of the first gradient point (FWORD, var +0). /// public short X0 { get; init; } /// /// Gets the y-coordinate of the first gradient point (FWORD, var +1). /// public short Y0 { get; init; } /// /// Gets the x-coordinate of the second gradient point (FWORD, var +2). /// public short X1 { get; init; } /// /// Gets the y-coordinate of the second gradient point (FWORD, var +3). /// public short Y1 { get; init; } /// /// Gets the x-coordinate of the rotation point (FWORD, var +4). /// public short X2 { get; init; } /// /// Gets the y-coordinate of the rotation point (FWORD, var +5). /// public short Y2 { get; init; } /// /// Gets the base index into the ItemVariationStore delta sets. /// public uint VarIndexBase { get; init; } } /// /// Represents a COLR v1 PaintRadialGradient (format 6), which fills with a radial gradient /// defined by two circles and a color line. /// /// internal sealed class PaintRadialGradient : Paint { /// /// Gets the color line defining the gradient stops and extend mode. /// public required ColorLine ColorLine { get; init; } /// /// Gets the x-coordinate of the first circle center (FWORD). /// public short X0 { get; init; } /// /// Gets the y-coordinate of the first circle center (FWORD). /// public short Y0 { get; init; } /// /// Gets the radius of the first circle (UFWORD). /// public ushort Radius0 { get; init; } /// /// Gets the x-coordinate of the second circle center (FWORD). /// public short X1 { get; init; } /// /// Gets the y-coordinate of the second circle center (FWORD). /// public short Y1 { get; init; } /// /// Gets the radius of the second circle (UFWORD). /// public ushort Radius1 { get; init; } } /// /// Represents a COLR v1 PaintVarRadialGradient (format 7), a variation-aware radial gradient. /// /// internal sealed class PaintVarRadialGradient : Paint { /// /// Gets the variable color line defining the gradient stops and extend mode. /// public required VarColorLine ColorLine { get; init; } /// /// Gets the x-coordinate of the first circle center (FWORD, var +0). /// public short X0 { get; init; } /// /// Gets the y-coordinate of the first circle center (FWORD, var +1). /// public short Y0 { get; init; } /// /// Gets the radius of the first circle (UFWORD, var +2). /// public ushort Radius0 { get; init; } /// /// Gets the x-coordinate of the second circle center (FWORD, var +3). /// public short X1 { get; init; } /// /// Gets the y-coordinate of the second circle center (FWORD, var +4). /// public short Y1 { get; init; } /// /// Gets the radius of the second circle (UFWORD, var +5). /// public ushort Radius1 { get; init; } /// /// Gets the base index into the ItemVariationStore delta sets. /// public uint VarIndexBase { get; init; } } /// /// Represents a COLR v1 PaintSweepGradient (format 8), which fills with a sweep (conical) gradient /// around a center point between start and end angles. /// /// internal sealed class PaintSweepGradient : Paint { /// /// Gets the color line defining the gradient stops and extend mode. /// public required ColorLine ColorLine { get; init; } /// /// Gets the x-coordinate of the sweep center (FWORD). /// public short CenterX { get; init; } /// /// Gets the y-coordinate of the sweep center (FWORD). /// public short CenterY { get; init; } /// /// Gets the start angle as an F2DOT14 value with bias per spec. /// public float StartAngle { get; init; } /// /// Gets the end angle as an F2DOT14 value with bias per spec. /// public float EndAngle { get; init; } } /// /// Represents a COLR v1 PaintVarSweepGradient (format 9), a variation-aware sweep gradient. /// /// internal sealed class PaintVarSweepGradient : Paint { /// /// Gets the variable color line defining the gradient stops and extend mode. /// public required VarColorLine ColorLine { get; init; } /// /// Gets the x-coordinate of the sweep center (FWORD, var +0). /// public short CenterX { get; init; } /// /// Gets the y-coordinate of the sweep center (FWORD, var +1). /// public short CenterY { get; init; } /// /// Gets the start angle as an F2DOT14 value (var +2). /// public float StartAngle { get; init; } /// /// Gets the end angle as an F2DOT14 value (var +3). /// public float EndAngle { get; init; } /// /// Gets the base index into the ItemVariationStore delta sets. /// public uint VarIndexBase { get; init; } } /// /// Represents a COLR v1 PaintGlyph (format 10), which binds a glyph outline to a child paint node. /// The glyph outline serves as a clip path for the child paint. /// /// internal sealed class PaintGlyph : Paint { /// /// Gets the child paint node that fills the glyph outline. /// public required Paint Child { get; init; } /// /// Gets the glyph ID whose outline is used as the clip path. /// public ushort GlyphId { get; init; } } /// /// Represents a COLR v1 PaintColrGlyph (format 11), which references another glyph's root paint /// from the BaseGlyphList, allowing reuse of color glyph definitions. /// /// internal sealed class PaintColrGlyph : Paint { /// /// Gets the glyph ID whose root paint in the BaseGlyphList is referenced. /// public ushort GlyphId { get; init; } } /// /// Represents a COLR v1 PaintTransform (format 12), which applies an affine transformation to its child paint. /// /// internal sealed class PaintTransform : Paint { /// /// Gets the child paint node to transform. /// public required Paint Child { get; init; } /// /// Gets the 2x3 affine transformation matrix. /// public Affine2x3 Transform { get; init; } } /// /// Represents a COLR v1 PaintVarTransform (format 13), a variation-aware affine transformation. /// /// internal sealed class PaintVarTransform : Paint { /// /// Gets the child paint node to transform. /// public required Paint Child { get; init; } /// /// Gets the variation-aware 2x3 affine transformation matrix. /// public VarAffine2x3 Transform { get; init; } } /// /// Represents a COLR v1 PaintTranslate (format 14), which translates its child paint by a fixed offset. /// /// internal sealed class PaintTranslate : Paint { /// /// Gets the child paint node to translate. /// public required Paint Child { get; init; } /// /// Gets the x-axis translation (FWORD). /// public short Dx { get; init; } /// /// Gets the y-axis translation (FWORD). /// public short Dy { get; init; } } /// /// Represents a COLR v1 PaintVarTranslate (format 15), a variation-aware translation. /// /// internal sealed class PaintVarTranslate : Paint { /// /// Gets the child paint node to translate. /// public required Paint Child { get; init; } /// /// Gets the x-axis translation (FWORD, var +0). /// public short Dx { get; init; } /// /// Gets the y-axis translation (FWORD, var +1). /// public short Dy { get; init; } /// /// Gets the base index into the ItemVariationStore delta sets. /// public uint VarIndexBase { get; init; } } /// /// Represents COLR v1 scale paint operations (formats 16, 18, 20, 22), which apply a scale /// transformation to their child paint. Supports uniform/anisotropic and around-center variants. /// /// internal sealed class PaintScale : Paint { /// /// Gets the child paint node to scale. /// public required Paint Child { get; init; } /// /// Gets the x-axis scale factor (F2DOT14). /// public float ScaleX { get; init; } /// /// Gets the y-axis scale factor (F2DOT14). Equal to ScaleX for uniform scale formats. /// public float ScaleY { get; init; } /// /// Gets the x-coordinate of the scale center (FWORD). Zero if not an "around center" format. /// public short CenterX { get; init; } /// /// Gets the y-coordinate of the scale center (FWORD). Zero if not an "around center" format. /// public short CenterY { get; init; } /// /// Gets a value indicating whether this is an "around center" scale format. /// public bool AroundCenter { get; init; } /// /// Gets a value indicating whether this is a uniform (isotropic) scale. /// public bool Uniform { get; init; } } /// /// Represents COLR v1 variation-aware scale paint operations (formats 17, 19, 21, 23). /// /// internal sealed class PaintVarScale : Paint { /// /// Gets the child paint node to scale. /// public required Paint Child { get; init; } /// /// Gets the x-axis scale factor (var +0). /// public float ScaleX { get; init; } /// /// Gets the y-axis scale factor (var +1). Equal to ScaleX for uniform scale formats. /// public float ScaleY { get; init; } /// /// Gets the x-coordinate of the scale center (var +2 if around center). /// public short CenterX { get; init; } /// /// Gets the y-coordinate of the scale center (var +3 if around center). /// public short CenterY { get; init; } /// /// Gets a value indicating whether this is an "around center" scale format. /// public bool AroundCenter { get; init; } /// /// Gets a value indicating whether this is a uniform (isotropic) scale. /// public bool Uniform { get; init; } /// /// Gets the base index into the ItemVariationStore delta sets. /// public uint VarIndexBase { get; init; } } /// /// Represents COLR v1 rotate paint operations (formats 24, 26), which apply a rotation /// to their child paint, optionally around a specified center point. /// /// internal sealed class PaintRotate : Paint { /// /// Gets the child paint node to rotate. /// public required Paint Child { get; init; } /// /// Gets the rotation angle as an F2DOT14 value (1.0 = 180 degrees). /// public float Angle { get; init; } /// /// Gets the x-coordinate of the rotation center (FWORD). Zero if not "around center". /// public short CenterX { get; init; } /// /// Gets the y-coordinate of the rotation center (FWORD). Zero if not "around center". /// public short CenterY { get; init; } /// /// Gets a value indicating whether this is an "around center" rotation format. /// public bool AroundCenter { get; init; } } /// /// Represents COLR v1 variation-aware rotate paint operations (formats 25, 27). /// /// internal sealed class PaintVarRotate : Paint { /// /// Gets the child paint node to rotate. /// public required Paint Child { get; init; } /// /// Gets the rotation angle (var +0). /// public float Angle { get; init; } /// /// Gets the x-coordinate of the rotation center (var +1 if around center). /// public short CenterX { get; init; } /// /// Gets the y-coordinate of the rotation center (var +2 if around center). /// public short CenterY { get; init; } /// /// Gets a value indicating whether this is an "around center" rotation format. /// public bool AroundCenter { get; init; } /// /// Gets the base index into the ItemVariationStore delta sets. /// public uint VarIndexBase { get; init; } } /// /// Represents COLR v1 skew paint operations (formats 28, 30), which apply a skew transformation /// to their child paint, optionally around a specified center point. /// /// internal sealed class PaintSkew : Paint { /// /// Gets the child paint node to skew. /// public required Paint Child { get; init; } /// /// Gets the x-axis skew angle as an F2DOT14 value. /// public float XSkew { get; init; } /// /// Gets the y-axis skew angle as an F2DOT14 value. /// public float YSkew { get; init; } /// /// Gets the x-coordinate of the skew center (FWORD). Zero if not "around center". /// public short CenterX { get; init; } /// /// Gets the y-coordinate of the skew center (FWORD). Zero if not "around center". /// public short CenterY { get; init; } /// /// Gets a value indicating whether this is an "around center" skew format. /// public bool AroundCenter { get; init; } } /// /// Represents COLR v1 variation-aware skew paint operations (formats 29, 31). /// /// internal sealed class PaintVarSkew : Paint { /// /// Gets the child paint node to skew. /// public required Paint Child { get; init; } /// /// Gets the x-axis skew angle (var +0). /// public float XSkew { get; init; } /// /// Gets the y-axis skew angle (var +1). /// public float YSkew { get; init; } /// /// Gets the x-coordinate of the skew center (var +2 if around center). /// public short CenterX { get; init; } /// /// Gets the y-coordinate of the skew center (var +3 if around center). /// public short CenterY { get; init; } /// /// Gets a value indicating whether this is an "around center" skew format. /// public bool AroundCenter { get; init; } /// /// Gets the base index into the ItemVariationStore delta sets. /// public uint VarIndexBase { get; init; } } /// /// Represents a COLR v1 PaintComposite (format 32), which composites a source paint over a /// backdrop paint using a specified Porter-Duff or blend mode. /// /// internal sealed class PaintComposite : Paint { /// /// Gets the composite mode used to blend the source over the backdrop. /// public ColrCompositeMode CompositeMode { get; init; } /// /// Gets the source paint node. /// public required Paint Source { get; init; } /// /// Gets the backdrop paint node. /// public required Paint Backdrop { get; init; } } }