Commit Graph

31 Commits

Author SHA1 Message Date
30ed7ce21e Update SVG examples since a few things (dimensions, palette selection) have changed
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2024-05-30 11:51:47 -07:00
782c1fc8d1 Add full source code to example generation
This will just do a `cat` of all Python files in the colorhash/
directory and shove it into a fullsource.in file.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2024-05-30 11:49:42 -07:00
eeb51ce510 Update README to show example of ANSI vs SVG output
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2024-05-30 11:44:00 -07:00
ad014b4ea4 Add ANSI color output, set that as the default
ANSI-based color output is available and now the default. Add a
-y / --output-type argument to select SVG or ANSI output. Also update
tools/genexamples.sh to use the SVG output type.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2024-05-30 11:38:33 -07:00
1def2fa7bf Update colors to be expressed explicitly as RGB or HSL
Generally, palettes are expressed using HSL, but sometimes we want the
output to be in RGB (or some other format). Colors are now expressed
using either RGBColor or HSLColor and can easily be converted between
the two.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2024-05-30 11:02:11 -07:00
ee16b14c73 Fix some mypy type errors in cli.py
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2024-05-30 10:57:39 -07:00
5fc595278c Fix a mypy error with matricizer.py
Self type is not allowed to access static members, in this case
DIMENSIONS

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2024-05-30 10:48:45 -07:00
2d0537e0d6 Add initial README
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2024-05-30 09:25:28 -07:00
54993bc63b Update TODOs in cli.py
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2024-05-26 19:43:03 -07:00
f1a64e2354 Move CLI implementation to its own file and out of __main__
CLI implementation will now live in colorhash/cli.py, and __main__ will
just import and call the cli_main() function.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2024-05-26 19:30:50 -07:00
6aed63c069 Add Matricizer.choose_dimensions
Matrices can choose their dimensions based on hash algorithm

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2024-05-24 22:54:53 -07:00
9298d72c17 Split up palettes into multicolor/gradient
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2024-05-24 22:30:42 -07:00
0baf1f7688 Palettes are selected by matricizer
Matricizers select color palettes now. This is motivated by the fact
that the gradient palettes don't really look good for openssh randomart
based art, and rainbows do look good.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2024-05-24 22:18:50 -07:00
6c370237ea Remove yellow-light palette. Doesn't look good.
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2024-05-24 21:41:39 -07:00
426c9580a7 Update palettes to use HSL coloring
Introduce a new function called `hsl_colors` and a helper `quantize`
function that creates palettes using HSL values on the fly. Default
palettes are now split into "<colorname>-dark" and "<colorname>-light"
for more variation.

In my experiments, red-centric colors seem to be more distinguishable
than others. You have red, green, blue - you can tell they're distinct.
Interleaved between these you have yellow, cyan, and magenta, also
distinct. But between yellow and green, or green and cyan, these colors
feel less distinct than orange, purple or pink. I have opted to elide
non-red "in-betweens" such as those. So we have a dark and light variant
of the following colors as palettes:

red, orange, yellow, green, cyan, blue, purple, magenta, pink, gray, and
also a rainbow palette that is every color at its full saturation.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2024-05-24 17:39:33 -07:00
d5bd09072a Fix a few things in __main__.py
* Palette choices are determined by the list of palettes available and
  not hard-coded
* Auto palette is chosen by the length of the palette choices rather
  than hard-coded
* Palette help listing is text-wrapped at 70 characters

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2024-05-24 17:37:46 -07:00
1277c2db8b Add input-type
Input can now either be a path, raw data, or a hash itself (path is
default)

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2024-05-24 11:45:42 -07:00
e14c796888 Split out color palettes to their own file
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2024-05-24 11:45:23 -07:00
909306cd0c Remove old .svgs from the examples
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2024-05-23 11:17:03 -07:00
660a0cb60c Add .pylintrc and some documentation + fixes to shut pylint up.
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2024-05-22 12:05:20 -07:00
840e878748 Fix types for mypy
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2024-05-22 11:15:43 -07:00
2cc9ea319b Add dummy __init__.py for package use
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2024-05-22 11:08:02 -07:00
b353b8ff8c Clean up progname in help dialogue
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2024-05-22 11:01:54 -07:00
ed892b7630 Add all examples
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2024-05-22 10:58:39 -07:00
4a9225d27f Add a tool that will generate examples using all matrix and hash options
This tool will go through the examples directory and generate an image
for all *.in files using every hash and matrix option.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2024-05-22 10:57:36 -07:00
962d2ad316 Add command line parsing
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2024-05-22 10:45:41 -07:00
f2627f5096 Rename hash_to_matrix to matricize
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2024-05-21 18:26:17 -07:00
f70e5a4222 Split functionality out into matrix and color passes
* Matricizers turn a hash into a matrix
* Colorizers turn a matrix into a colored matrix

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2024-05-21 18:23:14 -07:00
6fef09d602 OOP-ify this sucker
Colorization can be done using a class now. This allows for more
pluggable coloring methods and lets me try out new things easier.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2024-05-21 12:47:50 -07:00
4d56302e1c Add a couple of examples
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2024-05-21 12:09:21 -07:00
adbdf85b0e initial commit
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2024-05-21 11:54:15 -07:00