binary

hex

unbinary

unhex

binary

Arguments
[val][val num-digits]
Docstring

Returns a string representing the binary value of an int, char or byte. When converting an int to a string, it is possible to specify the number of digits used.

Works only inside sketch functions?
No
Original Processing method
binary()
Original p5js method
None.
Example
(q/background 255)
(q/fill 0)
(q/text (str "(q/binary 42) = " (q/binary 42)) 10 10)
(q/text (str "(q/binary 42 5) = " (q/binary 42 5)) 10 30)
try example

hex

Arguments
[val][val num-digits]
Docstring

Converts a byte, char, int, or color to a String containing the equivalent hexadecimal notation. For example color(0, 102, 153) will convert to the String "FF006699". This function can help make your geeky debugging sessions much happier.

Works only inside sketch functions?
No
Original Processing method
hex()
Original p5js method
hex()
Example
(q/background 255)
(q/fill 0)
(q/text (str "(q/hex 42) = " (q/hex 42)) 10 10)
(q/text (str "(q/hex 42 5) = " (q/hex 42 5)) 10 30)
try example

unbinary

Arguments
[str-val]
Docstring

Unpack a binary string to an integer. See binary for converting integers to strings.

Works only inside sketch functions?
No
Original Processing method
unbinary()
Original p5js method
None.
Example
(q/background 255)
(q/fill 0)
(q/text (str "(q/unbinary \"0101010\") = " (q/unbinary "0101010")) 10 10)
try example

unhex

Arguments
[hex-str]
Docstring

Converts a String representation of a hexadecimal number to its equivalent integer value.

Works only inside sketch functions?
No
Original Processing method
unhex()
Original p5js method
unhex()
Example
(q/background 255)
(q/fill 0)
(q/text (str "(q/unhex \"2A\") = " (q/unhex "2A")) 10 10)
try example