Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[apps/convert] Ability to add extra outputs #350

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions apps/convert/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,14 @@ function update () {
output.tBodies[0].textContent = "";
let ret = "";

// Prevent aliases showing up in the output
let spaces = new Set(Color.Space.all);
// Why a set? To prevent aliases showing up in the output
let formats = [...new Set(Color.Space.all)].map(space => ({space}));

for (let space of spaces) {
formats.push({space: "srgb", format: "hex"});
formats.push({space: "srgb", format: "color"});

for (let format of formats) {
let space = format.space;
let id = space.id;
let converted = color.to(id);

Expand All @@ -57,8 +61,8 @@ function update () {

let precision = precisionInput.value;
let inGamut = converted.inGamut();
let str = converted.toString({precision, inGamut: false});
let str_mapped = converted.toString({precision, inGamut: true});
let str = converted.toString({precision, inGamut: false, format});
let str_mapped = converted.toString({precision, inGamut: true, format});
let permalink = `?color=${encodeURIComponent(str)}&precision=${encodeURIComponent(precision)}`;
let permalink_mapped = `?color=${encodeURIComponent(str_mapped)}&precision=${encodeURIComponent(precision)}`;

Expand Down