afterglow.util

Utility functions that are likely to be widely useful

contrasting-text-color

(contrasting-text-color color)

If the default text color of white will be hard to read against a cell assigned the specified color, returns black. Otherwise returns white. Both are in the form of hex strings suitable for use in a CSS style.

find-closest-key

(find-closest-key sm k)

Finds the key closest to the one specified in a sorted map.

float-epsilon

The tolerance value for comparing two floating point numbers. If the difference between the values is smaller than this, after scaling appropriately for very small or very large numbers, they will be considered equal.

float<

(float< x y)(float< x y epsilon)

Checks whether x is less than y with an equality tolerance specified by epsilon, which defaults to float-epsilon if not provided.

float<=

(float<= x y)(float<= x y epsilon)

Checks whether x is less than or equal to y with an equality tolerance specified by epsilon, which defaults to float-epsilon if not provided.

float=

(float= x y)(float= x y epsilon)

Compare two floating point numbers for equality, with a tolerance specified by epsilon, which defaults to float-epsilon if not provided.

float>

(float> x y)(float> x y epsilon)

Checks whether x is greater than y with an equality tolerance specified by epsilon, which defaults to float-epsilon if not provided.

float>=

(float>= x y)(float>= x y epsilon)

Checks whether x is greater than or equal to y with an equality tolerance specified by epsilon, which defaults to float-epsilon if not provided.

normalize-cue-variable-value

(normalize-cue-variable-value var-spec raw)

Given a raw value that has been looked up for a cue variable, convert it to the appropriate type based on the variable specification.

ubyte

(ubyte val)

Convert small integer to its signed byte equivalent. Necessary for convenient handling of DMX values in the range 0-255, since Java does not have unsigned numbers.

unsign

(unsign val)

Convert a signed byte to its unsigned int equivalent, in the range 0-255.

valid-dmx-value?

(valid-dmx-value? v)

Checks that the supplied value is within the legal range for a DMX channel assignment.