Skip to content

How to create a custom RGB color space? #593

Answered by sidewayss
sidewayss asked this question in Q&A
Discussion options

You must be logged in to vote

This snippet has been edited to make sense as a standalone. I have a slightly unorthodox coding style that is on the dense side, and I have yet to adopt the new trend of trailing commas:

import Color from "https://colorjs.io/dist/color.js";
export Color;

document.addEventListener("DOMContentLoaded", loadIt, false);

function loadIt() {
    const
    RGB = "rgb", // my code has a collection of CSS function names, including color() spaces, so I don't need this
    ColorSpace = Color.Space,
    registry   = Color.spaces,
    sRGBLinear = registry["srgb-linear"],
    sRGB       = registry["srgb"],
    sRGB255    = new ColorSpace({
        id:    "rgb255",
        name:  "sRGB (0-255)",
        

Replies: 15 comments 68 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@facelessuser
Comment options

@sidewayss
Comment options

@sidewayss
Comment options

Comment options

You must be logged in to vote
4 replies
@sidewayss
Comment options

@sidewayss
Comment options

@lloydk
Comment options

@sidewayss
Comment options

Comment options

You must be logged in to vote
3 replies
@sidewayss
Comment options

@sidewayss
Comment options

@sidewayss
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
5 replies
@sidewayss
Comment options

@sidewayss
Comment options

@sidewayss
Comment options

@lloydk
Comment options

@sidewayss
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by sidewayss
Comment options

You must be logged in to vote
11 replies
@sidewayss
Comment options

@sidewayss
Comment options

@lloydk
Comment options

@sidewayss
Comment options

@sidewayss
Comment options

Comment options

You must be logged in to vote
8 replies
@facelessuser
Comment options

@sidewayss
Comment options

@facelessuser
Comment options

@sidewayss
Comment options

@sidewayss
Comment options

Comment options

You must be logged in to vote
15 replies
@sidewayss
Comment options

@facelessuser
Comment options

@sidewayss
Comment options

@sidewayss
Comment options

@sidewayss
Comment options

Comment options

You must be logged in to vote
18 replies
@sidewayss
Comment options

@lloydk
Comment options

@sidewayss
Comment options

@sidewayss
Comment options

@sidewayss
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@sidewayss
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants