Class:Smartest8BitInteger

From The Smartest Wiki
Jump to: navigation, search

This class is a wrapper for an integer from 0-255. It is not usually used much in a user-facing capacity, but is important in other classes, such as SmartestRgbColor.

However, it does have offsets that can be used to represent its quality in different ways, which are useful in the context of it being part of a colour, and could be useful elsewhere.

Offsets

$object._int or $object._integer

Returns a pure PHP integer of the value. Always 0-255.

$object._bin or $object._binary

Returns a binary representation of the integer:

Example:

$myint = new Smartest8BitInteger(22);

And then in your template:

<?sm:$myint._bin:?>

Results in: 00010110

$object._hex

Returns a hexadecimal representation of the integer

Example:

$myint = new Smartest8BitInteger(22);

And then in your template:

<?sm:$myint._hex:?>

Results in: 16

$object._pc or $object._percent

Returns a SmartestNumeric object containing the object as a percentage of 255

Example:

$myint = new Smartest8BitInteger(22);

And then in your template:

<?sm:$myint._percent:?>

Results in: SmartestNumeric with a value of 8.6274509803922