# Anilume > Anilume makes a color theme from a short JSON config. Each palette gets steps from the page color to the text color, in light and dark mode, with contrast checks. This server has an API for agents. Use it to make a theme from the words of the user. The API gives the colors and the code: you do not need a browser, and the user does not need to open a page. ## Steps 1. Write a config from the words of the user. See "From words to a config" and "Examples". 2. Check the config with the API: `GET https://anilume.maxschulmeister.dev/api/theme?config=`. 3. Read `problems`. Change the config, or apply a fix (see "Problems"). Check again. Stop when `problems` is empty, or when the user accepts the problems that stay. 4. Get the code: add `&format=css`, `tailwind`, `shadcn` or `json` to the same request (see "Code"). Use it in the task of the user, for example write it into a file of the project. The colors as hex are in `palettes` of the answer. 5. Tell the user the main colors: the first step of the `solid` category of each palette. 6. Also give the user the `link` of the answer. The user does not have to open it: it is for the user who wants to see the theme or change it in the app. ## API - `GET https://anilume.maxschulmeister.dev/api/theme?config=`. Encode the JSON with `encodeURIComponent`, or use `curl -G --data-urlencode config@theme.json https://anilume.maxschulmeister.dev/api/theme`. A `#` that is not encoded cuts the config. - `POST https://anilume.maxschulmeister.dev/api/theme` with the config as the body. Use it for a long config: a GET link must be shorter than about 16000 characters. - Optional query parameters for both: - `format`: `css`, `tailwind`, `shadcn` or `json`. The answer is the code as text. - `roles`: the palettes of the shadcn/ui roles, for example `primary.brand_neutral.gray_destructive.negative_charts.a.b.c.d.e`. Give only the roles to change. - `mode`: `light` (default) or `dark`. The checks always cover both modes. `mode` only sets which mode the texts name: a problem of the other mode names its mode. The link is the same for each mode. - `GET https://anilume.maxschulmeister.dev/api/schema`: the JSON Schema of the config, with each field. - A config has 20000 characters or fewer, 24 palettes or fewer (a count of n makes n palettes), 6 steps or fewer in a category, 12 categories or fewer, and 4 contrast limits or fewer in a category. A config that takes more than 10 s to calculate gives 400. The server calculates one config at a time: when too many configs wait, the answer is 503. Then send the request again after some seconds. The answer (200): ``` { "ok": true, "link": "https://anilume.maxschulmeister.dev/?c=v1....", "palettes": [{ "name": "brand", "source": "brand", "solid": { "l": 0.543, "c": 0.191, "h": 266.8 }, "categories": { "background": [1, 2], ..., "solid": [9, 10], "text": [11, 12] }, "light": ["", ...], "dark": [...], "contrast": { "light": { "11": "6.0", "12": "13.2" }, "dark": { "11": "9.1", "12": "14.5" } } }, ...], "problems": [{ "palette": "brand", "message": "Step 11: 3.2:1, needs 4.5:1", "step": 11, "fixes": [{ "label": "Adjust step", "config": { ... } }] }], "roles": { "primary": "brand", "neutral": "neutral", "destructive": "negative", "charts": [...] } } ``` - `palettes`: `source` is the palette in the config. A palette with `count` gives `name-1` to `name-n`. `categories` gives the step numbers of each category. `light` and `dark` are the sRGB hex colors of the steps in each mode: step n is item n − 1. With the default shape, step 9 is the solid color and steps 11–12 are text. With another shape the numbers change: use `categories`. - `solid`: the OKLCH values of the solid step in light mode (`l` 0–1, `c` chroma, `h` hue in degrees). - `contrast`: the contrast with the page of each step whose category has a limit against the page, as the app shows it. `4.6` is WCAG 4.6:1, `Lc 76` is APCA. Do not calculate it again. The default checks and these labels measure steps against the page. Text on a solid step is not checked: on a light solid (yellow, orange, a light brand), use a dark text step, not white. The shadcn/ui code chooses the foreground of `primary` with the most contrast. - `roles`: the palettes that the shadcn/ui code uses. The 5 chart roles take the palettes of a count first. With fewer than 5 of them, other color palettes (for example `warning`) fill the other chart roles. To choose other palettes, give `roles`. - An error gives 400: `{ "ok": false, "message": "..." }`. The message tells the problem. Change the config. ## Config `palettes` is necessary. `contexts`, `shape`, `categories` and `distance` are optional. Colors are OKLCH: hue in degrees (0–360), chroma 0 to 0.5 (gray below 0.04, vivid about 0.15–0.25), lightness 0 to 1. The default config of the app: ```json {"palettes":{"brand":{"color":"#3d63dd"},"neutral":{"hue":{"rule":"relate","palette":"brand"},"chroma":{"rule":"fix","value":0.012}},"negative":{"hue":{"rule":"spread","range":[15,35]}},"warning":{"hue":{"rule":"spread","range":[65,95]}},"positive":{"hue":{"rule":"spread","range":[135,165]}},"info":{"hue":{"rule":"spread","range":[230,265]}},"distinct":{"count":5,"hue":{"rule":"spread","exclude":[[350,40],[215,300]]},"shape":{"solid":1,"text":1}}}} ``` ### A palette A name starts with a letter and has only letters, digits and hyphens. It becomes a CSS name: `--brand-9`. - `"color": "#0f766e"`: the solid step is this color (hue, chroma and lightness). Use it for each color that the user gives. A palette has `color` or rules, not both. To change one value of a given color ("a little more blue"), replace `color` with three fix rules from `solid` of the answer, and change the one value. - `"hue"`, `"chroma"`, `"lightness"`: a rule for each one. Without a rule, the engine uses the natural chroma and lightness of the hue. - `{ "rule": "fix", "value": 145 }`: this value. - `{ "rule": "relate", "palette": "brand", "offset": 30, "factor": 1 }`: the value of another palette × `factor` + `offset`. A hue takes only `offset`. - `{ "rule": "spread", "range": [130, 170], "exclude": [[5, 40]] }`: a free value in `range` (default: all), as far as possible from the other palettes. Only a hue can have `exclude`: ranges that it does not use. A range can go past 360, for example `[350, 40]`. - `"count": 5`: makes `name-1` to `name-5`, far from each other. It needs a spread rule, and it cannot have `color`. The largest count is 12. - `"shape"`: the steps of each category for this palette only, for example `{ "solid": 1, "text": 1 }`. It replaces the shared shape: a category that is not in it gets no steps. - `"adjust": true`: the contrast checks can also move the solid step of a given `color`. - `"overrides": { "light": { "11": "#1a1a1a" } }`: a color for one step, by step number. ### Categories, shape and page - The default categories, on a ladder of 12 steps: `{"background":{"range":[1,2],"main":1},"component":{"range":[3,5],"main":3},"border":{"range":[6,8],"main":7},"solid":{"range":[9,10],"main":9},"text":{"range":[11,12],"main":11,"limits":[{"against":"page","min":4.5}]}}`. A `limit` is `{ "against": "page" or a category, "min": 4.5, "model": "wcag" or "apca" }` (`model` default: wcag). The engine moves a step until it passes its limits. - `"categories"` replaces all the default categories. Write all five, and change only what the user asks. - `"shape"`: the number of steps of each category for all palettes. Default: `{"background":2,"component":3,"border":3,"solid":2,"text":2}`. The steps of a category spread over its range. The app shows 0 to 6 steps in each category. - `"contexts": {"light":"#ffffff","dark":"#111111"}`: the page color of each mode (these are the defaults). Give one or both. - `"distance": { "deficiencies": true, "minimum": 10 }`: `deficiencies` also compares colors with color vision deficiencies. Two palettes that are nearer than `minimum` (default 10) give a problem. The check compares the palettes of one count with each other, and the palettes without a count with each other. It does not compare a chart color with the brand or another palette without a count. ## From words to a config - "Brand #0f766e": `"brand": { "color": "#0f766e" }`. Each other color that the user gives: a palette with `color`. - "A brand around hue 300": `"brand": { "hue": { "rule": "fix", "value": 300 } }`. Add a chroma or lightness rule only when the user gives one. - "A gray", "neutral": `"neutral": {"hue":{"rule":"relate","palette":"brand"},"chroma":{"rule":"fix","value":0.012}}` (the brand hue, a small tint). "Pure gray": `{"hue":{"rule":"fix","value":0},"chroma":{"rule":"fix","value":0}}`. - "A warm gray": a small chroma and a warm hue, `{ "hue": { "rule": "fix", "value": 70 }, "chroma": { "rule": "fix", "value": 0.01 } }`. "A cool gray": hue 250. "A gray like the brand, but warmer": `"hue": { "rule": "relate", "palette": "brand", "offset": }` and a small chroma. - "Status colors": negative [15,35], warning [65,95], positive [135,165], info [230,265]. Each one: `{ "hue": { "rule": "spread", "range": [...] } }`. - "Color-blind safe": status colors without red and green: negative [35,55], warning [90,110], positive [235,265], info [290,330], and `"distance": { "deficiencies": true }`. Then the error color (negative) is orange and the success color is blue: tell the user. - "5 chart colors": `"chart": {"count":5,"hue":{"rule":"spread"},"shape":{"solid":1,"text":1}}`. More than 8: also `"lightness": {"rule":"spread","range":[0.5,0.85]}`. - "Without red", "no green": add the range of the name to `exclude` of the hue, about 10° wider on each side (the ends of an excluded range can be used). For example "no green": `"exclude": [[110,175]]`. The hue names (the app uses the same): red [5,40], orange [40,75], yellow [75,120], green [120,165], teal [165,217.5], blue [217.5,275], purple [275,322.5], pink [322.5,5]. - "Dark page #0b0b0f": `"contexts": { "dark": "#0b0b0f" }`. "Dark-first": check with `&mode=dark`, and tell the user to select Dark in the app. The link does not keep the mode. - "Text with APCA 75 on the page": the five categories, with `"limits": [{ "against": "page", "min": 75, "model": "apca" }]` on `text`. "AAA": `"min": 7`. - "3 steps of background": `"shape"` with `"background": 3` and the other default numbers. - "No other colors": only the palettes that the user names. When the user does not say "only", an app theme usually needs a brand, a gray and status colors: add them. ## Problems Each problem has `palette`, `message`, `step` (when it is about one step) and `fixes`. A fix has a `label` and a `config`: the full config after the fix, the same as the app makes it. To apply a fix, use its `config` as the new config and check again. Do not change the config by hand to do a fix. A fix can need one more step. - "Adjust color" or "Adjust step" changes colors. Use it. On a palette with a `color` that the user gave, "Adjust color" moves that color: ask the user first, or tell the user the new color. - "Accept ..." lowers a contrast target or the minimum distance. Ask the user first, or tell the user which problems stay. - "Looks like brand.": two palettes are too similar. Change a hue or a range, or use the fix. "Adjust color" can change a `color` that the user gave: ask the user first, or change the other palette. ## Link - Give the user the `link` of the answer: `https://anilume.maxschulmeister.dev/?c=v1.`. Add nothing to it. It has the address that you used for the API. If the user opens the app at another address, use that address in the link. - Without the API: `https://anilume.maxschulmeister.dev/?config=`. The app checks the config, shows an error notice for a bad one, and then changes the link to the `?c=` format. - `&r=` keeps the shadcn/ui roles, in the format of the `roles` parameter. ## Code - `format=css`: CSS variables, `--brand-1` to `--brand-12` and alpha colors `--brand-a1`. Light on `:root`, dark on `.dark`. - `format=tailwind`: the CSS and Tailwind v4 colors (`bg-brand-9`). Put it after `@import "tailwindcss";`. - `format=shadcn`: the shadcn/ui color variables. They replace the colors in `globals.css`. They need a gray, a negative (destructive) and 5 other color palettes for the charts, for example `"chart": { "count": 5, "hue": { "rule": "spread" } }`, or the `roles` parameter. Without them, give `css` or `tailwind`. - `format=json`: the config. ## Examples "Orange brand #ea580c, a pure gray, status colors, 6 chart colors without red." ```json {"palettes":{"brand":{"color":"#ea580c"},"neutral":{"hue":{"rule":"fix","value":0},"chroma":{"rule":"fix","value":0}},"negative":{"hue":{"rule":"spread","range":[15,35]}},"warning":{"hue":{"rule":"spread","range":[65,95]}},"positive":{"hue":{"rule":"spread","range":[135,165]}},"info":{"hue":{"rule":"spread","range":[230,265]}},"chart":{"count":6,"hue":{"rule":"spread","exclude":[[355,50]]},"shape":{"solid":1,"text":1}}}} ``` "Green brand #16a34a, a gray with a brand tint, color-blind safe status colors, dark page #0d1117." ```json {"palettes":{"brand":{"color":"#16a34a"},"neutral":{"hue":{"rule":"relate","palette":"brand"},"chroma":{"rule":"fix","value":0.012}},"negative":{"hue":{"rule":"spread","range":[35,55]}},"warning":{"hue":{"rule":"spread","range":[90,110]}},"positive":{"hue":{"rule":"spread","range":[235,265]}},"info":{"hue":{"rule":"spread","range":[290,330]}}},"distance":{"deficiencies":true},"contexts":{"dark":"#0d1117"}} ``` "Purple brand #7c3aed, a gray, text with AAA contrast (7:1), 4 border steps." ```json {"palettes":{"brand":{"color":"#7c3aed"},"gray":{"hue":{"rule":"relate","palette":"brand"},"chroma":{"rule":"fix","value":0.012}}},"shape":{"background":2,"component":3,"border":4,"solid":2,"text":2},"categories":{"background":{"range":[1,2],"main":1},"component":{"range":[3,5],"main":3},"border":{"range":[6,8],"main":7},"solid":{"range":[9,10],"main":9},"text":{"range":[11,12],"main":11,"limits":[{"against":"page","min":7}]}}} ```