@tokens-studio/tokenscript-schemas 0.0.10

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.
@@ -0,0 +1,183 @@
1
+ {
2
+ "version": "0.0.10",
3
+ "types": [
4
+ {
5
+ "name": "Hex",
6
+ "type": "color",
7
+ "description": "A color in hex format, e.g. #ff0000",
8
+ "schema": {
9
+ "type": "object",
10
+ "properties": {
11
+ "value": {
12
+ "type": "string"
13
+ }
14
+ }
15
+ },
16
+ "initializers": [
17
+ {
18
+ "title": "Hex Color Initializer",
19
+ "keyword": "hex",
20
+ "script": {
21
+ "type": "https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/tokenscript/0/",
22
+ "script": "variable c: Color.Hex;\nc.value = {input};\nreturn c;"
23
+ }
24
+ }
25
+ ],
26
+ "conversions": [],
27
+ "slug": "hex-color"
28
+ },
29
+ {
30
+ "name": "Rgb",
31
+ "type": "color",
32
+ "description": "RGB color",
33
+ "schema": {
34
+ "type": "object",
35
+ "properties": {
36
+ "r": {
37
+ "type": "number"
38
+ },
39
+ "g": {
40
+ "type": "number"
41
+ },
42
+ "b": {
43
+ "type": "number"
44
+ }
45
+ },
46
+ "required": [
47
+ "r",
48
+ "g",
49
+ "b"
50
+ ],
51
+ "order": [
52
+ "r",
53
+ "g",
54
+ "b"
55
+ ],
56
+ "additionalProperties": false
57
+ },
58
+ "initializers": [
59
+ {
60
+ "title": "function",
61
+ "keyword": "rgb",
62
+ "description": "Creates an RGB color",
63
+ "script": {
64
+ "type": "https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/tokenscript/0/",
65
+ "script": "variable color_parts: List = {input}; \nvariable output: Color.Rgb;\noutput.r = color_parts.get(0);\noutput.g = color_parts.get(1);\noutput.b = color_parts.get(2);\nreturn output;"
66
+ }
67
+ }
68
+ ],
69
+ "conversions": [
70
+ {
71
+ "source": "https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/hex-color/0/",
72
+ "target": "$self",
73
+ "description": "Converts HEX to RGB",
74
+ "lossless": true,
75
+ "script": {
76
+ "type": "https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/tokenscript/0/",
77
+ "script": "variable color_parts: List = {input}.to_string().split('#'); \nvariable color: List = color_parts.get(1).split(); \nvariable length: Number = color.length(); \nvariable rgb: List = 0, 0, 0; \nif(length == 3) [ \n rgb.update(0, parse_int(color.get(0).concat(color.get(0)), 16)); \n rgb.update(1, parse_int(color.get(1).concat(color.get(1)), 16)); \n rgb.update(2, parse_int(color.get(2).concat(color.get(2)), 16)); \n] else [ \n rgb.update(0, parse_int(color.get(0).concat(color.get(1)), 16)); \n rgb.update(1, parse_int(color.get(2).concat(color.get(3)), 16)); \n rgb.update(2, parse_int(color.get(4).concat(color.get(5)), 16)); \n]; \n\nvariable output: Color.Rgb; \noutput.r = rgb.get(0); \noutput.g = rgb.get(1); \noutput.b = rgb.get(2); \n\nreturn output;"
78
+ }
79
+ },
80
+ {
81
+ "source": "$self",
82
+ "target": "https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/hex-color/0/",
83
+ "description": "Converts RGB to HEX",
84
+ "lossless": true,
85
+ "script": {
86
+ "type": "https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/tokenscript/0/",
87
+ "script": "variable rgba: List = {input}.r, {input}.g, {input}.b;\nvariable hex: String = \"#\";\nvariable i: Number = 0;\nvariable value: Number = 0;\n\n// Convert RGBA to Hex\nwhile( i < min(rgba.length(), 3)) [\n value = round(rgba.get(i));\n if(value < 16) [\n hex = hex.concat(\"0\").concat(value.to_string(16));\n ] else [\n hex = hex.concat(value.to_string(16));\n ];\n i = i + 1;\n];\n\nif (rgba.length() == 4) [\n value = rgba.get(3) * 255; // Convert alpha to 0-255 range\n if(value < 16) [\n hex = hex.concat(\"0\").concat(value.to_string(16));\n ] else [\n hex = hex.concat(value.to_string(16));\n ];\n];\n\nreturn hex;"
88
+ }
89
+ }
90
+ ],
91
+ "slug": "rgb-color"
92
+ },
93
+ {
94
+ "name": "Rgba",
95
+ "type": "color",
96
+ "description": "RGBA color",
97
+ "schema": {
98
+ "type": "object",
99
+ "properties": {
100
+ "r": {
101
+ "type": "number"
102
+ },
103
+ "g": {
104
+ "type": "number"
105
+ },
106
+ "b": {
107
+ "type": "number"
108
+ },
109
+ "a": {
110
+ "type": "number"
111
+ }
112
+ },
113
+ "required": [
114
+ "r",
115
+ "g",
116
+ "b",
117
+ "a"
118
+ ],
119
+ "order": [
120
+ "r",
121
+ "g",
122
+ "b",
123
+ "a"
124
+ ],
125
+ "additionalProperties": false
126
+ },
127
+ "initializers": [
128
+ {
129
+ "title": "function",
130
+ "keyword": "rgba",
131
+ "description": "Creates an RGBA color",
132
+ "script": {
133
+ "type": "https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/tokenscript/0/",
134
+ "script": "variable color_parts: List = {input};\nvariable output: Color.Rgba;\noutput.r = color_parts.get(0);\noutput.g = color_parts.get(1);\noutput.b = color_parts.get(2);\noutput.a = color_parts.get(3);\nreturn output;"
135
+ }
136
+ }
137
+ ],
138
+ "conversions": [
139
+ {
140
+ "source": "https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/hex-color/0/",
141
+ "target": "$self",
142
+ "description": "Converts HEX to RGBA",
143
+ "lossless": true,
144
+ "script": {
145
+ "type": "https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/tokenscript/0/",
146
+ "script": "variable color_parts: List = {input}.to_string().split('#');\nvariable color: List = color_parts.get(1).split();\nvariable length: Number = color.length();\nvariable rgba: List = 0, 0, 0, 1.0;\nif(length == 3) [\n rgba.update(0, parse_int(color.get(0).concat(color.get(0)), 16));\n rgba.update(1, parse_int(color.get(1).concat(color.get(1)), 16));\n rgba.update(2, parse_int(color.get(2).concat(color.get(2)), 16));\n] else [\n rgba.update(0, parse_int(color.get(0).concat(color.get(1)), 16));\n rgba.update(1, parse_int(color.get(2).concat(color.get(3)), 16));\n rgba.update(2, parse_int(color.get(4).concat(color.get(5)), 16));\n];\n\nvariable output: Color.Rgba;\noutput.r = rgba.get(0);\noutput.g = rgba.get(1);\noutput.b = rgba.get(2);\noutput.a = rgba.get(3);\n\nreturn output;"
147
+ }
148
+ },
149
+ {
150
+ "source": "$self",
151
+ "target": "https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/hex-color/0/",
152
+ "description": "Converts RGBA to HEX",
153
+ "lossless": false,
154
+ "script": {
155
+ "type": "https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/tokenscript/0/",
156
+ "script": "variable rgba: List = {input}.r, {input}.g, {input}.b;\nvariable hex: String = \"#\";\nvariable i: Number = 0;\nvariable value: Number = 0;\n\n// Convert RGBA to Hex (excluding alpha)\nwhile( i < rgba.length()) [\n value = round(rgba.get(i));\n if(value < 16) [\n hex = hex.concat(\"0\").concat(value.to_string(16));\n ] else [\n hex = hex.concat(value.to_string(16));\n ];\n i = i + 1;\n];\n\nreturn hex;"
157
+ }
158
+ },
159
+ {
160
+ "source": "https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/rgb-color/0/",
161
+ "target": "$self",
162
+ "description": "Converts RGB to RGBA",
163
+ "lossless": true,
164
+ "script": {
165
+ "type": "https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/tokenscript/0/",
166
+ "script": "variable output: Color.Rgba;\noutput.r = {input}.r;\noutput.g = {input}.g;\noutput.b = {input}.b;\noutput.a = 1.0;\nreturn output;"
167
+ }
168
+ },
169
+ {
170
+ "source": "$self",
171
+ "target": "https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/rgb-color/0/",
172
+ "description": "Converts RGBA to RGB",
173
+ "lossless": false,
174
+ "script": {
175
+ "type": "https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/tokenscript/0/",
176
+ "script": "variable output: Color.Rgb;\noutput.r = {input}.r;\noutput.g = {input}.g;\noutput.b = {input}.b;\nreturn output;"
177
+ }
178
+ }
179
+ ],
180
+ "slug": "rgba-color"
181
+ }
182
+ ]
183
+ }