This is an experiment showcasing interpolation via Kubelka-Munk theory. Approach generally employs the method as outlined in Spectral.js. Most of foundational topics are covered in Mixbox's paper, though Spectral.js uses an approach less focused on specific paints and instead opts to generalize and simplify the approach by simply generating reflectance curves directly from the spectral data. Results don't necessarily mimic specific paints, but give a pigment like feel.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Calculate reflection curves for red, green, and blue that sum to the actual D65 white using SciPy. | |
| `calc_reflect_scipy.py` forces the curves to sum to a flat reflectance of 1. Integrating a flat | |
| reflectance under the sampled D65 illuminant does not land exactly on the color space's white | |
| (the spectral D65 and CMFs, at this sampling, are not quite `[0.3127, 0.3290]`), so that script | |
| rescales the rows of the XYZ to RGB conversion to compensate. That alters the color space. | |
| Here the color space is left alone. Instead of a flat 1, the curves sum to the smoothest white | |
| reflectance curve `w` that maps to exactly `[1, 1, 1]`, which is the color space's D65 white. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Calculate reflection curves for red, green, and blue jointly using SciPy. | |
| This is a reference implementation of the joint solver in `calc_reflect.py`. | |
| The curves are the softmax of three logits (blue's logit is held at zero), so they | |
| always sum to exactly 1 and stay strictly between 0 and 1. The smoothness of the | |
| logits is minimized subject to red and green reproducing their target colors. | |
| Blue is implied: a flat reflectance of 1 is white, so blue is `white - red - green`. | |
| Requires `numpy`, `scipy`, and `plotly`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| DLM color space. | |
| This is a prototype of the space as described here: https://prototypestudios.neocities.org/dlm | |
| We have not bothered to see exactly how they do their space, but have instead just implemented it as described. | |
| Any errors in implementation are likely our own. | |
| """ | |
| from __future__ import annotations | |
| import math | |
| from coloraide.spaces import Space, Prism, Luminant | |
| from coloraide.channels import Channel |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """OkTCh color space.""" | |
| from __future__ import annotations | |
| import math | |
| from coloraide import algebra as alg | |
| from coloraide import util | |
| from coloraide.cat import WHITES | |
| from coloraide.channels import Channel, FLG_ANGLE | |
| from coloraide.types import Vector | |
| from coloraide.spaces.lab import y_to_lstar, lstar_to_y | |
| from coloraide.spaces.lch import LCh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Msh color space. | |
| Accounts for negative lightness and uses degrees for hue instead of radians. | |
| - https://www.kennethmoreland.com/color-maps/ColorMapsExpanded.pdf | |
| """ | |
| import math | |
| from coloraide import Color as Base | |
| from coloraide import stop |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## MIT License | |
| ## | |
| ## Copyright (c) 2023 Ronald van Wijnen | |
| ## | |
| ## Permission is hereby granted, free of charge, to any person obtaining a | |
| ## copy of this software and associated documentation files (the "Software"), | |
| ## to deal in the Software without restriction, including without limitation | |
| ## the rights to use, copy, modify, merge, publish, distribute, sublicense, | |
| ## and/or sell copies of the Software, and to permit persons to whom the | |
| ## Software is furnished to do so, subject to the following conditions: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## MIT License | |
| ## | |
| ## Copyright (c) 2023 Ronald van Wijnen | |
| ## | |
| ## Permission is hereby granted, free of charge, to any person obtaining a | |
| ## copy of this software and associated documentation files (the "Software"), | |
| ## to deal in the Software without restriction, including without limitation | |
| ## the rights to use, copy, modify, merge, publish, distribute, sublicense, | |
| ## and/or sell copies of the Software, and to permit persons to whom the | |
| ## Software is furnished to do so, subject to the following conditions: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Fancy lists in the style of Pandoc. | |
| --- | |
| # A Python implementation of John Gruber's Markdown. | |
| # Started by Manfred Stienstra (http://www.dwerg.net/). | |
| # Maintained for a few years by Yuri Takhteyev (http://www.freewisdom.org). | |
| # Currently maintained by Waylan Limberg (https://github.com/waylan), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # pragma: init | |
| from __future__ import annotations | |
| from coloraide.spaces.okhsl import Okhsl, okhsl_to_oklab, oklab_to_okhsl | |
| from coloraide.spaces.okhsv import Okhsv, okhsv_to_oklab, oklab_to_okhsv | |
| P3L_TO_LMS = [ | |
| [0.4813798527499543, 0.4621183710113182, 0.05650177623872754], | |
| [0.2288319418112447, 0.6532168193835677, 0.11795123880518772], | |
| [0.08394575232299314, 0.22416527097756647, 0.6918889766994405] | |
| ] |
NewerOlder