Skip to content

Instantly share code, notes, and snippets.

View facelessuser's full-sized avatar
💭
Screaming into the void 😱

Isaac Muse facelessuser

💭
Screaming into the void 😱
View GitHub Profile
@facelessuser
facelessuser / exploring-tonal-palettes.md
Last active April 26, 2024 17:59
Exploring Tonal Palettes

Exploring Tonal Palettes

HCT

HCT is a color model developed by [Google][material-hct]. It aims to solve a problem related to generating color palettes with good contrast. While HCT may seem like a revolutionary color model, the idea behind it is quite simple, take the perceptually uniform color model CAM16 and combine it with the CIE Lab's lightness.

Upside of HCT

@facelessuser
facelessuser / okwide.py
Created March 21, 2024 23:18
Okhsl and Okhsv for wide gamuts
# 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]
]
@facelessuser
facelessuser / compare.py
Created February 26, 2024 18:13
Compare GMA
from coloraide.gamut import Fit
from coloraide.spaces import RGBish
from coloraide import algebra as alg
class OkLChScale(Fit):
"""
Gamut mapping by scaling.
Expected gamut mapping spaces are RGB type spaces.
For best results, linear light RGB spaces are preferred.
"""
@facelessuser
facelessuser / scalelh.py
Last active February 18, 2024 22:34
Scale LH and tones
# pragma: init
from coloraide.gamut import Fit
from coloraide.spaces import RGBish
class OkLChScale(Fit):
"""
Gamut mapping by scaling.
Expected gamut mapping spaces are RGB type spaces.
For best results, linear light RGB spaces are preferred.
@facelessuser
facelessuser / oklch-scale2.py
Created February 15, 2024 13:21
Evaluating Scaled LH
# pragma: init
from coloraide.gamut import Fit
from coloraide.spaces import RGBish
from coloraide import algebra as alg
class OkLChScale(Fit):
"""
Gamut mapping by scaling.
Expected gamut mapping spaces are RGB type spaces.
@facelessuser
facelessuser / pycon.py
Last active January 3, 2024 13:48
Python Console Execution for SuperFences
"""
Execute Python code in code blocks and construct a interactive Python console output.
This allows you to write code examples, but then execute them, showing the results.
https://github.com/facelessuser/pymdown-extensions/issues/1690
---
MIT License
@facelessuser
facelessuser / playground.md
Last active August 29, 2023 16:06
Page: Coloraide - Playground

Color Notebook

ColorAide's documentation is rendered with Python Markdown and Pymdown Extensions. The color notebook implements a dynamic, live environment allowing for on the fly page rendering. This is accomplished by using Pyodide to execute the required Python modules to render the desired pages.

Pages can contain most Markdown but also special code blocks called playgrounds. These playgrounds are simple fenced code blocks that allow for a user to input and execute Python code. Each playground exposes access to ColorAide allowing for sandboxes to explore the features of ColorAide. Additionally, the playgrounds will search for color objects, interpolation objects, and color

@facelessuser
facelessuser / css.py
Created August 23, 2023 16:24
CSS undefined handling
from coloraide import Color as Base
class Color(Base):
FIT = 'oklch-chroma'
POWERLESS = True
CARRYFORWARD = True
print('==== Case 1 ====')
color = Color.interpolate(['oklch(100% 50% 60deg)', 'oklch(50% 50% 0deg)'], space='oklch', out_space='oklch')(0.5)
Row([color.to_string(percent=True), color.convert('srgb').to_string()])

/// tab | Tab 1

//// tab | Tab A content ////

//// tab | Tab B content //// ///

@facelessuser
facelessuser / LICENSE.md
Created June 30, 2023 15:40
Delta Phi Star

DPS CONTRAST (DELTA PHI STAR) LICENSE

DPS Contrast, also known as Delta Phi Star, is a simple formula for predicting human visual perception of contrast between text and background.

  • WHAT WHERE HOW

    • Delta Phi Star predicts the contrast of text against the background for a given pair of colors.
    • Delta Phi Star emerged from the SAPC/APCA project developing new standards for better beat ability on the web.
    • Delta Phi Star takes in two $L^*$ (Lstar) values, and returns an $L^c$ (lightness contrast) value.
  • UNIFORMITY:

  • DPS Contrast is quasi-uniform for human perception of text against a background on a self-illuminated display