238 lines
5.3 KiB
Markdown
238 lines
5.3 KiB
Markdown
# QuadCol
|
|
|
|
## About
|
|
|
|
QuadCol is a color palette generator that creates a 4-color palette from a single base hex color. It uses the OKLab perceptually uniform color space to generate complementary colors with consistent perceptual brightness.
|
|
|
|
Given a base color, QuadCol generates:
|
|
- A lighter variant
|
|
- A medium variant
|
|
- The original base color
|
|
- A darker variant
|
|
|
|
The generated palette is rendered as an interactive HTML page displaying color swatches with hex and RGB values, along with CSS custom properties (variables) for easy integration into stylesheets.
|
|
|
|
## Dependencies
|
|
|
|
**coloraide** - A Python color library used to convert hex colors to the OKLab perceptually uniform color space, adjust lightness values for consistent color variants, and convert back to sRGB for hex and RGB output formats. This ensures the generated palette maintains visual harmony and perceptual consistency.
|
|
|
|
## Running From Source
|
|
|
|
These instructions are for Linux or macOS environments.
|
|
|
|
### Prerequisites
|
|
|
|
If you're on Linux and encounter a Python venv setup error, install the required package:
|
|
|
|
```bash
|
|
sudo apt install python3.12-venv
|
|
```
|
|
|
|
### Setup Steps
|
|
|
|
**1. Create a virtual environment** (one-time setup)
|
|
|
|
```bash
|
|
python3 -m venv .venv
|
|
```
|
|
|
|
**2. Activate the virtual environment** (required each time you open a terminal)
|
|
|
|
```bash
|
|
source .venv/bin/activate
|
|
```
|
|
|
|
**3. Install dependencies** (one-time setup)
|
|
|
|
```bash
|
|
pip install coloraide
|
|
```
|
|
|
|
**4. Run QuadCol**
|
|
|
|
```bash
|
|
python3 quadcol.py <base_color> [output_file]
|
|
```
|
|
|
|
Examples:
|
|
- `python3 quadcol.py FF6B6B` — generates `output.html`
|
|
- `python3 quadcol.py #FF6B6B mypalette.html` — saves to `mypalette.html`
|
|
|
|
## Single Executable
|
|
|
|
If you want to use QuadCol without keeping a virtual environment active, or you want a cleaner developer workflow, bundle it into a single executable and put it on your `PATH`.
|
|
|
|
This is the easiest option for day-to-day use because it avoids ad-hoc files in the repo and lets you run `quadcol` from anywhere.
|
|
|
|
### Why use the executable build?
|
|
|
|
- Keeps the project root cleaner
|
|
- Avoids repeated setup churn from generated files
|
|
- Makes the command easier to invoke in scripts and terminal sessions
|
|
- Gives you a stable, shareable local tool
|
|
|
|
### Build Steps
|
|
|
|
These instructions are for Linux or macOS. You need to build the executable separately for each operating system you target.
|
|
|
|
> The virtual environment from the previous section is reused here. If it does not exist yet, create and activate it first.
|
|
|
|
**1. Activate the virtual environment**
|
|
|
|
```bash
|
|
source .venv/bin/activate
|
|
```
|
|
|
|
**2. Install the required build tools**
|
|
|
|
```bash
|
|
pip install coloraide
|
|
pip install pyinstaller
|
|
```
|
|
|
|
**3. Generate the PyInstaller spec file**
|
|
|
|
This creates a configuration matching your main entry script:
|
|
|
|
```bash
|
|
pyi-makespec --onefile quadcol.py
|
|
```
|
|
|
|
**4. Update the spec file so bundled resources are included**
|
|
|
|
Open `quadcol.spec` and find the `datas=[]` entry inside the `Analysis` block. Replace it with:
|
|
|
|
```python
|
|
datas=[
|
|
("resources/*", "resources"),
|
|
],
|
|
```
|
|
|
|
This ensures the app can find the resource files it needs when bundled as a single executable.
|
|
|
|
**5. Build the executable**
|
|
|
|
```bash
|
|
pyinstaller quadcol.spec
|
|
```
|
|
|
|
This creates the binary in the project directory at:
|
|
|
|
```bash
|
|
dist/quadcol
|
|
```
|
|
|
|
**6. Run it directly or install it on your PATH**
|
|
|
|
Run it from the build output folder:
|
|
|
|
```bash
|
|
./dist/quadcol <base_color> [output_file]
|
|
```
|
|
|
|
Or install it somewhere convenient on your `PATH`:
|
|
|
|
```bash
|
|
chmod +x dist/quadcol
|
|
cp dist/quadcol ~/.local/bin/quadcol
|
|
```
|
|
|
|
Then you can run it like this:
|
|
|
|
```bash
|
|
quadcol <base_color> [output_file]
|
|
```
|
|
|
|
If `~/.local/bin` is not already on your `PATH`, add it to your shell profile before using the command globally.
|
|
|
|
### Example usage
|
|
|
|
```bash
|
|
quadcol AE5F38 palette-orange.html
|
|
quadcol #FF6B6B mypalette.html
|
|
```
|
|
|
|
## Example Palettes
|
|
|
|
Here are a few palettes that I regularly use, and you might be interested in:
|
|
|
|
### Palette Blue
|
|
|
|
```bash
|
|
python3 quadcol.py 009BFF palette-blue.html
|
|
|
|
./quadcol 009BFF palette-blue.html
|
|
```
|
|
|
|
Here is the [generated output](sample/palette-blue.html)
|
|
|
|
### Palette Green
|
|
|
|
```bash
|
|
python3 quadcol.py 5AB33B palette-green.html
|
|
|
|
./quadcol 5AB33B palette-green.html
|
|
```
|
|
|
|
Here is the [generated output](sample/palette-green.html)
|
|
|
|
### Palette Orange
|
|
|
|
```bash
|
|
python3 quadcol.py AE5F38 palette-orange.html
|
|
|
|
./quadcol AE5F38 palette-orange.html
|
|
```
|
|
|
|
Here is the [generated output](sample/palette-orange.html)
|
|
|
|
### Palette Slate
|
|
|
|
```bash
|
|
python3 quadcol.py 4C566A palette-slate.html
|
|
|
|
./quadcol 4C566A palette-slate.html
|
|
```
|
|
|
|
Here is the [generated output](sample/palette-slate.html)
|
|
|
|
### Palette Terracotta
|
|
|
|
```bash
|
|
python3 quadcol.py BC5215 palette-terracotta.html
|
|
|
|
./quadcol BC5215 palette-terracotta.html
|
|
```
|
|
|
|
Here is the [generated output](sample/palette-terracotta.html)
|
|
|
|
### Palette Moss
|
|
|
|
```bash
|
|
python3 quadcol.py 66800B palette-moss.html
|
|
|
|
./quadcol 66800B palette-moss.html
|
|
```
|
|
|
|
Here is the [generated output](sample/palette-moss.html)
|
|
|
|
### Palette Lavender
|
|
|
|
```bash
|
|
python3 quadcol.py 8A4FFF palette-lavender.html
|
|
|
|
./quadcol 8A4FFF palette-lavender.html
|
|
```
|
|
|
|
Here is the [generated output](sample/palette-lavender.html)
|
|
|
|
### Palette Ocean
|
|
|
|
```bash
|
|
python3 quadcol.py 205EA6 palette-ocean.html
|
|
|
|
./quadcol 205EA6 palette-ocean.html
|
|
```
|
|
|
|
Here is the [generated output](sample/palette-ocean.html)
|