@tokens-studio/tokenscript-schemas 0.0.13 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -0
- package/bundled/functions/adjust_chroma.json +60 -0
- package/bundled/functions/adjust_hue.json +60 -0
- package/bundled/functions/adjust_lightness.json +60 -0
- package/bundled/functions/adjust_to_contrast.json +67 -0
- package/bundled/functions/alpha_blend.json +31 -0
- package/bundled/functions/alpha_scale.json +27 -0
- package/bundled/functions/analogous.json +32 -0
- package/bundled/functions/apca_contrast.json +27 -0
- package/bundled/functions/are_similar.json +73 -0
- package/bundled/functions/auto_text_color.json +66 -0
- package/bundled/functions/best_contrast.json +28 -0
- package/bundled/functions/chroma.json +54 -0
- package/bundled/functions/clamp_chroma.json +66 -0
- package/bundled/functions/clamp_lightness.json +66 -0
- package/bundled/functions/clamp_to_gamut.json +23 -0
- package/bundled/functions/complement.json +24 -0
- package/bundled/functions/contrast_ratio.json +27 -0
- package/bundled/functions/cooler.json +52 -0
- package/bundled/functions/darken.json +28 -0
- package/bundled/functions/delta_e_2000.json +40 -0
- package/bundled/functions/delta_e_76.json +27 -0
- package/bundled/functions/delta_e_ok.json +27 -0
- package/bundled/functions/desaturate.json +28 -0
- package/bundled/functions/distributed.json +36 -0
- package/bundled/functions/diverging.json +36 -0
- package/bundled/functions/grayscale.json +24 -0
- package/bundled/functions/harmonize.json +65 -0
- package/bundled/functions/hue.json +54 -0
- package/bundled/functions/hue_difference.json +27 -0
- package/bundled/functions/in_gamut.json +27 -0
- package/bundled/functions/interpolate.json +66 -0
- package/bundled/functions/invert.json +1 -1
- package/bundled/functions/is_cool.json +23 -0
- package/bundled/functions/is_dark.json +27 -0
- package/bundled/functions/is_light.json +27 -0
- package/bundled/functions/is_neutral.json +65 -0
- package/bundled/functions/is_warm.json +23 -0
- package/bundled/functions/lighten.json +28 -0
- package/bundled/functions/lightness.json +61 -0
- package/bundled/functions/luminance.json +23 -0
- package/bundled/functions/meets_contrast.json +31 -0
- package/bundled/functions/mix.json +32 -0
- package/bundled/functions/monochromatic.json +28 -0
- package/bundled/functions/muted.json +59 -0
- package/bundled/functions/neutral_variant.json +59 -0
- package/bundled/functions/relative_luminance.json +61 -0
- package/bundled/functions/rotate_hue.json +28 -0
- package/bundled/functions/saturate.json +28 -0
- package/bundled/functions/scale_chroma.json +60 -0
- package/bundled/functions/scale_lightness.json +60 -0
- package/bundled/functions/sepia.json +59 -0
- package/bundled/functions/set_chroma.json +28 -0
- package/bundled/functions/set_hue.json +28 -0
- package/bundled/functions/set_lightness.json +28 -0
- package/bundled/functions/shade_scale.json +28 -0
- package/bundled/functions/split_complement.json +28 -0
- package/bundled/functions/steps.json +32 -0
- package/bundled/functions/tetradic.json +24 -0
- package/bundled/functions/tint_scale.json +36 -0
- package/bundled/functions/to_gamut.json +59 -0
- package/bundled/functions/triadic.json +24 -0
- package/bundled/functions/vibrant.json +59 -0
- package/bundled/functions/warmer.json +52 -0
- package/bundled/functions/wcag_level.json +60 -0
- package/bundled/functions.json +2602 -6
- package/bundled/registry.json +3705 -84
- package/bundled/types/css-color.json +151 -0
- package/bundled/types/hsl-color.json +66 -0
- package/bundled/types/hsv-color.json +57 -0
- package/bundled/types/hwb-color.json +66 -0
- package/bundled/types/lab-color.json +57 -0
- package/bundled/types/lch-color.json +57 -0
- package/bundled/types/okhsl-color.json +57 -0
- package/bundled/types/okhsv-color.json +57 -0
- package/bundled/types/oklab-color.json +87 -0
- package/bundled/types/oklch-color.json +57 -0
- package/bundled/types/p3-color.json +57 -0
- package/bundled/types/p3-linear-color.json +57 -0
- package/bundled/types/rgb-color.json +12 -3
- package/bundled/types/srgb-color.json +77 -0
- package/bundled/types/srgb-linear-color.json +67 -0
- package/bundled/types/xyz-d50-color.json +57 -0
- package/bundled/types/xyz-d65-color.json +77 -0
- package/bundled/types.json +1067 -43
- package/dist/cli/index.cjs +231 -22
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.js +231 -22
- package/dist/cli/index.js.map +1 -1
- package/dist/index.cjs +5 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/package.json +4 -2
- package/src/bundler/index.ts +7 -0
- package/src/bundler/presets/css.ts +21 -0
- package/src/bundler/presets/index.ts +47 -0
- package/src/bundler/presets/types.ts +10 -0
- package/src/bundler/selective-bundler.ts +9 -0
- package/src/bundler/types.ts +1 -0
- package/src/cli/commands/bundle.test.ts +34 -0
- package/src/cli/commands/bundle.ts +37 -11
- package/src/cli/commands/list.ts +36 -4
- package/src/cli/commands/presets.ts +81 -0
- package/src/cli/index.ts +12 -1
- package/src/cli/output-generator.ts +8 -2
- package/src/cli/version-info.ts +93 -0
- package/src/schemas/types/css-color/from-hsl-color.tokenscript +17 -4
- package/src/schemas/types/css-color/from-hwb-color.tokenscript +17 -4
- package/src/schemas/types/css-color/from-lab-color.tokenscript +17 -4
- package/src/schemas/types/css-color/from-lch-color.tokenscript +17 -4
- package/src/schemas/types/css-color/from-oklab-color.tokenscript +17 -4
- package/src/schemas/types/css-color/from-oklch-color.tokenscript +17 -4
- package/src/schemas/types/css-color/from-p3-color.tokenscript +17 -4
- package/src/schemas/types/css-color/from-rgb-color.tokenscript +17 -4
- package/src/schemas/types/css-color/from-srgb-color.tokenscript +17 -4
- package/src/schemas/types/css-color/from-xyz-d50-color.tokenscript +17 -4
- package/src/schemas/types/css-color/from-xyz-d65-color.tokenscript +17 -4
- package/src/schemas/types/css-color/unit.test.ts +216 -0
- package/src/schemas/types/hex-color/unit.test.ts +18 -0
- package/src/schemas/types/hsl-color/hsla-initializer.tokenscript +17 -0
- package/src/schemas/types/hsl-color/initializer.tokenscript +6 -1
- package/src/schemas/types/hsl-color/schema.json +9 -0
- package/src/schemas/types/hsl-color/unit.test.ts +95 -1
- package/src/schemas/types/hsv-color/initializer.tokenscript +6 -1
- package/src/schemas/types/hsv-color/unit.test.ts +44 -0
- package/src/schemas/types/hwb-color/hwba-initializer.tokenscript +17 -0
- package/src/schemas/types/hwb-color/initializer.tokenscript +6 -1
- package/src/schemas/types/hwb-color/schema.json +9 -0
- package/src/schemas/types/hwb-color/unit.test.ts +70 -0
- package/src/schemas/types/lab-color/initializer.tokenscript +6 -1
- package/src/schemas/types/lab-color/unit.test.ts +44 -0
- package/src/schemas/types/lch-color/initializer.tokenscript +6 -1
- package/src/schemas/types/lch-color/unit.test.ts +44 -0
- package/src/schemas/types/okhsl-color/initializer.tokenscript +8 -1
- package/src/schemas/types/okhsl-color/unit.test.ts +37 -0
- package/src/schemas/types/okhsv-color/initializer.tokenscript +8 -1
- package/src/schemas/types/okhsv-color/unit.test.ts +37 -0
- package/src/schemas/types/oklab-color/initializer.tokenscript +6 -1
- package/src/schemas/types/oklab-color/unit.test.ts +58 -0
- package/src/schemas/types/oklch-color/initializer.tokenscript +6 -1
- package/src/schemas/types/oklch-color/unit.test.ts +58 -0
- package/src/schemas/types/p3-color/initializer.tokenscript +6 -1
- package/src/schemas/types/p3-color/unit.test.ts +47 -0
- package/src/schemas/types/rgb-color/initializer.tokenscript +7 -1
- package/src/schemas/types/rgb-color/rgba-initializer.tokenscript +17 -0
- package/src/schemas/types/rgb-color/schema.json +9 -0
- package/src/schemas/types/rgb-color/unit.test.ts +110 -1
- package/src/schemas/types/srgb-color/initializer.tokenscript +6 -1
- package/src/schemas/types/srgb-color/unit.test.ts +89 -0
- package/bundled/types/rgba-color.json +0 -89
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Presets command - list available bundle presets
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/// <reference types="../../../types/ulog" />
|
|
6
|
+
|
|
7
|
+
import anylogger from "ulog";
|
|
8
|
+
import { BUNDLE_PRESETS } from "@/bundler/presets/index";
|
|
9
|
+
|
|
10
|
+
const log = anylogger("presets");
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Format preset information for display
|
|
14
|
+
*/
|
|
15
|
+
function formatPresetInfo(): string {
|
|
16
|
+
const lines: string[] = [];
|
|
17
|
+
|
|
18
|
+
lines.push("=".repeat(60));
|
|
19
|
+
lines.push("Available Bundle Presets");
|
|
20
|
+
lines.push("=".repeat(60));
|
|
21
|
+
|
|
22
|
+
for (const [key, preset] of Object.entries(BUNDLE_PRESETS)) {
|
|
23
|
+
lines.push("");
|
|
24
|
+
lines.push(`preset:${key}`);
|
|
25
|
+
lines.push(` ${preset.description}`);
|
|
26
|
+
|
|
27
|
+
// Types section
|
|
28
|
+
const typesCount =
|
|
29
|
+
preset.types.length === 1 && preset.types[0] === "*" ? "all" : preset.types.length;
|
|
30
|
+
lines.push("");
|
|
31
|
+
lines.push(` Types (${typesCount}):`);
|
|
32
|
+
if (preset.types.length > 0 && preset.types[0] !== "*") {
|
|
33
|
+
for (const type of preset.types) {
|
|
34
|
+
lines.push(` - ${type}`);
|
|
35
|
+
}
|
|
36
|
+
} else {
|
|
37
|
+
lines.push(` - all`);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Functions section
|
|
41
|
+
const functionsCount =
|
|
42
|
+
preset.functions.length === 1 && preset.functions[0] === "*"
|
|
43
|
+
? "all"
|
|
44
|
+
: preset.functions.length;
|
|
45
|
+
lines.push("");
|
|
46
|
+
lines.push(` Functions (${functionsCount}):`);
|
|
47
|
+
if (preset.functions.length > 0 && preset.functions[0] !== "*") {
|
|
48
|
+
for (const func of preset.functions) {
|
|
49
|
+
lines.push(` - ${func}`);
|
|
50
|
+
}
|
|
51
|
+
} else {
|
|
52
|
+
lines.push(` - all`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
lines.push("");
|
|
57
|
+
lines.push("=".repeat(60));
|
|
58
|
+
lines.push("Usage Examples:");
|
|
59
|
+
lines.push("=".repeat(60));
|
|
60
|
+
lines.push("npx tokenscript-schemas bundle preset:css");
|
|
61
|
+
lines.push("npx tokenscript-schemas bundle preset:css type:oklab-color");
|
|
62
|
+
lines.push("npx tokenscript-schemas bundle type:hex-color function:lighten");
|
|
63
|
+
lines.push("");
|
|
64
|
+
lines.push("Note: You can combine multiple presets and specific schemas!");
|
|
65
|
+
|
|
66
|
+
return lines.join("\n");
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export async function handlePresetsCommand(): Promise<void> {
|
|
70
|
+
try {
|
|
71
|
+
log.info("Listing available presets");
|
|
72
|
+
|
|
73
|
+
const output = formatPresetInfo();
|
|
74
|
+
console.log(output);
|
|
75
|
+
|
|
76
|
+
log.info(`Listed ${Object.keys(BUNDLE_PRESETS).length} presets`);
|
|
77
|
+
} catch (error) {
|
|
78
|
+
log.error("Failed to list presets:", error);
|
|
79
|
+
throw error;
|
|
80
|
+
}
|
|
81
|
+
}
|
package/src/cli/index.ts
CHANGED
|
@@ -10,6 +10,7 @@ import cac from "cac";
|
|
|
10
10
|
import anylogger from "ulog";
|
|
11
11
|
import { type BundleOptions, handleBundleCommand } from "./commands/bundle.js";
|
|
12
12
|
import { handleListCommand, type ListOptions } from "./commands/list.js";
|
|
13
|
+
import { handlePresetsCommand } from "./commands/presets.js";
|
|
13
14
|
|
|
14
15
|
const log = anylogger("cli");
|
|
15
16
|
|
|
@@ -44,7 +45,17 @@ cli
|
|
|
44
45
|
}
|
|
45
46
|
});
|
|
46
47
|
|
|
48
|
+
// Presets command
|
|
49
|
+
cli.command("presets", "List available bundle presets").action(async () => {
|
|
50
|
+
try {
|
|
51
|
+
await handlePresetsCommand();
|
|
52
|
+
} catch (error) {
|
|
53
|
+
log.error("Error:", error);
|
|
54
|
+
process.exit(1);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
47
58
|
cli.help();
|
|
48
|
-
cli.version("0.0.
|
|
59
|
+
cli.version("0.0.14");
|
|
49
60
|
|
|
50
61
|
cli.parse();
|
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import type { BundledSchemaEntry } from "@/bundler/selective-bundler.js";
|
|
6
|
+
import { getVersionInfo } from "./version-info.js";
|
|
6
7
|
|
|
7
8
|
export interface OutputGeneratorOptions {
|
|
8
9
|
schemas: BundledSchemaEntry[];
|
|
9
10
|
includeHelper?: boolean; // Include makeConfig() helper
|
|
11
|
+
generatedBy?: string; // CLI command used to generate
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
/**
|
|
@@ -16,14 +18,18 @@ export function generateOutput(options: OutputGeneratorOptions): string {
|
|
|
16
18
|
const { schemas, includeHelper = true } = options;
|
|
17
19
|
|
|
18
20
|
const timestamp = new Date().toISOString();
|
|
19
|
-
const
|
|
21
|
+
const versionInfo = getVersionInfo();
|
|
20
22
|
|
|
21
23
|
const lines: string[] = [];
|
|
22
24
|
|
|
23
25
|
// Header comment
|
|
24
26
|
lines.push("// Auto-generated by @tokens-studio/tokenscript-schemas");
|
|
27
|
+
lines.push(`// Version: ${versionInfo.version}`);
|
|
28
|
+
lines.push(`// GitHub: ${versionInfo.githubUrl}`);
|
|
29
|
+
if (options.generatedBy) {
|
|
30
|
+
lines.push(`// Command: ${options.generatedBy}`);
|
|
31
|
+
}
|
|
25
32
|
lines.push(`// Generated: ${timestamp}`);
|
|
26
|
-
lines.push(`// Schemas: ${schemaList}`);
|
|
27
33
|
lines.push("");
|
|
28
34
|
|
|
29
35
|
// Import statement
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get version information for the bundled output
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { execSync } from "node:child_process";
|
|
6
|
+
import { readFileSync } from "node:fs";
|
|
7
|
+
import { dirname, join } from "node:path";
|
|
8
|
+
import { fileURLToPath } from "node:url";
|
|
9
|
+
|
|
10
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
11
|
+
const __dirname = dirname(__filename);
|
|
12
|
+
|
|
13
|
+
export interface VersionInfo {
|
|
14
|
+
version: string; // Package version or git SHA
|
|
15
|
+
githubUrl: string;
|
|
16
|
+
isLocal: boolean; // true if running from local repo (not published package)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Get the current git SHA
|
|
21
|
+
*/
|
|
22
|
+
function getGitSha(): string | null {
|
|
23
|
+
try {
|
|
24
|
+
return execSync("git rev-parse --short HEAD", {
|
|
25
|
+
encoding: "utf-8",
|
|
26
|
+
stdio: ["pipe", "pipe", "ignore"],
|
|
27
|
+
}).trim();
|
|
28
|
+
} catch {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Check if we're running from a local git repo
|
|
35
|
+
*/
|
|
36
|
+
function isGitRepo(): boolean {
|
|
37
|
+
try {
|
|
38
|
+
execSync("git rev-parse --git-dir", {
|
|
39
|
+
stdio: ["pipe", "pipe", "ignore"],
|
|
40
|
+
});
|
|
41
|
+
return true;
|
|
42
|
+
} catch {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Get version from package.json
|
|
49
|
+
*/
|
|
50
|
+
function getPackageVersion(): string {
|
|
51
|
+
try {
|
|
52
|
+
// Try multiple paths for package.json
|
|
53
|
+
const paths = [
|
|
54
|
+
join(__dirname, "../../package.json"), // From src/cli
|
|
55
|
+
join(__dirname, "../../../package.json"), // From dist/cli
|
|
56
|
+
];
|
|
57
|
+
|
|
58
|
+
for (const path of paths) {
|
|
59
|
+
try {
|
|
60
|
+
const pkg = JSON.parse(readFileSync(path, "utf-8"));
|
|
61
|
+
return pkg.version || "unknown";
|
|
62
|
+
} catch {
|
|
63
|
+
// Try next path
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return "unknown";
|
|
68
|
+
} catch {
|
|
69
|
+
return "unknown";
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Get version information for the bundle
|
|
75
|
+
*/
|
|
76
|
+
export function getVersionInfo(): VersionInfo {
|
|
77
|
+
const githubUrl = "https://github.com/tokens-studio/tokenscript-schemas";
|
|
78
|
+
const isLocal = isGitRepo();
|
|
79
|
+
|
|
80
|
+
let version: string;
|
|
81
|
+
if (isLocal) {
|
|
82
|
+
const sha = getGitSha();
|
|
83
|
+
version = sha ? `local-${sha}` : "local";
|
|
84
|
+
} else {
|
|
85
|
+
version = getPackageVersion();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
version,
|
|
90
|
+
githubUrl,
|
|
91
|
+
isLocal,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
@@ -1,16 +1,29 @@
|
|
|
1
1
|
// HSL to CSS Conversion
|
|
2
2
|
// Converts HSL to CSS hsl() syntax
|
|
3
|
-
// CSS Color Level 4: hsl(h s l) where s and l are percentages
|
|
3
|
+
// CSS Color Level 4: hsl(h s l) or hsl(h s l / alpha) where s and l are percentages
|
|
4
4
|
//
|
|
5
|
-
// Input: Color.HSL with h (0-360), s (0-1), l (0-1)
|
|
6
|
-
// Output: Color.CSS with value like "hsl(120 50% 75%)"
|
|
5
|
+
// Input: Color.HSL with h (0-360), s (0-1), l (0-1), optional alpha (0-1)
|
|
6
|
+
// Output: Color.CSS with value like "hsl(120 50% 75%)" or "hsl(120 50% 75% / 0.5)"
|
|
7
|
+
// Note: Alpha is omitted if null or 1.0 (fully opaque)
|
|
7
8
|
|
|
8
9
|
variable precision: Number = 100;
|
|
9
10
|
variable h: Number = round({input}.h * precision) / precision;
|
|
10
11
|
variable s: Number = round({input}.s * 100 * precision) / precision;
|
|
11
12
|
variable l: Number = round({input}.l * 100 * precision) / precision;
|
|
12
13
|
|
|
14
|
+
variable css_value: String = "hsl(".concat(h.to_string()).concat(" ").concat(s.to_string()).concat("% ").concat(l.to_string()).concat("%");
|
|
15
|
+
|
|
16
|
+
// Add alpha if present, not null, and not 1.0 (per CSS convention)
|
|
17
|
+
variable alpha: Number = {input}.alpha;
|
|
18
|
+
if (alpha != null) [
|
|
19
|
+
if (alpha != 1) [
|
|
20
|
+
css_value = css_value.concat(" / ").concat(alpha.to_string());
|
|
21
|
+
];
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
css_value = css_value.concat(")");
|
|
25
|
+
|
|
13
26
|
variable output: Color.CSS;
|
|
14
|
-
output.value =
|
|
27
|
+
output.value = css_value;
|
|
15
28
|
return output;
|
|
16
29
|
|
|
@@ -1,16 +1,29 @@
|
|
|
1
1
|
// HWB to CSS Conversion
|
|
2
2
|
// Converts HWB to CSS hwb() syntax
|
|
3
|
-
// CSS Color Level 4: hwb(h w b) where w and b are percentages
|
|
3
|
+
// CSS Color Level 4: hwb(h w b) or hwb(h w b / alpha) where w and b are percentages
|
|
4
4
|
//
|
|
5
|
-
// Input: Color.HWB with h (0-360), w (0-1), b (0-1)
|
|
6
|
-
// Output: Color.CSS with value like "hwb(120 10% 20%)"
|
|
5
|
+
// Input: Color.HWB with h (0-360), w (0-1), b (0-1), optional alpha (0-1)
|
|
6
|
+
// Output: Color.CSS with value like "hwb(120 10% 20%)" or "hwb(120 10% 20% / 0.5)"
|
|
7
|
+
// Note: Alpha is omitted if null or 1.0 (fully opaque)
|
|
7
8
|
|
|
8
9
|
variable precision: Number = 100;
|
|
9
10
|
variable h: Number = round({input}.h * precision) / precision;
|
|
10
11
|
variable w: Number = round({input}.w * 100 * precision) / precision;
|
|
11
12
|
variable b_val: Number = round({input}.b * 100 * precision) / precision;
|
|
12
13
|
|
|
14
|
+
variable css_value: String = "hwb(".concat(h.to_string()).concat(" ").concat(w.to_string()).concat("% ").concat(b_val.to_string()).concat("%");
|
|
15
|
+
|
|
16
|
+
// Add alpha if present, not null, and not 1.0 (per CSS convention)
|
|
17
|
+
variable alpha: Number = {input}.alpha;
|
|
18
|
+
if (alpha != null) [
|
|
19
|
+
if (alpha != 1) [
|
|
20
|
+
css_value = css_value.concat(" / ").concat(alpha.to_string());
|
|
21
|
+
];
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
css_value = css_value.concat(")");
|
|
25
|
+
|
|
13
26
|
variable output: Color.CSS;
|
|
14
|
-
output.value =
|
|
27
|
+
output.value = css_value;
|
|
15
28
|
return output;
|
|
16
29
|
|
|
@@ -1,16 +1,29 @@
|
|
|
1
1
|
// CIE Lab to CSS Conversion
|
|
2
2
|
// Converts CIE Lab to CSS lab() syntax
|
|
3
|
-
// CSS Color Level 4: lab(L a b) where L is a percentage
|
|
3
|
+
// CSS Color Level 4: lab(L a b) or lab(L a b / alpha) where L is a percentage
|
|
4
4
|
//
|
|
5
|
-
// Input: Color.Lab with l (0-100), a, b
|
|
6
|
-
// Output: Color.CSS with value like "lab(75% 20 -30)"
|
|
5
|
+
// Input: Color.Lab with l (0-100), a, b, optional alpha (0-1)
|
|
6
|
+
// Output: Color.CSS with value like "lab(75% 20 -30)" or "lab(75% 20 -30 / 0.5)"
|
|
7
|
+
// Note: Alpha is omitted if null or 1.0 (fully opaque)
|
|
7
8
|
|
|
8
9
|
variable precision: Number = 10000;
|
|
9
10
|
variable l: Number = round({input}.l * precision) / precision;
|
|
10
11
|
variable a: Number = round({input}.a * precision) / precision;
|
|
11
12
|
variable b_val: Number = round({input}.b * precision) / precision;
|
|
12
13
|
|
|
14
|
+
variable css_value: String = "lab(".concat(l.to_string()).concat("% ").concat(a.to_string()).concat(" ").concat(b_val.to_string());
|
|
15
|
+
|
|
16
|
+
// Add alpha if present, not null, and not 1.0 (per CSS convention)
|
|
17
|
+
variable alpha: Number = {input}.alpha;
|
|
18
|
+
if (alpha != null) [
|
|
19
|
+
if (alpha != 1) [
|
|
20
|
+
css_value = css_value.concat(" / ").concat(alpha.to_string());
|
|
21
|
+
];
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
css_value = css_value.concat(")");
|
|
25
|
+
|
|
13
26
|
variable output: Color.CSS;
|
|
14
|
-
output.value =
|
|
27
|
+
output.value = css_value;
|
|
15
28
|
return output;
|
|
16
29
|
|
|
@@ -1,16 +1,29 @@
|
|
|
1
1
|
// CIE LCH to CSS Conversion
|
|
2
2
|
// Converts CIE LCH to CSS lch() syntax
|
|
3
|
-
// CSS Color Level 4: lch(L C H) where L is a percentage
|
|
3
|
+
// CSS Color Level 4: lch(L C H) or lch(L C H / alpha) where L is a percentage
|
|
4
4
|
//
|
|
5
|
-
// Input: Color.LCH with l (0-100), c, h (0-360)
|
|
6
|
-
// Output: Color.CSS with value like "lch(75% 50 180)"
|
|
5
|
+
// Input: Color.LCH with l (0-100), c, h (0-360), optional alpha (0-1)
|
|
6
|
+
// Output: Color.CSS with value like "lch(75% 50 180)" or "lch(75% 50 180 / 0.5)"
|
|
7
|
+
// Note: Alpha is omitted if null or 1.0 (fully opaque)
|
|
7
8
|
|
|
8
9
|
variable precision: Number = 10000;
|
|
9
10
|
variable l: Number = round({input}.l * precision) / precision;
|
|
10
11
|
variable c: Number = round({input}.c * precision) / precision;
|
|
11
12
|
variable h: Number = round({input}.h * precision) / precision;
|
|
12
13
|
|
|
14
|
+
variable css_value: String = "lch(".concat(l.to_string()).concat("% ").concat(c.to_string()).concat(" ").concat(h.to_string());
|
|
15
|
+
|
|
16
|
+
// Add alpha if present, not null, and not 1.0 (per CSS convention)
|
|
17
|
+
variable alpha: Number = {input}.alpha;
|
|
18
|
+
if (alpha != null) [
|
|
19
|
+
if (alpha != 1) [
|
|
20
|
+
css_value = css_value.concat(" / ").concat(alpha.to_string());
|
|
21
|
+
];
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
css_value = css_value.concat(")");
|
|
25
|
+
|
|
13
26
|
variable output: Color.CSS;
|
|
14
|
-
output.value =
|
|
27
|
+
output.value = css_value;
|
|
15
28
|
return output;
|
|
16
29
|
|
|
@@ -1,16 +1,29 @@
|
|
|
1
1
|
// OKLab to CSS Conversion
|
|
2
2
|
// Converts OKLab to CSS oklab() syntax
|
|
3
|
-
// CSS Color Level 4: oklab(L a b) where L is 0-1 decimal
|
|
3
|
+
// CSS Color Level 4: oklab(L a b) or oklab(L a b / alpha) where L is 0-1 decimal
|
|
4
4
|
//
|
|
5
|
-
// Input: Color.OKLab with l (0-1), a, b
|
|
6
|
-
// Output: Color.CSS with value like "oklab(0.7 0.1 -0.05)"
|
|
5
|
+
// Input: Color.OKLab with l (0-1), a, b, optional alpha (0-1)
|
|
6
|
+
// Output: Color.CSS with value like "oklab(0.7 0.1 -0.05)" or "oklab(0.7 0.1 -0.05 / 0.5)"
|
|
7
|
+
// Note: Alpha is omitted if null or 1.0 (fully opaque)
|
|
7
8
|
|
|
8
9
|
variable precision: Number = 100000;
|
|
9
10
|
variable l: Number = round({input}.l * precision) / precision;
|
|
10
11
|
variable a: Number = round({input}.a * precision) / precision;
|
|
11
12
|
variable b_val: Number = round({input}.b * precision) / precision;
|
|
12
13
|
|
|
14
|
+
variable css_value: String = "oklab(".concat(l.to_string()).concat(" ").concat(a.to_string()).concat(" ").concat(b_val.to_string());
|
|
15
|
+
|
|
16
|
+
// Add alpha if present, not null, and not 1.0 (per CSS convention)
|
|
17
|
+
variable alpha: Number = {input}.alpha;
|
|
18
|
+
if (alpha != null) [
|
|
19
|
+
if (alpha != 1) [
|
|
20
|
+
css_value = css_value.concat(" / ").concat(alpha.to_string());
|
|
21
|
+
];
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
css_value = css_value.concat(")");
|
|
25
|
+
|
|
13
26
|
variable output: Color.CSS;
|
|
14
|
-
output.value =
|
|
27
|
+
output.value = css_value;
|
|
15
28
|
return output;
|
|
16
29
|
|
|
@@ -1,16 +1,29 @@
|
|
|
1
1
|
// OKLCH to CSS Conversion
|
|
2
2
|
// Converts OKLCH to CSS oklch() syntax
|
|
3
|
-
// CSS Color Level 4: oklch(L C H) where L is 0-1 decimal
|
|
3
|
+
// CSS Color Level 4: oklch(L C H) or oklch(L C H / alpha) where L is 0-1 decimal
|
|
4
4
|
//
|
|
5
|
-
// Input: Color.OKLCH with l (0-1), c, h (0-360)
|
|
6
|
-
// Output: Color.CSS with value like "oklch(0.7 0.15 180)"
|
|
5
|
+
// Input: Color.OKLCH with l (0-1), c, h (0-360), optional alpha (0-1)
|
|
6
|
+
// Output: Color.CSS with value like "oklch(0.7 0.15 180)" or "oklch(0.7 0.15 180 / 0.5)"
|
|
7
|
+
// Note: Alpha is omitted if null or 1.0 (fully opaque)
|
|
7
8
|
|
|
8
9
|
variable precision: Number = 100000;
|
|
9
10
|
variable l: Number = round({input}.l * precision) / precision;
|
|
10
11
|
variable c: Number = round({input}.c * precision) / precision;
|
|
11
12
|
variable h: Number = round({input}.h * precision) / precision;
|
|
12
13
|
|
|
14
|
+
variable css_value: String = "oklch(".concat(l.to_string()).concat(" ").concat(c.to_string()).concat(" ").concat(h.to_string());
|
|
15
|
+
|
|
16
|
+
// Add alpha if present, not null, and not 1.0 (per CSS convention)
|
|
17
|
+
variable alpha: Number = {input}.alpha;
|
|
18
|
+
if (alpha != null) [
|
|
19
|
+
if (alpha != 1) [
|
|
20
|
+
css_value = css_value.concat(" / ").concat(alpha.to_string());
|
|
21
|
+
];
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
css_value = css_value.concat(")");
|
|
25
|
+
|
|
13
26
|
variable output: Color.CSS;
|
|
14
|
-
output.value =
|
|
27
|
+
output.value = css_value;
|
|
15
28
|
return output;
|
|
16
29
|
|
|
@@ -1,16 +1,29 @@
|
|
|
1
1
|
// Display-P3 to CSS Conversion
|
|
2
2
|
// Converts Display-P3 to CSS color(display-p3) syntax
|
|
3
|
-
// CSS Color Level 4: color(display-p3 r g b)
|
|
3
|
+
// CSS Color Level 4: color(display-p3 r g b) or color(display-p3 r g b / alpha)
|
|
4
4
|
//
|
|
5
|
-
// Input: Color.P3 with r, g, b in 0-1 range
|
|
6
|
-
// Output: Color.CSS with value like "color(display-p3 1 0.5 0.25)"
|
|
5
|
+
// Input: Color.P3 with r, g, b in 0-1 range, optional alpha (0-1)
|
|
6
|
+
// Output: Color.CSS with value like "color(display-p3 1 0.5 0.25)" or "color(display-p3 1 0.5 0.25 / 0.5)"
|
|
7
|
+
// Note: Alpha is omitted if null or 1.0 (fully opaque)
|
|
7
8
|
|
|
8
9
|
variable precision: Number = 100000;
|
|
9
10
|
variable r: Number = round({input}.r * precision) / precision;
|
|
10
11
|
variable g: Number = round({input}.g * precision) / precision;
|
|
11
12
|
variable b: Number = round({input}.b * precision) / precision;
|
|
12
13
|
|
|
14
|
+
variable css_value: String = "color(display-p3 ".concat(r.to_string()).concat(" ").concat(g.to_string()).concat(" ").concat(b.to_string());
|
|
15
|
+
|
|
16
|
+
// Add alpha if present, not null, and not 1.0 (per CSS convention)
|
|
17
|
+
variable alpha: Number = {input}.alpha;
|
|
18
|
+
if (alpha != null) [
|
|
19
|
+
if (alpha != 1) [
|
|
20
|
+
css_value = css_value.concat(" / ").concat(alpha.to_string());
|
|
21
|
+
];
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
css_value = css_value.concat(")");
|
|
25
|
+
|
|
13
26
|
variable output: Color.CSS;
|
|
14
|
-
output.value =
|
|
27
|
+
output.value = css_value;
|
|
15
28
|
return output;
|
|
16
29
|
|
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
// RGB to CSS Conversion
|
|
2
2
|
// Converts RGB (0-255) to CSS rgb() syntax
|
|
3
|
-
// CSS Color Level 4 modern syntax: rgb(r g b)
|
|
3
|
+
// CSS Color Level 4 modern syntax: rgb(r g b) or rgb(r g b / alpha)
|
|
4
4
|
//
|
|
5
|
-
// Input: Color.Rgb with r, g, b in 0-255 range
|
|
6
|
-
// Output: Color.CSS with value like "rgb(255 128 64)"
|
|
5
|
+
// Input: Color.Rgb with r, g, b in 0-255 range, optional alpha (0-1)
|
|
6
|
+
// Output: Color.CSS with value like "rgb(255 128 64)" or "rgb(255 128 64 / 0.5)"
|
|
7
|
+
// Note: Alpha is omitted if null or 1.0 (fully opaque)
|
|
7
8
|
|
|
8
9
|
variable r: Number = round({input}.r);
|
|
9
10
|
variable g: Number = round({input}.g);
|
|
10
11
|
variable b: Number = round({input}.b);
|
|
11
12
|
|
|
13
|
+
variable css_value: String = "rgb(".concat(r.to_string()).concat(" ").concat(g.to_string()).concat(" ").concat(b.to_string());
|
|
14
|
+
|
|
15
|
+
// Add alpha if present, not null, and not 1.0 (per CSS convention)
|
|
16
|
+
variable alpha: Number = {input}.alpha;
|
|
17
|
+
if (alpha != null) [
|
|
18
|
+
if (alpha != 1) [
|
|
19
|
+
css_value = css_value.concat(" / ").concat(alpha.to_string());
|
|
20
|
+
];
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
css_value = css_value.concat(")");
|
|
24
|
+
|
|
12
25
|
variable output: Color.CSS;
|
|
13
|
-
output.value =
|
|
26
|
+
output.value = css_value;
|
|
14
27
|
return output;
|
|
15
28
|
|
|
@@ -1,16 +1,29 @@
|
|
|
1
1
|
// sRGB to CSS Conversion
|
|
2
2
|
// Converts sRGB (0-1) to CSS color(srgb) syntax
|
|
3
|
-
// CSS Color Level 4: color(srgb r g b)
|
|
3
|
+
// CSS Color Level 4: color(srgb r g b) or color(srgb r g b / alpha)
|
|
4
4
|
//
|
|
5
|
-
// Input: Color.SRGB with r, g, b in 0-1 range
|
|
6
|
-
// Output: Color.CSS with value like "color(srgb 1 0.5 0.25)"
|
|
5
|
+
// Input: Color.SRGB with r, g, b in 0-1 range, optional alpha (0-1)
|
|
6
|
+
// Output: Color.CSS with value like "color(srgb 1 0.5 0.25)" or "color(srgb 1 0.5 0.25 / 0.5)"
|
|
7
|
+
// Note: Alpha is omitted if null or 1.0 (fully opaque)
|
|
7
8
|
|
|
8
9
|
variable precision: Number = 100000;
|
|
9
10
|
variable r: Number = round({input}.r * precision) / precision;
|
|
10
11
|
variable g: Number = round({input}.g * precision) / precision;
|
|
11
12
|
variable b: Number = round({input}.b * precision) / precision;
|
|
12
13
|
|
|
14
|
+
variable css_value: String = "color(srgb ".concat(r.to_string()).concat(" ").concat(g.to_string()).concat(" ").concat(b.to_string());
|
|
15
|
+
|
|
16
|
+
// Add alpha if present, not null, and not 1.0 (per CSS convention)
|
|
17
|
+
variable alpha: Number = {input}.alpha;
|
|
18
|
+
if (alpha != null) [
|
|
19
|
+
if (alpha != 1) [
|
|
20
|
+
css_value = css_value.concat(" / ").concat(alpha.to_string());
|
|
21
|
+
];
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
css_value = css_value.concat(")");
|
|
25
|
+
|
|
13
26
|
variable output: Color.CSS;
|
|
14
|
-
output.value =
|
|
27
|
+
output.value = css_value;
|
|
15
28
|
return output;
|
|
16
29
|
|
|
@@ -1,16 +1,29 @@
|
|
|
1
1
|
// XYZ-D50 to CSS Conversion
|
|
2
2
|
// Converts XYZ-D50 to CSS color(xyz-d50) syntax
|
|
3
|
-
// CSS Color Level 4: color(xyz-d50 x y z)
|
|
3
|
+
// CSS Color Level 4: color(xyz-d50 x y z) or color(xyz-d50 x y z / alpha)
|
|
4
4
|
//
|
|
5
|
-
// Input: Color.XYZD50 with x, y, z tristimulus values
|
|
6
|
-
// Output: Color.CSS with value like "color(xyz-d50 0.4360 0.2225 0.0139)"
|
|
5
|
+
// Input: Color.XYZD50 with x, y, z tristimulus values, optional alpha (0-1)
|
|
6
|
+
// Output: Color.CSS with value like "color(xyz-d50 0.4360 0.2225 0.0139)" or "color(xyz-d50 0.4360 0.2225 0.0139 / 0.5)"
|
|
7
|
+
// Note: Alpha is omitted if null or 1.0 (fully opaque)
|
|
7
8
|
|
|
8
9
|
variable precision: Number = 100000;
|
|
9
10
|
variable x: Number = round({input}.x * precision) / precision;
|
|
10
11
|
variable y: Number = round({input}.y * precision) / precision;
|
|
11
12
|
variable z: Number = round({input}.z * precision) / precision;
|
|
12
13
|
|
|
14
|
+
variable css_value: String = "color(xyz-d50 ".concat(x.to_string()).concat(" ").concat(y.to_string()).concat(" ").concat(z.to_string());
|
|
15
|
+
|
|
16
|
+
// Add alpha if present, not null, and not 1.0 (per CSS convention)
|
|
17
|
+
variable alpha: Number = {input}.alpha;
|
|
18
|
+
if (alpha != null) [
|
|
19
|
+
if (alpha != 1) [
|
|
20
|
+
css_value = css_value.concat(" / ").concat(alpha.to_string());
|
|
21
|
+
];
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
css_value = css_value.concat(")");
|
|
25
|
+
|
|
13
26
|
variable output: Color.CSS;
|
|
14
|
-
output.value =
|
|
27
|
+
output.value = css_value;
|
|
15
28
|
return output;
|
|
16
29
|
|
|
@@ -1,16 +1,29 @@
|
|
|
1
1
|
// XYZ-D65 to CSS Conversion
|
|
2
2
|
// Converts XYZ-D65 to CSS color(xyz-d65) syntax
|
|
3
|
-
// CSS Color Level 4: color(xyz-d65 x y z) or color(xyz x y z)
|
|
3
|
+
// CSS Color Level 4: color(xyz-d65 x y z) or color(xyz-d65 x y z / alpha)
|
|
4
4
|
//
|
|
5
|
-
// Input: Color.XYZD65 with x, y, z tristimulus values
|
|
6
|
-
// Output: Color.CSS with value like "color(xyz-d65 0.4124 0.2126 0.0193)"
|
|
5
|
+
// Input: Color.XYZD65 with x, y, z tristimulus values, optional alpha (0-1)
|
|
6
|
+
// Output: Color.CSS with value like "color(xyz-d65 0.4124 0.2126 0.0193)" or "color(xyz-d65 0.4124 0.2126 0.0193 / 0.5)"
|
|
7
|
+
// Note: Alpha is omitted if null or 1.0 (fully opaque)
|
|
7
8
|
|
|
8
9
|
variable precision: Number = 100000;
|
|
9
10
|
variable x: Number = round({input}.x * precision) / precision;
|
|
10
11
|
variable y: Number = round({input}.y * precision) / precision;
|
|
11
12
|
variable z: Number = round({input}.z * precision) / precision;
|
|
12
13
|
|
|
14
|
+
variable css_value: String = "color(xyz-d65 ".concat(x.to_string()).concat(" ").concat(y.to_string()).concat(" ").concat(z.to_string());
|
|
15
|
+
|
|
16
|
+
// Add alpha if present, not null, and not 1.0 (per CSS convention)
|
|
17
|
+
variable alpha: Number = {input}.alpha;
|
|
18
|
+
if (alpha != null) [
|
|
19
|
+
if (alpha != 1) [
|
|
20
|
+
css_value = css_value.concat(" / ").concat(alpha.to_string());
|
|
21
|
+
];
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
css_value = css_value.concat(")");
|
|
25
|
+
|
|
13
26
|
variable output: Color.CSS;
|
|
14
|
-
output.value =
|
|
27
|
+
output.value = css_value;
|
|
15
28
|
return output;
|
|
16
29
|
|