Code Monkey home page Code Monkey logo

okcolor's Introduction

Easier color palettes and accessibility

OkColor

This is a plugin for Figma, see its community page.

Picking color and creating balanced color palettes with Figma is not an easy task, HSL and HSB are not perceptually uniform, HSL's lightness is relative to the current hue, so for each of them, the real perceived 50% lightness is not at L 50.

Same problem with hue, if we make a palette from hue 0 to 70 with the same incremental value, we'll get a palette that is not perceptually progressive, some hue changes will seem bigger than others.

We also have a problem known as the “Abney effect”, mainly in the blue hues. If we take the hue 240, it shift from blue to purple when we update the lightness.

OkColor solves all these problems and more, its params are reliable and uniform, you know what you'll get.

If we change the hue of a color in OkLCH and keep the same lightness value, we know that the resulting color will have the same perceived lightness.

You can also easily create perceptually uniform color palettes, and do more advanced things with OkLCH like picking colors in P3 space and use the relative chroma (see this thread for more infos).

For more details, check plugin community's page for a FAQ and a playground file that explain in more details the plugin.

Credits

This plugin is made possible by the Culori JS library and the creator of these color models: Björn Ottosson.

The rendering of the color picker is done by freydev using WebGL shaders.

The APCA contrast feature is made possible by the work of Myndex .

To know more about these uniform color spaces, you can check his original article: Oksvh and Okhsl and the one from oklch.com's creators: OKLCH in CSS: why we moved from RGB and HSL.

For developpers

Why I don't use culori.mjs file from node_modules?

Instead of importing from "../node_modules/culori/bundled/culori.mjs", I duplicated the file on the src folder due to clampChroma's limitation. The problem here is that this function can only clamp in sRGB, so to make it clamp in any provided space, I created "clampChromaInGamut(color, mode = "lch", targetGamut = "rgb")". I will send the suggestion to CuloriJS's author to add it in its code.

I tried to use toGamut() but it changes the hue and luminosity of the final color, and what I needed, was to only clamp the chroma while keeping the two others values untouched.

okcolor's People

Contributors

dokozero avatar freydev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

okcolor's Issues

The field order for OKLCH

Hey! Thanks for the update that brings P3. I’m continuing to test it, but at first glance, it looks great!

Every time I use the plugin, I have to wrap my head around this control.

image

The order here is H, C, and L. This order contradicts the parameter order in the CSS notation and even the space name: LCH.

I would suggest changing the field order according to the selected color space. So it would be H, S, L for HSL, and L, C, H for OKLCH.

Chroma value formatting

The Chroma value looks confusing, because it’s actually 0.319.

image

Is there a strong reason to format it as 31.9?

LCH values accuracy

Hi there! Thank you for the plugin 🙌

I noticed that lch.oklch.com and the okColor plugin show really different values for the LCH color mode. E. g. 105 and 26.3 for Chroma.
image

What could be the reason?

OKLrCH for better Lightness?

Hi,

I'd like to suggest implementing OkLrCH space instead of the current OkLCH for more perceptually uniform lightness.
Björn used it in one of these color pickers: https://bottosson.github.io/misc/colorpicker

Middle gray in OkColor is currently #636363, which is darker than the supposed #777777

Also, OkLCH suffers from an extension of dark values near Black, as you can see from this post:
https://raphlinus.github.io/color/2021/01/18/oklab-critique.html
which makes the interpolation from any light colors to black not very uniform.

I hope you will consider this in the next update.
Thank you for such a great plugin!

Cheers,
Alex

WebGL sRGB rendering bug in Chrome and Safari

Hello @freydev I'm going to need your help again.

I just released a new version and found a bug in OkLCH's render, I'm not sure if it was there before when we released version 5, maybe Chrome changed something meanwhile in their WebGL engine.

On Chrome and Safari (macOS)
chrome-safari

On Figma desktop, Firefox and Edge (macOS)
figma-desktop-firefox-edge

I reverted the update to see if it was present on the last release (5), tested on Chrome and yes, same weird bug:
version5-chrome

It only happens in sRGB, P3 is fine, here is a capture from Chrome:
chrome-safari-p3

I looked into the code, especially in f_shader.glsl but I'm not that familiar with WebGL, If you know where it can come from that would be helpful (you'll see that I refactored the whole code and it's now easier to read 👍).

If you need to push a new test version in prod tell me as we can't test dev version in Chrome but only in desktop app which is a shame to debug 😔 . Thanks in advance for your time.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.