@tokens-studio/tokenscript-schemas 0.1.1 → 0.1.3
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 +31 -7
- package/dist/cli/index.cjs +21 -35
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.js +21 -35
- package/dist/cli/index.js.map +1 -1
- package/dist/index.cjs +19 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +19 -19
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/bundler/{bundle-schema.ts → build-schema.ts} +2 -2
- package/src/bundler/index.ts +25 -25
- package/src/bundler/schema-dependency-resolver.ts +3 -3
- package/src/bundler/selective-bundler.ts +3 -3
- package/src/cli/commands/bundle.test.ts +95 -1
- package/src/cli/commands/bundle.ts +11 -1
- package/src/cli/index.ts +1 -0
- package/src/cli/version-info.ts +16 -18
- package/bundled/functions/adjust_chroma.json +0 -60
- package/bundled/functions/adjust_hue.json +0 -60
- package/bundled/functions/adjust_lightness.json +0 -60
- package/bundled/functions/adjust_to_contrast.json +0 -67
- package/bundled/functions/alpha_blend.json +0 -31
- package/bundled/functions/alpha_scale.json +0 -27
- package/bundled/functions/analogous.json +0 -32
- package/bundled/functions/apca_contrast.json +0 -27
- package/bundled/functions/are_similar.json +0 -73
- package/bundled/functions/auto_text_color.json +0 -66
- package/bundled/functions/best_contrast.json +0 -28
- package/bundled/functions/chroma.json +0 -54
- package/bundled/functions/clamp_chroma.json +0 -66
- package/bundled/functions/clamp_lightness.json +0 -66
- package/bundled/functions/clamp_to_gamut.json +0 -23
- package/bundled/functions/complement.json +0 -24
- package/bundled/functions/contrast_ratio.json +0 -27
- package/bundled/functions/cooler.json +0 -52
- package/bundled/functions/darken.json +0 -28
- package/bundled/functions/delta_e_2000.json +0 -40
- package/bundled/functions/delta_e_76.json +0 -27
- package/bundled/functions/delta_e_ok.json +0 -27
- package/bundled/functions/desaturate.json +0 -28
- package/bundled/functions/distributed.json +0 -36
- package/bundled/functions/diverging.json +0 -36
- package/bundled/functions/grayscale.json +0 -24
- package/bundled/functions/harmonize.json +0 -65
- package/bundled/functions/hue.json +0 -54
- package/bundled/functions/hue_difference.json +0 -27
- package/bundled/functions/in_gamut.json +0 -27
- package/bundled/functions/interpolate.json +0 -66
- package/bundled/functions/invert.json +0 -23
- package/bundled/functions/is_cool.json +0 -23
- package/bundled/functions/is_dark.json +0 -27
- package/bundled/functions/is_light.json +0 -27
- package/bundled/functions/is_neutral.json +0 -65
- package/bundled/functions/is_warm.json +0 -23
- package/bundled/functions/lighten.json +0 -28
- package/bundled/functions/lightness.json +0 -61
- package/bundled/functions/luminance.json +0 -23
- package/bundled/functions/meets_contrast.json +0 -31
- package/bundled/functions/mix.json +0 -32
- package/bundled/functions/monochromatic.json +0 -28
- package/bundled/functions/muted.json +0 -59
- package/bundled/functions/neutral_variant.json +0 -59
- package/bundled/functions/relative_luminance.json +0 -61
- package/bundled/functions/rotate_hue.json +0 -28
- package/bundled/functions/saturate.json +0 -28
- package/bundled/functions/scale_chroma.json +0 -60
- package/bundled/functions/scale_lightness.json +0 -60
- package/bundled/functions/sepia.json +0 -59
- package/bundled/functions/set_chroma.json +0 -28
- package/bundled/functions/set_hue.json +0 -28
- package/bundled/functions/set_lightness.json +0 -28
- package/bundled/functions/shade_scale.json +0 -28
- package/bundled/functions/split_complement.json +0 -28
- package/bundled/functions/steps.json +0 -32
- package/bundled/functions/tetradic.json +0 -24
- package/bundled/functions/tint_scale.json +0 -36
- package/bundled/functions/to_gamut.json +0 -59
- package/bundled/functions/triadic.json +0 -24
- package/bundled/functions/vibrant.json +0 -59
- package/bundled/functions/warmer.json +0 -52
- package/bundled/functions/wcag_level.json +0 -60
- package/bundled/functions.json +0 -2624
- package/bundled/registry.json +0 -3833
- package/bundled/types/css-color.json +0 -151
- package/bundled/types/hex-color.json +0 -25
- package/bundled/types/hsl-color.json +0 -66
- package/bundled/types/hsv-color.json +0 -57
- package/bundled/types/hwb-color.json +0 -66
- package/bundled/types/lab-color.json +0 -57
- package/bundled/types/lch-color.json +0 -57
- package/bundled/types/okhsl-color.json +0 -57
- package/bundled/types/okhsv-color.json +0 -57
- package/bundled/types/oklab-color.json +0 -87
- package/bundled/types/oklch-color.json +0 -57
- package/bundled/types/p3-color.json +0 -57
- package/bundled/types/p3-linear-color.json +0 -57
- package/bundled/types/rgb-color.json +0 -73
- package/bundled/types/srgb-color.json +0 -77
- package/bundled/types/srgb-linear-color.json +0 -67
- package/bundled/types/xyz-d50-color.json +0 -57
- package/bundled/types/xyz-d65-color.json +0 -77
- package/bundled/types.json +0 -1207
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "Desaturate",
|
|
3
|
-
"type": "function",
|
|
4
|
-
"description": "Decreases color saturation by reducing chroma in OKLCH space. Amount is 0-1 where 0.25 = 25% less saturated.",
|
|
5
|
-
"keyword": "desaturate",
|
|
6
|
-
"input": {
|
|
7
|
-
"type": "object",
|
|
8
|
-
"properties": {
|
|
9
|
-
"color": {
|
|
10
|
-
"type": "color",
|
|
11
|
-
"description": "The color to desaturate"
|
|
12
|
-
},
|
|
13
|
-
"amount": {
|
|
14
|
-
"type": "number",
|
|
15
|
-
"description": "Amount to desaturate (0-1). Default is 0.25"
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
"script": {
|
|
20
|
-
"type": "https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/tokenscript/0/",
|
|
21
|
-
"script": "// Desaturate a color by decreasing its OKLCH chroma\n// Amount: 0-1 where 0.25 means 25% decrease, 1.0 = full grayscale\n//\n// Algorithm: C' = C * (1 - amount)\n\nvariable input: List = {input};\nvariable color: Color.OKLCH = input.get(0).to.oklch();\n\n// Default amount is 0.25 (25%)\nvariable amount: Number = 0.25;\nif (input.length() > 1) [\n amount = input.get(1);\n];\n\n// Calculate new chroma\nvariable current_c: Number = color.c;\nvariable new_c: Number = current_c * (1 - amount);\n\n// Clamp to valid range\nif (new_c < 0) [ new_c = 0; ];\n\n// Create output in OKLCH, return as sRGB\nvariable result: Color.OKLCH;\nresult.l = color.l;\nresult.c = new_c;\nresult.h = color.h;\n\nreturn result;"
|
|
22
|
-
},
|
|
23
|
-
"requirements": [
|
|
24
|
-
"https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/oklch-color/0/",
|
|
25
|
-
"https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/srgb-color/0/"
|
|
26
|
-
],
|
|
27
|
-
"slug": "desaturate"
|
|
28
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "Distributed",
|
|
3
|
-
"type": "function",
|
|
4
|
-
"description": "Creates evenly distributed colors around the OKLCH hue wheel. Perfect for categorical data where each category needs a distinct, visually balanced color.",
|
|
5
|
-
"keyword": "distributed",
|
|
6
|
-
"input": {
|
|
7
|
-
"type": "object",
|
|
8
|
-
"properties": {
|
|
9
|
-
"count": {
|
|
10
|
-
"type": "number",
|
|
11
|
-
"description": "Number of colors to generate. Default is 6"
|
|
12
|
-
},
|
|
13
|
-
"lightness": {
|
|
14
|
-
"type": "number",
|
|
15
|
-
"description": "Lightness for all colors (0-1). Default is 0.7"
|
|
16
|
-
},
|
|
17
|
-
"chroma": {
|
|
18
|
-
"type": "number",
|
|
19
|
-
"description": "Chroma/saturation for all colors (0-0.4). Default is 0.15"
|
|
20
|
-
},
|
|
21
|
-
"start_hue": {
|
|
22
|
-
"type": "number",
|
|
23
|
-
"description": "Starting hue angle (0-360). Default is 30 (orange)"
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
"script": {
|
|
28
|
-
"type": "https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/tokenscript/0/",
|
|
29
|
-
"script": "// Create evenly distributed categorical colors using OKLCH\n// Colors are spaced equally around the hue wheel\n//\n// Ideal for: pie charts, bar charts, legends, category labels\n// Uses golden angle offset for better distinction with many colors\n\nvariable input: List = {input};\n\n// Default count is 6\nvariable count: Number = 6;\nif (input.length() > 0) [\n count = input.get(0);\n];\n\n// Default lightness is 0.7 (good for both light/dark backgrounds)\nvariable lightness: Number = 0.7;\nif (input.length() > 1) [\n lightness = input.get(1);\n];\n\n// Default chroma is 0.15 (vivid but not overwhelming)\nvariable chroma: Number = 0.15;\nif (input.length() > 2) [\n chroma = input.get(2);\n];\n\n// Default start hue is 30 (orange - visually distinct starting point)\nvariable start_hue: Number = 30;\nif (input.length() > 3) [\n start_hue = input.get(3);\n];\n\n// Calculate hue step (360° / count for even distribution)\nvariable hue_step: Number = 360 / count;\n\nvariable result: List;\nvariable i: Number = 0;\nvariable current_hue: Number = 0;\nvariable color: Color.OKLCH;\n\nwhile (i < count) [\n current_hue = start_hue + i * hue_step;\n if (current_hue >= 360) [ current_hue = current_hue - 360; ];\n \n color.l = lightness;\n color.c = chroma;\n color.h = current_hue;\n \n result = result, color.to.srgb();\n i = i + 1;\n];\n\nreturn result;"
|
|
30
|
-
},
|
|
31
|
-
"requirements": [
|
|
32
|
-
"https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/oklch-color/0/",
|
|
33
|
-
"https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/srgb-color/0/"
|
|
34
|
-
],
|
|
35
|
-
"slug": "distributed"
|
|
36
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "Diverging",
|
|
3
|
-
"type": "function",
|
|
4
|
-
"description": "Creates a diverging color palette for heatmaps. Goes from color1 through a neutral midpoint to color2. Perfect for data that diverges from a center value (e.g., -1 to 0 to +1).",
|
|
5
|
-
"keyword": "diverging",
|
|
6
|
-
"input": {
|
|
7
|
-
"type": "object",
|
|
8
|
-
"properties": {
|
|
9
|
-
"color1": {
|
|
10
|
-
"type": "color",
|
|
11
|
-
"description": "Color for negative/low end (e.g., blue)"
|
|
12
|
-
},
|
|
13
|
-
"color2": {
|
|
14
|
-
"type": "color",
|
|
15
|
-
"description": "Color for positive/high end (e.g., red)"
|
|
16
|
-
},
|
|
17
|
-
"count": {
|
|
18
|
-
"type": "number",
|
|
19
|
-
"description": "Number of steps (should be odd for clear midpoint). Default is 9"
|
|
20
|
-
},
|
|
21
|
-
"neutral": {
|
|
22
|
-
"type": "number",
|
|
23
|
-
"description": "Lightness of neutral midpoint (0-1). Default is 0.95 (near white)"
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
"script": {
|
|
28
|
-
"type": "https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/tokenscript/0/",
|
|
29
|
-
"script": "// Create a diverging color palette for data visualization\n// Goes: color1 → neutral → color2\n//\n// Ideal for: heatmaps, correlation matrices, deviation from mean\n// Example: blue → white → red for temperature anomalies\n\nvariable input: List = {input};\nvariable color1: Color.OKLCH = input.get(0).to.oklch();\nvariable color2: Color.OKLCH = input.get(1).to.oklch();\n\n// Default count is 9 (gives clear midpoint at index 4)\nvariable count: Number = 9;\nif (input.length() > 2) [\n count = input.get(2);\n];\n\n// Default neutral lightness is 0.95 (near white)\nvariable neutral_l: Number = 0.95;\nif (input.length() > 3) [\n neutral_l = input.get(3);\n];\n\n// Calculate midpoint index\nvariable mid: Number = (count - 1) / 2;\n\nvariable result: List;\nvariable i: Number = 0;\nvariable t: Number = 0;\nvariable step_color: Color.OKLCH;\n\nwhile (i < count) [\n if (i < mid) [\n // First half: color1 → neutral\n t = i / mid;\n step_color.l = color1.l + (neutral_l - color1.l) * t;\n step_color.c = color1.c * (1 - t);\n step_color.h = color1.h;\n ] else [\n if (i == mid) [\n // Midpoint: neutral (achromatic)\n step_color.l = neutral_l;\n step_color.c = 0;\n step_color.h = 0;\n ] else [\n // Second half: neutral → color2\n t = (i - mid) / mid;\n step_color.l = neutral_l + (color2.l - neutral_l) * t;\n step_color.c = color2.c * t;\n step_color.h = color2.h;\n ];\n ];\n \n result = result, step_color.to.srgb();\n i = i + 1;\n];\n\nreturn result;"
|
|
30
|
-
},
|
|
31
|
-
"requirements": [
|
|
32
|
-
"https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/oklch-color/0/",
|
|
33
|
-
"https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/srgb-color/0/"
|
|
34
|
-
],
|
|
35
|
-
"slug": "diverging"
|
|
36
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "Grayscale",
|
|
3
|
-
"type": "function",
|
|
4
|
-
"description": "Converts a color to grayscale by removing all chroma in OKLCH space. Preserves perceptual lightness.",
|
|
5
|
-
"keyword": "grayscale",
|
|
6
|
-
"input": {
|
|
7
|
-
"type": "object",
|
|
8
|
-
"properties": {
|
|
9
|
-
"color": {
|
|
10
|
-
"type": "color",
|
|
11
|
-
"description": "The color to convert to grayscale"
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
"script": {
|
|
16
|
-
"type": "https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/tokenscript/0/",
|
|
17
|
-
"script": "// Convert a color to grayscale by setting OKLCH chroma to 0\n// This preserves perceptual lightness (unlike simple RGB averaging)\n\nvariable input: List = {input};\nvariable color: Color.OKLCH = input.get(0).to.oklch();\n\n// Create grayscale by removing chroma\nvariable result: Color.OKLCH;\nresult.l = color.l;\nresult.c = 0;\nresult.h = 0;\n\nreturn result;"
|
|
18
|
-
},
|
|
19
|
-
"requirements": [
|
|
20
|
-
"https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/oklch-color/0/",
|
|
21
|
-
"https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/srgb-color/0/"
|
|
22
|
-
],
|
|
23
|
-
"slug": "grayscale"
|
|
24
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "harmonize",
|
|
3
|
-
"type": "function",
|
|
4
|
-
"description": "Harmonizes a color by shifting its hue toward a source color. Inspired by Material Design 3's color harmonization algorithm. This creates visual cohesion in design systems by making colors feel related while preserving their identity. The amount parameter controls how much the hue shifts (0 = no change, 1 = full shift to source hue).",
|
|
5
|
-
"keyword": "harmonize",
|
|
6
|
-
"requirements": [
|
|
7
|
-
"https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/srgb-color/0/",
|
|
8
|
-
"https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/oklch-color/0/"
|
|
9
|
-
],
|
|
10
|
-
"schema": {
|
|
11
|
-
"type": "object",
|
|
12
|
-
"properties": {
|
|
13
|
-
"input": {
|
|
14
|
-
"type": "array",
|
|
15
|
-
"items": [
|
|
16
|
-
{
|
|
17
|
-
"description": "Color to harmonize",
|
|
18
|
-
"type": "color"
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
"description": "Source color (hue target)",
|
|
22
|
-
"type": "color"
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
"description": "Amount of harmonization (0-1, default 0.5)",
|
|
26
|
-
"type": "number"
|
|
27
|
-
}
|
|
28
|
-
],
|
|
29
|
-
"minItems": 2,
|
|
30
|
-
"maxItems": 3
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
"required": [
|
|
34
|
-
"input"
|
|
35
|
-
]
|
|
36
|
-
},
|
|
37
|
-
"returns": {
|
|
38
|
-
"type": "color",
|
|
39
|
-
"description": "Harmonized color with hue shifted toward source"
|
|
40
|
-
},
|
|
41
|
-
"script": {
|
|
42
|
-
"type": "https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/tokenscript/0/",
|
|
43
|
-
"script": "// harmonize: Shift hue towards a source color for visual harmony\n// Reference: Material Design 3 Color System\n// Reference: https://m3.material.io/styles/color/dynamic-color\n//\n// Shifts the input color's hue towards a source color by a specified\n// amount, creating a harmonized palette. Uses OKLCH for perceptually\n// uniform hue interpolation via the shortest angular path.\n//\n// Parameters:\n// color - Color to harmonize\n// source - Target hue source\n// amount - Shift amount (0 = no change, 1 = match source), default 0.5\n//\n// Input: Any color space (converted to OKLCH internally)\n// Output: OKLCH (working space)\n// To get sRGB: harmonize(color, source, 0.5).to.srgb()\n\nvariable input: List = {input};\nvariable color: Color.OKLCH = input.get(0).to.oklch();\nvariable source: Color.OKLCH = input.get(1).to.oklch();\n\n// Default harmonization amount (0.5 = 50% shift)\nvariable amount: Number = 0.5;\nif (input.length() > 2) [\n amount = input.get(2);\n];\n\n// Get hues\nvariable color_hue: Number = color.h;\nvariable source_hue: Number = source.h;\n\n// Calculate shortest path around the hue circle\nvariable diff: Number = source_hue - color_hue;\n\n// Normalize to -180 to 180 range for shortest path\nif (diff > 180) [\n diff = diff - 360;\n];\nif (diff < -180) [\n diff = diff + 360;\n];\n\n// Apply harmonization: shift hue by amount * difference\nvariable new_hue: Number = color_hue + (diff * amount);\n\n// Normalize hue to 0-360\nif (new_hue < 0) [\n new_hue = new_hue + 360;\n];\nif (new_hue >= 360) [\n new_hue = new_hue - 360;\n];\n\n// Create result with shifted hue, preserving lightness and chroma\nvariable result: Color.OKLCH;\nresult.l = color.l;\nresult.c = color.c;\nresult.h = new_hue;\n\nreturn result;"
|
|
44
|
-
},
|
|
45
|
-
"examples": [
|
|
46
|
-
{
|
|
47
|
-
"description": "Harmonize red toward blue",
|
|
48
|
-
"input": [
|
|
49
|
-
"#ff0000",
|
|
50
|
-
"#0000ff",
|
|
51
|
-
0.3
|
|
52
|
-
],
|
|
53
|
-
"output": "Color with hue shifted toward blue"
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
"description": "Harmonize green toward brand color",
|
|
57
|
-
"input": [
|
|
58
|
-
"#00ff00",
|
|
59
|
-
"#6750a4"
|
|
60
|
-
],
|
|
61
|
-
"output": "Green shifted toward purple brand"
|
|
62
|
-
}
|
|
63
|
-
],
|
|
64
|
-
"slug": "harmonize"
|
|
65
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "hue",
|
|
3
|
-
"type": "function",
|
|
4
|
-
"description": "Extracts the hue angle from any color using OKLCH. Returns a value from 0 to 360 degrees representing the color's position on the hue wheel. Hue in OKLCH is perceptually uniform, meaning equal angular steps produce equally perceived hue changes. Essential for color harmony calculations and palette generation.",
|
|
5
|
-
"keyword": "hue",
|
|
6
|
-
"requirements": [
|
|
7
|
-
"https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/srgb-color/0/",
|
|
8
|
-
"https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/oklch-color/0/"
|
|
9
|
-
],
|
|
10
|
-
"schema": {
|
|
11
|
-
"type": "object",
|
|
12
|
-
"properties": {
|
|
13
|
-
"input": {
|
|
14
|
-
"type": "array",
|
|
15
|
-
"items": [
|
|
16
|
-
{
|
|
17
|
-
"description": "Color to extract hue from",
|
|
18
|
-
"type": "color"
|
|
19
|
-
}
|
|
20
|
-
],
|
|
21
|
-
"minItems": 1,
|
|
22
|
-
"maxItems": 1
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
"required": [
|
|
26
|
-
"input"
|
|
27
|
-
]
|
|
28
|
-
},
|
|
29
|
-
"returns": {
|
|
30
|
-
"type": "number",
|
|
31
|
-
"description": "Hue angle (0-360 degrees)"
|
|
32
|
-
},
|
|
33
|
-
"script": {
|
|
34
|
-
"type": "https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/tokenscript/0/",
|
|
35
|
-
"script": "// hue: Extract hue angle from a color\n// Reference: OKLCH Color Space (Björn Ottosson)\n// Reference: https://bottosson.github.io/posts/oklab/\n//\n// Returns the H component from OKLCH, representing the\n// perceptually uniform hue angle. Range: 0-360 degrees.\n\nvariable input: List = {input};\nvariable color: Color.OKLCH = input.get(0).to.oklch();\n\nreturn color.h;"
|
|
36
|
-
},
|
|
37
|
-
"examples": [
|
|
38
|
-
{
|
|
39
|
-
"description": "Red has hue around 30° in OKLCH",
|
|
40
|
-
"input": [
|
|
41
|
-
"#ff0000"
|
|
42
|
-
],
|
|
43
|
-
"output": 29
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
"description": "Cyan has hue around 195°",
|
|
47
|
-
"input": [
|
|
48
|
-
"#00ffff"
|
|
49
|
-
],
|
|
50
|
-
"output": 195
|
|
51
|
-
}
|
|
52
|
-
],
|
|
53
|
-
"slug": "hue"
|
|
54
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "Hue Difference",
|
|
3
|
-
"type": "function",
|
|
4
|
-
"description": "Calculates the angular difference between two color hues. Returns the shortest path around the hue circle (0-180°). Useful for determining how different two colors are in terms of hue alone, ignoring lightness and chroma.",
|
|
5
|
-
"keyword": "hue_difference",
|
|
6
|
-
"input": {
|
|
7
|
-
"type": "object",
|
|
8
|
-
"properties": {
|
|
9
|
-
"color1": {
|
|
10
|
-
"type": "color",
|
|
11
|
-
"description": "First color"
|
|
12
|
-
},
|
|
13
|
-
"color2": {
|
|
14
|
-
"type": "color",
|
|
15
|
-
"description": "Second color"
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
"script": {
|
|
20
|
-
"type": "https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/tokenscript/0/",
|
|
21
|
-
"script": "// Hue Difference\n// Calculates angular hue difference using shortest path\n//\n// The hue circle wraps at 360°, so we need to find\n// the shortest angular distance between two hues.\n//\n// Examples:\n// hue_diff(350°, 10°) = 20° (not 340°)\n// hue_diff(0°, 180°) = 180° (maximum difference)\n// hue_diff(90°, 90°) = 0° (same hue)\n//\n// Returns value in range [0, 180]\n\nvariable input: List = {input};\nvariable color1: Color.OKLCH = input.get(0).to.oklch();\nvariable color2: Color.OKLCH = input.get(1).to.oklch();\n\n// Get hue values\nvariable h1: Number = color1.h;\nvariable h2: Number = color2.h;\n\n// Normalize to 0-360\nif (h1 < 0) [ h1 = h1 + 360; ];\nif (h1 >= 360) [ h1 = h1 - 360; ];\nif (h2 < 0) [ h2 = h2 + 360; ];\nif (h2 >= 360) [ h2 = h2 - 360; ];\n\n// Calculate raw difference\nvariable diff: Number = h1 - h2;\n\n// Make positive\nif (diff < 0) [\n diff = 0 - diff;\n];\n\n// Take shortest path around circle\nif (diff > 180) [\n diff = 360 - diff;\n];\n\nreturn diff;"
|
|
22
|
-
},
|
|
23
|
-
"requirements": [
|
|
24
|
-
"https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/oklch-color/0/"
|
|
25
|
-
],
|
|
26
|
-
"slug": "hue_difference"
|
|
27
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "In Gamut",
|
|
3
|
-
"type": "function",
|
|
4
|
-
"description": "Checks if a color is within the sRGB gamut. Returns true if all RGB components are in [0,1] range, false otherwise. Useful for checking if colors from wider gamuts (P3, OKLab) can be displayed on standard monitors.",
|
|
5
|
-
"keyword": "in_gamut",
|
|
6
|
-
"input": {
|
|
7
|
-
"type": "object",
|
|
8
|
-
"properties": {
|
|
9
|
-
"color": {
|
|
10
|
-
"type": "color",
|
|
11
|
-
"description": "Color to check"
|
|
12
|
-
},
|
|
13
|
-
"epsilon": {
|
|
14
|
-
"type": "number",
|
|
15
|
-
"description": "Tolerance for near-gamut colors (default 0.000075)"
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
"script": {
|
|
20
|
-
"type": "https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/tokenscript/0/",
|
|
21
|
-
"script": "// In Gamut Check\n// Checks if a color is within the sRGB gamut\n// Reference: Color.js inGamut implementation\n//\n// sRGB gamut is defined by all RGB components being in [0, 1]\n// This is critical for determining if colors can be displayed\n// on standard monitors without clipping.\n//\n// An epsilon tolerance is used to handle floating-point precision\n// issues near the gamut boundary.\n\nvariable input: List = {input};\nvariable color: Color.SRGB = input.get(0).to.srgb();\n\n// Default epsilon from Color.js\nvariable epsilon: Number = 0.000075;\nif (input.length() > 1) [\n epsilon = input.get(1);\n];\n\n// Get RGB values\nvariable r: Number = color.r;\nvariable g: Number = color.g;\nvariable b: Number = color.b;\n\n// Check if within gamut bounds with epsilon tolerance\nvariable min_bound: Number = 0 - epsilon;\nvariable max_bound: Number = 1 + epsilon;\n\n// All channels must be within bounds\nvariable r_in: Boolean = r >= min_bound;\nif (r_in) [ r_in = r <= max_bound; ];\n\nvariable g_in: Boolean = g >= min_bound;\nif (g_in) [ g_in = g <= max_bound; ];\n\nvariable b_in: Boolean = b >= min_bound;\nif (b_in) [ b_in = b <= max_bound; ];\n\n// Return true only if all channels are in gamut\nvariable result: Boolean = false;\nif (r_in) [\n if (g_in) [\n if (b_in) [\n result = true;\n ];\n ];\n];\n\nreturn result;"
|
|
22
|
-
},
|
|
23
|
-
"requirements": [
|
|
24
|
-
"https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/srgb-color/0/"
|
|
25
|
-
],
|
|
26
|
-
"slug": "in_gamut"
|
|
27
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "interpolate",
|
|
3
|
-
"type": "function",
|
|
4
|
-
"description": "Interpolates between two colors at a given position in perceptual OKLCH space. Position of 0 returns the first color, 1 returns the second color, 0.5 returns the midpoint. Uses shortest-path hue interpolation for natural color transitions.",
|
|
5
|
-
"keyword": "interpolate",
|
|
6
|
-
"requirements": [
|
|
7
|
-
"https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/srgb-color/0/",
|
|
8
|
-
"https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/oklch-color/0/"
|
|
9
|
-
],
|
|
10
|
-
"schema": {
|
|
11
|
-
"type": "object",
|
|
12
|
-
"properties": {
|
|
13
|
-
"input": {
|
|
14
|
-
"type": "array",
|
|
15
|
-
"items": [
|
|
16
|
-
{
|
|
17
|
-
"description": "Start color",
|
|
18
|
-
"type": "color"
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
"description": "End color",
|
|
22
|
-
"type": "color"
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
"description": "Position (0-1, default 0.5)",
|
|
26
|
-
"type": "number"
|
|
27
|
-
}
|
|
28
|
-
],
|
|
29
|
-
"minItems": 2,
|
|
30
|
-
"maxItems": 3
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
"required": [
|
|
34
|
-
"input"
|
|
35
|
-
]
|
|
36
|
-
},
|
|
37
|
-
"returns": {
|
|
38
|
-
"type": "color",
|
|
39
|
-
"description": "Interpolated color"
|
|
40
|
-
},
|
|
41
|
-
"script": {
|
|
42
|
-
"type": "https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/tokenscript/0/",
|
|
43
|
-
"script": "// interpolate: Blend between two colors in perceptual space\n// Reference: CSS Color Level 4 Color Interpolation\n// Reference: https://www.w3.org/TR/css-color-4/#interpolation\n//\n// Performs linear interpolation in OKLCH space with shortest-path\n// hue interpolation. OKLCH provides perceptually uniform results.\n//\n// Parameters:\n// start - First color (t=0)\n// end - Second color (t=1)\n// t - Interpolation factor [0, 1], default 0.5\n//\n// Input: Any color space (converted to OKLCH internally)\n// Output: OKLCH (working space)\n// To get sRGB: interpolate(start, end, 0.5).to.srgb()\n\nvariable input: List = {input};\nvariable start: Color.OKLCH = input.get(0).to.oklch();\nvariable end: Color.OKLCH = input.get(1).to.oklch();\n\n// Default to midpoint\nvariable t: Number = 0.5;\nif (input.length() > 2) [\n t = input.get(2);\n];\n\n// Clamp t to valid range\nif (t < 0) [ t = 0; ];\nif (t > 1) [ t = 1; ];\n\n// Interpolate lightness and chroma linearly\nvariable result_l: Number = start.l + (end.l - start.l) * t;\nvariable result_c: Number = start.c + (end.c - start.c) * t;\n\n// Interpolate hue using shortest path\nvariable h1: Number = start.h;\nvariable h2: Number = end.h;\nvariable delta_h: Number = h2 - h1;\n\n// Normalize to shortest path around the circle\nif (delta_h > 180) [\n delta_h = delta_h - 360;\n];\nif (delta_h < -180) [\n delta_h = delta_h + 360;\n];\n\nvariable result_h: Number = h1 + delta_h * t;\n\n// Normalize result hue to 0-360\nif (result_h < 0) [ result_h = result_h + 360; ];\nif (result_h >= 360) [ result_h = result_h - 360; ];\n\n// Create result\nvariable result: Color.OKLCH;\nresult.l = result_l;\nresult.c = result_c;\nresult.h = result_h;\n\nreturn result;"
|
|
44
|
-
},
|
|
45
|
-
"examples": [
|
|
46
|
-
{
|
|
47
|
-
"description": "Midpoint between red and blue",
|
|
48
|
-
"input": [
|
|
49
|
-
"#ff0000",
|
|
50
|
-
"#0000ff",
|
|
51
|
-
0.5
|
|
52
|
-
],
|
|
53
|
-
"output": "Purple-ish color in OKLCH"
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
"description": "Quarter way from black to white",
|
|
57
|
-
"input": [
|
|
58
|
-
"#000000",
|
|
59
|
-
"#ffffff",
|
|
60
|
-
0.25
|
|
61
|
-
],
|
|
62
|
-
"output": "Dark gray"
|
|
63
|
-
}
|
|
64
|
-
],
|
|
65
|
-
"slug": "interpolate"
|
|
66
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "Invert Color",
|
|
3
|
-
"type": "function",
|
|
4
|
-
"description": "Inverts a color by inverting each RGB channel (R' = 255 - R, G' = 255 - G, B' = 255 - B).",
|
|
5
|
-
"keyword": "invert",
|
|
6
|
-
"input": {
|
|
7
|
-
"type": "object",
|
|
8
|
-
"properties": {
|
|
9
|
-
"color": {
|
|
10
|
-
"type": "color",
|
|
11
|
-
"description": "The color to invert."
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
"script": {
|
|
16
|
-
"type": "https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/tokenscript/0/",
|
|
17
|
-
"script": "// Invert Color Function\n// Returns the inverse/negative of a color by subtracting each RGB channel from 255\n//\n// Algorithm:\n// R' = 255 - R\n// G' = 255 - G \n// B' = 255 - B\n//\n// Use cases:\n// - Creating negative images\n// - High contrast accessibility variants\n// - Artistic color effects\n//\n// Input: Any color (converted to RGB internally)\n// Output: Color.Rgb with inverted channels\n\nvariable input: List = {input};\n\n// Convert input to RGB (0-255 range)\nvariable rgb_color: Color.Rgb = input.get(0).to.rgb();\n\n// Invert each channel by subtracting from 255\nvariable inverted_r: Number = 255 - rgb_color.r;\nvariable inverted_g: Number = 255 - rgb_color.g;\nvariable inverted_b: Number = 255 - rgb_color.b;\n\n// Create and return the inverted color\nvariable inverted_color: Color.Rgb = rgb(inverted_r, inverted_g, inverted_b);\nreturn inverted_color;"
|
|
18
|
-
},
|
|
19
|
-
"requirements": [
|
|
20
|
-
"https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/rgb-color/0/"
|
|
21
|
-
],
|
|
22
|
-
"slug": "invert"
|
|
23
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "Is Cool",
|
|
3
|
-
"type": "function",
|
|
4
|
-
"description": "Checks if a color is perceptually cool. Cool colors have hues in the green-blue-purple range (roughly 130-320° in OKLCH). Returns true for cool colors (green, cyan, blue, purple), false for warm colors. Achromatic colors are considered neutral/cool.",
|
|
5
|
-
"keyword": "is_cool",
|
|
6
|
-
"input": {
|
|
7
|
-
"type": "object",
|
|
8
|
-
"properties": {
|
|
9
|
-
"color": {
|
|
10
|
-
"type": "color",
|
|
11
|
-
"description": "Color to check"
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
"script": {
|
|
16
|
-
"type": "https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/tokenscript/0/",
|
|
17
|
-
"script": "// Is Cool Color\n// Determines if a color is perceptually cool\n//\n// Cool colors are associated with:\n// - Water, ice, sky\n// - Calm, professional, trustworthy feelings\n// - Receding visual perception (appear further away)\n//\n// OKLCH hue ranges:\n// - Cool: 130-320° (yellow-green through purple)\n// - Includes: green, cyan, blue, purple\n//\n// Achromatic colors (low chroma) are considered cool/neutral\n\nvariable input: List = {input};\nvariable color: Color.OKLCH = input.get(0).to.oklch();\n\n// Get hue and chroma\nvariable h: Number = color.h;\nvariable c: Number = color.c;\n\n// Achromatic colors (very low chroma) are considered cool/neutral\nif (c < 0.02) [\n return true;\n];\n\n// Normalize hue to 0-360\nif (h < 0) [ h = h + 360; ];\nif (h >= 360) [ h = h - 360; ];\n\n// Cool hue range: 130-320° (green through purple)\nvariable is_cool: Boolean = false;\n\nif (h > 130) [\n if (h < 320) [\n is_cool = true;\n ];\n];\n\nreturn is_cool;"
|
|
18
|
-
},
|
|
19
|
-
"requirements": [
|
|
20
|
-
"https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/oklch-color/0/"
|
|
21
|
-
],
|
|
22
|
-
"slug": "is_cool"
|
|
23
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "Is Dark",
|
|
3
|
-
"type": "function",
|
|
4
|
-
"description": "Returns true if a color is perceptually dark (lightness <= threshold). Uses OKLCH lightness for perceptual accuracy. Default threshold is 0.6.",
|
|
5
|
-
"keyword": "is_dark",
|
|
6
|
-
"input": {
|
|
7
|
-
"type": "object",
|
|
8
|
-
"properties": {
|
|
9
|
-
"color": {
|
|
10
|
-
"type": "color",
|
|
11
|
-
"description": "The color to check"
|
|
12
|
-
},
|
|
13
|
-
"threshold": {
|
|
14
|
-
"type": "number",
|
|
15
|
-
"description": "Lightness threshold (0-1). Default is 0.6"
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
"script": {
|
|
20
|
-
"type": "https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/tokenscript/0/",
|
|
21
|
-
"script": "// Check if a color is perceptually dark\n// Uses OKLCH lightness for accurate perception matching\n//\n// Returns: true if L <= threshold, false otherwise\n// Default threshold: 0.6 (slightly above middle)\n\nvariable input: List = {input};\nvariable color: Color.OKLCH = input.get(0).to.oklch();\n\nvariable threshold: Number = 0.6;\nif (input.length() > 1) [\n threshold = input.get(1);\n];\n\nreturn color.l <= threshold;"
|
|
22
|
-
},
|
|
23
|
-
"requirements": [
|
|
24
|
-
"https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/oklch-color/0/"
|
|
25
|
-
],
|
|
26
|
-
"slug": "is_dark"
|
|
27
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "Is Light",
|
|
3
|
-
"type": "function",
|
|
4
|
-
"description": "Returns true if a color is perceptually light (lightness > threshold). Uses OKLCH lightness for perceptual accuracy. Default threshold is 0.6.",
|
|
5
|
-
"keyword": "is_light",
|
|
6
|
-
"input": {
|
|
7
|
-
"type": "object",
|
|
8
|
-
"properties": {
|
|
9
|
-
"color": {
|
|
10
|
-
"type": "color",
|
|
11
|
-
"description": "The color to check"
|
|
12
|
-
},
|
|
13
|
-
"threshold": {
|
|
14
|
-
"type": "number",
|
|
15
|
-
"description": "Lightness threshold (0-1). Default is 0.6"
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
"script": {
|
|
20
|
-
"type": "https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/tokenscript/0/",
|
|
21
|
-
"script": "// Check if a color is perceptually light\n// Uses OKLCH lightness for accurate perception matching\n//\n// Returns: true if L > threshold, false otherwise\n// Default threshold: 0.6 (slightly above middle)\n\nvariable input: List = {input};\nvariable color: Color.OKLCH = input.get(0).to.oklch();\n\nvariable threshold: Number = 0.6;\nif (input.length() > 1) [\n threshold = input.get(1);\n];\n\nreturn color.l > threshold;"
|
|
22
|
-
},
|
|
23
|
-
"requirements": [
|
|
24
|
-
"https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/oklch-color/0/"
|
|
25
|
-
],
|
|
26
|
-
"slug": "is_light"
|
|
27
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "is_neutral",
|
|
3
|
-
"type": "function",
|
|
4
|
-
"description": "Determines if a color is achromatic (neutral/gray). Uses OKLCH chroma value - colors with very low chroma are considered neutral regardless of their hue. Default threshold of 0.02 allows for near-neutral colors that appear gray to human observers.",
|
|
5
|
-
"keyword": "is_neutral",
|
|
6
|
-
"requirements": [
|
|
7
|
-
"https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/srgb-color/0/",
|
|
8
|
-
"https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/oklch-color/0/"
|
|
9
|
-
],
|
|
10
|
-
"schema": {
|
|
11
|
-
"type": "object",
|
|
12
|
-
"properties": {
|
|
13
|
-
"input": {
|
|
14
|
-
"type": "array",
|
|
15
|
-
"items": [
|
|
16
|
-
{
|
|
17
|
-
"description": "Color to test",
|
|
18
|
-
"type": "color"
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
"description": "Chroma threshold (default 0.02). Lower = stricter.",
|
|
22
|
-
"type": "number"
|
|
23
|
-
}
|
|
24
|
-
],
|
|
25
|
-
"minItems": 1,
|
|
26
|
-
"maxItems": 2
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
"required": [
|
|
30
|
-
"input"
|
|
31
|
-
]
|
|
32
|
-
},
|
|
33
|
-
"returns": {
|
|
34
|
-
"type": "boolean",
|
|
35
|
-
"description": "True if color is achromatic/neutral"
|
|
36
|
-
},
|
|
37
|
-
"script": {
|
|
38
|
-
"type": "https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/tokenscript/0/",
|
|
39
|
-
"script": "// is_neutral: Check if a color is achromatic (gray)\n// Uses OKLCH chroma - low chroma means neutral\n// Threshold of 0.02 allows for near-neutral colors\n\nvariable input: List = {input};\nvariable color: Color.OKLCH = input.get(0).to.oklch();\n\n// Default chroma threshold\nvariable threshold: Number = 0.02;\nif (input.length() > 1) [\n threshold = input.get(1);\n];\n\n// Color is neutral if chroma is below threshold\nreturn color.c < threshold;"
|
|
40
|
-
},
|
|
41
|
-
"examples": [
|
|
42
|
-
{
|
|
43
|
-
"description": "Pure gray is neutral",
|
|
44
|
-
"input": [
|
|
45
|
-
"#808080"
|
|
46
|
-
],
|
|
47
|
-
"output": true
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
"description": "Pure red is not neutral",
|
|
51
|
-
"input": [
|
|
52
|
-
"#ff0000"
|
|
53
|
-
],
|
|
54
|
-
"output": false
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
"description": "Desaturated color may be neutral",
|
|
58
|
-
"input": [
|
|
59
|
-
"#7a7a7c"
|
|
60
|
-
],
|
|
61
|
-
"output": true
|
|
62
|
-
}
|
|
63
|
-
],
|
|
64
|
-
"slug": "is_neutral"
|
|
65
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "Is Warm",
|
|
3
|
-
"type": "function",
|
|
4
|
-
"description": "Checks if a color is perceptually warm. Uses OKLCH color space where warm colors have hues in the red-yellow range (roughly 0-130° and 320-360°). Returns true for warm colors (red, orange, yellow), false for cool colors (green, cyan, blue, purple). Achromatic colors are considered neutral/cool.",
|
|
5
|
-
"keyword": "is_warm",
|
|
6
|
-
"input": {
|
|
7
|
-
"type": "object",
|
|
8
|
-
"properties": {
|
|
9
|
-
"color": {
|
|
10
|
-
"type": "color",
|
|
11
|
-
"description": "Color to check"
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
"script": {
|
|
16
|
-
"type": "https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/tokenscript/0/",
|
|
17
|
-
"script": "// Is Warm Color\n// Determines if a color is perceptually warm or cool\n//\n// Color Temperature Psychology:\n// - Warm colors: Red, orange, yellow (associated with fire, sun)\n// - Cool colors: Blue, green, purple (associated with water, ice)\n//\n// Hue ranges (in OKLCH/HSL degrees):\n// - Warm: roughly 0-90° (red through yellow) and 330-360° (red-magenta)\n// - Cool: roughly 90-330° (yellow-green through purple)\n//\n// Achromatic colors (low chroma) are considered neutral\n// and return false (lean towards cool for safety in accessibility)\n\nvariable input: List = {input};\nvariable color: Color.OKLCH = input.get(0).to.oklch();\n\n// Get hue and chroma\nvariable h: Number = color.h;\nvariable c: Number = color.c;\n\n// Achromatic colors (very low chroma) are neutral\n// Return false (cool) for these\nif (c < 0.02) [\n return false;\n];\n\n// Normalize hue to 0-360\nif (h < 0) [ h = h + 360; ];\nif (h >= 360) [ h = h - 360; ];\n\n// OKLCH Warm hue ranges:\n// In OKLCH, hue angles differ from HSL:\n// - Red: ~29°\n// - Orange: ~53°\n// - Yellow: ~110°\n// - Yellow-green: ~130°\n// - Green: ~145°\n// - Cyan: ~195°\n// - Blue: ~265°\n// - Purple: ~300°\n// - Magenta: ~330°\n//\n// Warm colors: 0-130° (red through yellow-green) and 320-360° (magenta-red)\nvariable is_warm: Boolean = false;\n\n// Check 0-130 range (red through yellow to yellow-green)\nif (h >= 0) [\n if (h <= 130) [\n is_warm = true;\n ];\n];\n\n// Check 320-360 range (magenta-red)\nif (h >= 320) [\n if (h <= 360) [\n is_warm = true;\n ];\n];\n\nreturn is_warm;"
|
|
18
|
-
},
|
|
19
|
-
"requirements": [
|
|
20
|
-
"https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/oklch-color/0/"
|
|
21
|
-
],
|
|
22
|
-
"slug": "is_warm"
|
|
23
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "Lighten",
|
|
3
|
-
"type": "function",
|
|
4
|
-
"description": "Makes a color lighter by increasing its lightness in OKLab space. Amount is 0-1 where 0.25 = 25% lighter.",
|
|
5
|
-
"keyword": "lighten",
|
|
6
|
-
"input": {
|
|
7
|
-
"type": "object",
|
|
8
|
-
"properties": {
|
|
9
|
-
"color": {
|
|
10
|
-
"type": "color",
|
|
11
|
-
"description": "The color to lighten"
|
|
12
|
-
},
|
|
13
|
-
"amount": {
|
|
14
|
-
"type": "number",
|
|
15
|
-
"description": "Amount to lighten (0-1). Default is 0.25"
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
"script": {
|
|
20
|
-
"type": "https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/tokenscript/0/",
|
|
21
|
-
"script": "// lighten: Increase lightness proportionally towards white\n// Amount: 0-1 where 0.25 means 25% closer to white\n//\n// Algorithm: L' = L + (1 - L) * amount\n// This ensures we approach white (L=1) proportionally.\n//\n// Input: Any color space (converted to OKLab internally)\n// Output: OKLCH (working space)\n// To get sRGB: lighten(color, 0.25).to.srgb()\n\nvariable input: List = {input};\nvariable color: Color.OKLab = input.get(0).to.oklab();\n\n// Default amount is 0.25 (25%)\nvariable amount: Number = 0.25;\nif (input.length() > 1) [\n amount = input.get(1);\n];\n\n// Calculate new lightness (move toward 1)\nvariable current_l: Number = color.l;\nvariable new_l: Number = current_l + (1 - current_l) * amount;\n\n// Clamp to valid range\nif (new_l > 1) [ new_l = 1; ];\n\n// Create output in OKLab, return as OKLCH (working space)\nvariable result: Color.OKLab;\nresult.l = new_l;\nresult.a = color.a;\nresult.b = color.b;\n\nreturn result.to.oklch();"
|
|
22
|
-
},
|
|
23
|
-
"requirements": [
|
|
24
|
-
"https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/oklab-color/0/",
|
|
25
|
-
"https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/srgb-color/0/"
|
|
26
|
-
],
|
|
27
|
-
"slug": "lighten"
|
|
28
|
-
}
|