Skip to content

SixelPixelAccess

Namespace: Hex1b.Surfaces

Assembly: Hex1b.dll

Provides read-only access to sixel pixel data at a specific cell position.

csharp
public readonly struct SixelPixelAccess

Properties

IsValid

Gets whether this accessor has valid pixel data.

Returns: Boolean

csharp
public bool IsValid { get; }

PixelHeight

Gets the height of this cell's pixel region.

Returns: Int32

csharp
public int PixelHeight { get; }

PixelWidth

Gets the width of this cell's pixel region.

Returns: Int32

csharp
public int PixelWidth { get; }

Methods

GetAverageColor()

Gets the average color of all pixels in this cell.

Returns: Rgba32

The average color.

csharp
public Rgba32 GetAverageColor()

GetDominantColor()

Gets the dominant color of pixels in this cell.

Returns: Rgba32

The most common non-transparent color.

csharp
public Rgba32 GetDominantColor()

GetPixel(int, int)

Gets the pixel at the specified position within this cell.

Parameters:

  • x (Int32): X position within the cell (0 to PixelWidth-1).
  • y (Int32): Y position within the cell (0 to PixelHeight-1).

Returns: Rgba32

The pixel color, or transparent if out of bounds.

csharp
public Rgba32 GetPixel(int x, int y)

HasVisiblePixels()

Checks if any pixel in this cell is non-transparent.

Returns: Boolean

csharp
public bool HasVisiblePixels()

ToPixelBuffer()

Creates a copy of the pixel data for this cell region.

Returns: SixelPixelBuffer

A new pixel buffer containing just this cell's pixels.

csharp
public SixelPixelBuffer? ToPixelBuffer()

WithBrightness(float)

Creates a modified copy of the pixel data with brightness adjusted.

Parameters:

  • factor (Single): Brightness factor (1.0 = no change, 0.5 = half brightness, 2.0 = double).

Returns: SixelPixelBuffer

A new pixel buffer with brightness adjusted.

csharp
public SixelPixelBuffer? WithBrightness(float factor)

WithTint(Rgba32, float)

Creates a modified copy of the pixel data with a color tint applied.

Parameters:

  • tintColor (Rgba32): The color to blend with.
  • opacity (Single): The blend opacity (0.0 to 1.0).

Returns: SixelPixelBuffer

A new pixel buffer with the tint applied.

csharp
public SixelPixelBuffer? WithTint(Rgba32 tintColor, float opacity)

Remarks

This type is used by computed cells to query pixel data from sixels in layers below. The pixel access is relative to the cell position, allowing effects like tinting or brightness adjustment based on the underlying sixel content.

The sixel data is decoded lazily on first access.

Released under the MIT License.