textmode.js / TextmodeGlyphRamp
Class: TextmodeGlyphRamp
Immutable character sequence for mapping numbers to glyphs.
TextmodeGlyphRamp stores a low-to-high sequence of grapheme clusters and maps normalized values to one glyph from that sequence.
Use Textmodifier.createGlyphRamp to create ramps inside a sketch.
Example
Constructors
Constructor
new TextmodeGlyphRamp(characters): TextmodeGlyphRamp;Create a ramp from characters ordered from low values to high values.
At least two grapheme clusters are required.
Parameters
| Parameter | Type | Description |
|---|---|---|
characters | string | Character sequence ordered from low to high. |
Returns
TextmodeGlyphRamp
Example
Properties
characters
readonly characters: string;The character sequence this ramp was created with.
length
readonly length: number;Number of grapheme clusters in the ramp.
Methods
at()
Call Signature
at(normalizedValue): string;Map a normalized value to a character.
Values outside [0, 1] are clamped. 0 returns the first character, and 1 returns the last character.
Parameters
| Parameter | Type | Description |
|---|---|---|
normalizedValue | number | Normalized value to map. |
Returns
string
Character from this ramp.
Example
Call Signature
at(
value,
min,
max): string;Map a value from a source range to a character.
The value is normalized using min and max, then mapped through this ramp. Reversed ranges are supported. Equal range bounds are invalid.
Parameters
| Parameter | Type | Description |
|---|---|---|
value | number | Value to map. |
min | number | Source range minimum. |
max | number | Source range maximum. |
Returns
string
Character from this ramp.
Example
shift()
shift(amount): TextmodeGlyphRamp;Return a shifted copy of this ramp.
Positive amounts rotate forward and negative amounts rotate backward. Fractional amounts are truncated before rotation.
Parameters
| Parameter | Type | Description |
|---|---|---|
amount | number | Number of character steps to shift. |
Returns
TextmodeGlyphRamp
A new shifted ramp.