Skip to content

Size

interludesoftware.tick

Interlude.Tick

Size Struct

A length used by layout helpers (Top(Size), PushSizedHorizontal(Size[]), etc.). Either an absolute pixel count (Interlude.Tick.SizeUnit.Pixel) or a fraction of the parent dimension in [0, 1] (Interlude.Tick.SizeUnit.Percent).

The implicit int → Pixel and float → Percent conversions are convenient at literal call sites but can silently mis-interpret computed values: Left(10f) is 1000% of parent, not 10 pixels. Prefer Pixels(int) / Percent(float) when the unit is not obvious from context - particularly when the value comes from arithmetic, a serialised field, or a Mathf call.

public struct Size

Constructors

Size(float) Constructor

Creates a percent-unit Size. Prefer Percent(float) at non-obvious call sites.

public Size(float value);

Parameters

value System.Single

Size(int) Constructor

Creates a pixel-unit Size. Prefer Pixels(int) at non-obvious call sites.

public Size(int value);

Parameters

value System.Int32

Size(SizeUnit, float) Constructor

Creates a Size with an explicit unit and value.

public Size(Interlude.Tick.SizeUnit unit, float value);

Parameters

unit Interlude.Tick.SizeUnit

value System.Single

Methods

Size.Percent(float) Method

Constructs a percent-unit Size as a fraction of the parent dimension. 0.5f is half the parent, 1.0f the full parent. Equivalent to the implicit float → Size conversion, but explicit at the call site so a literal like 10f can't be silently treated as 1000% - pass Pixels(10) if pixels were intended.

public static Interlude.Tick.Size Percent(float fraction);

Parameters

fraction System.Single

Returns

Size

Size.Pixels(float) Method

Constructs a pixel-unit Size from a possibly-fractional value. Use when a pixel length comes from arithmetic (for example a computed radius) so the implicit float → Percent conversion cannot silently misread it.

public static Interlude.Tick.Size Pixels(float value);

Parameters

value System.Single

Returns

Size

Size.Pixels(int) Method

Constructs a pixel-unit Size. Equivalent to the implicit int → Size conversion, but explicit at the call site, which matters when the value comes from arithmetic that could be mistakenly authored as float.

public static Interlude.Tick.Size Pixels(int value);

Parameters

value System.Int32

Returns

Size

Operators

Size.implicit operator Size(float) Operator

Implicitly converts a System.Single literal to a percent-unit Size.

public static Interlude.Tick.Size implicit operator Interlude.Tick.Size(float value);

Parameters

value System.Single

Returns

Size

Size.implicit operator Size(int) Operator

Implicitly converts an System.Int32 literal to a pixel-unit Size.

public static Interlude.Tick.Size implicit operator Interlude.Tick.Size(int value);

Parameters

value System.Int32

Returns

Size