CellMetrics
Namespace: Hex1b.Surfaces
Assembly: Hex1b.dll
Represents the pixel dimensions of a terminal cell.
public readonly record struct CellMetrics : IEquatable<CellMetrics>Implements
Constructors
CellMetrics(double, int)
Creates cell metrics with actual (floating-point) width.
Parameters:
public CellMetrics(double actualPixelWidth, int pixelHeight)CellMetrics(int, int)
Creates cell metrics with integer dimensions.
Parameters:
public CellMetrics(int pixelWidth, int pixelHeight)Properties
ActualPixelWidth
The actual (possibly fractional) width of a cell in pixels. Used for precise sixel sizing in browser-based terminals.
Returns: Double
public double ActualPixelWidth { get; }PixelHeight
The integer height of a cell in pixels.
Returns: Int32
public int PixelHeight { get; }PixelWidth
The integer width of a cell in pixels (for backward compatibility).
Returns: Int32
public int PixelWidth { get; }Methods
CellToPixel(int, int, int, int)
Converts a cell rectangle to pixel coordinates.
Parameters:
Returns: PixelRect
public PixelRect CellToPixel(int cellX, int cellY, int cellWidth, int cellHeight)CellToPixel(Rect)
Converts a cell rectangle to pixel coordinates.
Parameters:
cellRect(Rect):
Returns: PixelRect
public PixelRect CellToPixel(Rect cellRect)GetCellOffsetForPixel(int)
Calculates the cell offset for a given pixel position using actual dimensions.
Parameters:
pixelX(Int32):
Returns: Int32
public int GetCellOffsetForPixel(int pixelX)GetPixelForCellBoundary(int)
Calculates the pixel position for a cell boundary using actual dimensions.
Parameters:
cellX(Int32):
Returns: Int32
public int GetPixelForCellBoundary(int cellX)GetPixelWidthForCells(int)
Calculates the pixel width for a given number of cells using actual dimensions.
Parameters:
cellCount(Int32):
Returns: Int32
public int GetPixelWidthForCells(int cellCount)PixelToCell(PixelRect)
Converts a pixel rectangle to cell coordinates.
Parameters:
pixelRect(PixelRect):
Returns: Rect
public Rect PixelToCell(PixelRect pixelRect)PixelToCellSpan(int, int)
Computes the cell span for a pixel dimension (rounds up).
Parameters:
Returns: ValueTuple<Int32, Int32>
public (int CellWidth, int CellHeight) PixelToCellSpan(int pixelWidth, int pixelHeight)Fields
Default
Default cell metrics (10×20 pixels).
Returns: CellMetrics
public static readonly CellMetrics DefaultXtermJs
Cell metrics for xterm.js with 14px font (approximately 9×17 pixels).
Returns: CellMetrics
public static readonly CellMetrics XtermJsRemarks
Terminal cells have a fixed pixel size determined by the font and terminal emulator. This information is needed for sixel graphics, which are defined in pixels but must be mapped to cell boundaries for proper rendering and clipping.
Note: Cell width may be fractional in browser-based terminals like xterm.js due to font rendering. The property stores the precise value while provides the integer approximation for compatibility.