Forums › Adobe After Effects Expressions › Slider (Decimal) to Binary
Slider (Decimal) to Binary
Andy Benham
January 22, 2021 at 12:50 pmHello all,
I would like to control a text layer to read a padded 10-bit binary number, ideally controlled by a slider.
ie.
0 Decimal = 0000000000512 Decimal = 10000000000
1024 Decimal = 1111111111
I can’t find any expressions that would work to do this, although I imagine it should be quite trivial, I can’t imagine nobody has ever needed to do this before?
Suggestions welcome.
Othman Ahmed
January 22, 2021 at 1:09 pmYup, it’s pretty easy. just add this code to the source text of the text layer :
decimal = thisComp.layer("slider controller").effect("Slider Control")("Slider");
Number(decimal).toString(2)
// done by VFXING
Andy Benham
January 22, 2021 at 1:19 pmThat’s perfect, thank you 🙂
Any suggestions on how to pad to 10 bits?
Filip Vandueren
January 22, 2021 at 1:43 pmThat would be:
decimal=effect("Slider Control")("Slider").value;
binary = decimal.toString(2).padStart(10,"0");Andy Benham
January 22, 2021 at 1:50 pmThank you so much both – that’s absolutely perfect.
Othman Ahmed
January 22, 2021 at 2:19 pmYou’re welcome.
Log in to reply.