easier copy/paste between hex RGB(A) and LÖVE
Posted: Sun May 24, 2020 11:14 am
With the change to color components being (0,1) instead of (0,255), I've found it harder to convert between color pickers or paint programs and LÖVE.
For 10.x, I'd just see #cdcdcd and type {0xcd, 0xcd, 0xcd, 0xff}. I need a calculator for 11.x :-)
That got painful enough that I made a gadget which takes a HTML-style hex color (rgb or rgba) from either the clipboard or standard input and converts it to 4 comma-separated floats between curly braces, ready to be consumed by unpack(), placing it on either the clipboard or standard output depending on where it came from.
Normally I'd do this in python, but pyperclip wasn't working well on my workstation, and the startup time for the interpreter was noticeable enough that I didn't want to fix it, so it's in C++.
It should work on Mac, Linux or Windows. I've used it heavily on Linux, and done a quick test on Windows.
Source code is available here, MIT licensed:
https://git.sr.ht/~tuxpup/love_color_copy
I made a cross-compiled 32-bit Windows build and tested it out a little. That's attached in case anyone wants it. But that's not ideally what I'd distribute for Windows... I just didn't have a machine with visual studio close at hand to build a static version. The attached should be good enough for anyone who's interested to test and see if they care to make a better build
If anyone tries it out, please let me know how it works for you. If anyone builds their own, please let me know if the build instructions are reasonably complete.
I hope it saves someone else as much aggravation as it's saved me.
For 10.x, I'd just see #cdcdcd and type {0xcd, 0xcd, 0xcd, 0xff}. I need a calculator for 11.x :-)
That got painful enough that I made a gadget which takes a HTML-style hex color (rgb or rgba) from either the clipboard or standard input and converts it to 4 comma-separated floats between curly braces, ready to be consumed by unpack(), placing it on either the clipboard or standard output depending on where it came from.
Normally I'd do this in python, but pyperclip wasn't working well on my workstation, and the startup time for the interpreter was noticeable enough that I didn't want to fix it, so it's in C++.
It should work on Mac, Linux or Windows. I've used it heavily on Linux, and done a quick test on Windows.
Source code is available here, MIT licensed:
https://git.sr.ht/~tuxpup/love_color_copy
I made a cross-compiled 32-bit Windows build and tested it out a little. That's attached in case anyone wants it. But that's not ideally what I'd distribute for Windows... I just didn't have a machine with visual studio close at hand to build a static version. The attached should be good enough for anyone who's interested to test and see if they care to make a better build
If anyone tries it out, please let me know how it works for you. If anyone builds their own, please let me know if the build instructions are reasonably complete.
I hope it saves someone else as much aggravation as it's saved me.