~tuxpup/love_color_copy

format colors for easy pasting into love2d games
make stdin/out work too
add an attempt at subrepo detection.
add clip subrepository

refs

master
browse  log 

clone

read-only
https://git.sr.ht/~tuxpup/love_color_copy
read/write
git@git.sr.ht:~tuxpup/love_color_copy

You can also use your local clone with git send-email.

#LÖVE Color Copy

A tiny command-line tool that looks for HTML-style colors and formats them such that they can easily be unpacked in a LÖVE program.

Copyright 2020 Geoff Beier geoff@tuxpup.com


#Basic Usage

love-color-copy <options>

If no options are specified, love-color-copy will read standard input. For each line it receives, it will check to see if that contains an HTML-style color specification, e.g. #ff0000 or #ff0000ff. If it finds one, it will print the color to standard output in a format that's easily unpack'd in a LÖVE program.

$ echo '#ff0000' |love-color-copy
{1.0, 0.0, 0.0, 1.0}
$ echo '#ff3301ff' |love-color-copy

#Options

--clip

Causes love-color-copy to check the clipboard for a color and, if it finds one, write its output back to the clipboard.

--10

Causes love-color-copy to use 0 - 255 for color components instead of 0.0 - 1.0, for compatibility with LÖVE 10 and earlier.


#Compiling LÖVE Color Copy

NOTE: While LÖVE Color Copy should support Linux, Mac and Windows, it has only been tested on Linux as of this writing. The Mac and Windows instructions below are what I expect to work. Please report back if you try them out.

#Linux

Linux clipboard support is a train wreck, and is the only reason there's any complexity at all to this build process. The straightforward way is to use the clip library that is included as a submodule in this repository. I built this tool using that the whole way, only to find that it didn't work very consistently on my main Fedora 31 workstation.

Because of that, I added support for using the clipboard via wxWidgets, in spite of the fact that this is purely a command line tool and wxWidgets doesn't include clipboard access in its command line support classes.

That didn't work well either, so I added pure GTK+3 clipboard support. That is reliable.

To enable clipboard support, specify USE_CLIPBOARD either on the cmake command line (by supplying -DUSE_CLIPBOARD=1) or by using cmake-gui or ccmake. To select the clip backend, specify USE_CLIP. To select the wxWidgets backend, specify USE_WXWIDGETS. To select the GTK-3 backend, specify USE_GTK. For the clip backend, specify USE_CLIP.

The default Linux build will enable clipboard support using GTK-3.

The most common Linux build and install steps:

$ mkdir cmake-build-linux-rel
$ cd cmake-build-linux-rel
$ cmake -G "Unix Makefiles" ..
$ make

#Mac

WARNING - These steps are currently untested

The whole reason clip support was left in after it proved unreliable on my Fedora workstation is that it's generally easier than installing the wxWidgets dependency. The OS X pasteboard is substantially simpler than the Linux set of clipboard systems, so it's very likely that clip is all that's needed.

$ mkdir cmake-build-xcode-rel
$ cd cmake-build-xcode-rel
$ cmake -G Xcode -DUSE_CLIPBOARD=1 -DUSE_WXWIDGETS=0 -DUSE_CLIP=1 ..
$ cmake --build .

#Windows

WARNING - These steps are currently untested

As with the Mac build speculatively described above, clip should be sufficient on Windows and should be easier than using wx just to get clipboard support.

mkdir cmake-build-visual-studio
cd cmake-build-visual-studio
cmake -G "Visual Studio 16 2019" -DUSE_CLIPBOARD=1 -DUSE_WXWIDGETS=0 -DUSE_CLIP=1 ..
cmake --build .