material 3.7.2 → 3.8.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.
Files changed (313) hide show
  1. package/NOTICE +223 -0
  2. package/README.md +5 -3
  3. package/dist/components/extended-fab/types.d.ts +3 -0
  4. package/dist/components/fab/types.d.ts +3 -0
  5. package/dist/components/slider/features/controller.js +24 -8
  6. package/dist/elements/css/card.css +1 -1
  7. package/dist/elements/css/card.js +1 -1
  8. package/dist/elements/css/dialog.css +1 -1
  9. package/dist/elements/css/dialog.js +1 -1
  10. package/dist/elements/css/menu.css +1 -1
  11. package/dist/elements/css/menu.js +1 -1
  12. package/dist/elements/css/select.css +1 -1
  13. package/dist/elements/css/select.js +1 -1
  14. package/dist/elements/css/slider.css +1 -1
  15. package/dist/elements/css/slider.js +1 -1
  16. package/dist/elements/css/tabs.css +1 -1
  17. package/dist/elements/css/tabs.js +1 -1
  18. package/dist/elements/css/timepicker.css +1 -1
  19. package/dist/elements/css/timepicker.js +1 -1
  20. package/dist/elements/extended-fab.d.ts +1 -0
  21. package/dist/elements/fab.d.ts +1 -0
  22. package/dist/elements/preupgrade/badge.css +1 -1
  23. package/dist/elements/preupgrade/bottom-app-bar.css +1 -1
  24. package/dist/elements/preupgrade/bottom-sheet.css +1 -1
  25. package/dist/elements/preupgrade/button-group.css +1 -1
  26. package/dist/elements/preupgrade/button.css +1 -1
  27. package/dist/elements/preupgrade/card.css +1 -1
  28. package/dist/elements/preupgrade/carousel.css +1 -1
  29. package/dist/elements/preupgrade/checkbox.css +1 -1
  30. package/dist/elements/preupgrade/chips.css +1 -1
  31. package/dist/elements/preupgrade/datepicker.css +1 -1
  32. package/dist/elements/preupgrade/dialog.css +1 -1
  33. package/dist/elements/preupgrade/divider.css +1 -1
  34. package/dist/elements/preupgrade/drawer.css +1 -1
  35. package/dist/elements/preupgrade/extended-fab.css +1 -1
  36. package/dist/elements/preupgrade/fab-menu.css +1 -1
  37. package/dist/elements/preupgrade/fab.css +1 -1
  38. package/dist/elements/preupgrade/icon-button.css +1 -1
  39. package/dist/elements/preupgrade/list.css +1 -1
  40. package/dist/elements/preupgrade/loading-indicator.css +1 -1
  41. package/dist/elements/preupgrade/menu.css +1 -1
  42. package/dist/elements/preupgrade/navigation-bar.css +1 -1
  43. package/dist/elements/preupgrade/navigation-rail.css +1 -1
  44. package/dist/elements/preupgrade/progress.css +1 -1
  45. package/dist/elements/preupgrade/radios.css +1 -1
  46. package/dist/elements/preupgrade/search.css +1 -1
  47. package/dist/elements/preupgrade/select.css +1 -1
  48. package/dist/elements/preupgrade/side-sheet.css +1 -1
  49. package/dist/elements/preupgrade/slider.css +1 -1
  50. package/dist/elements/preupgrade/snackbar.css +1 -1
  51. package/dist/elements/preupgrade/split-button.css +1 -1
  52. package/dist/elements/preupgrade/switch.css +1 -1
  53. package/dist/elements/preupgrade/tabs.css +1 -1
  54. package/dist/elements/preupgrade/text-field.css +1 -1
  55. package/dist/elements/preupgrade/timepicker.css +1 -1
  56. package/dist/elements/preupgrade/toolbar.css +1 -1
  57. package/dist/elements/preupgrade/tooltip.css +1 -1
  58. package/dist/elements/preupgrade/top-app-bar.css +1 -1
  59. package/dist/elements/preupgrade.css +1 -1
  60. package/dist/styles/badge.css +1 -1
  61. package/dist/styles/base-lite.css +2 -2
  62. package/dist/styles/base.css +2 -2
  63. package/dist/styles/bottom-app-bar.css +1 -1
  64. package/dist/styles/bottom-sheet.css +1 -1
  65. package/dist/styles/button-group.css +1 -1
  66. package/dist/styles/button.css +1 -1
  67. package/dist/styles/card.css +2 -2
  68. package/dist/styles/carousel.css +1 -1
  69. package/dist/styles/checkbox.css +1 -1
  70. package/dist/styles/chips.css +1 -1
  71. package/dist/styles/contrast.css +2 -2
  72. package/dist/styles/datepicker.css +1 -1
  73. package/dist/styles/dialog.css +2 -2
  74. package/dist/styles/divider.css +1 -1
  75. package/dist/styles/drawer.css +1 -1
  76. package/dist/styles/extended-fab.css +1 -1
  77. package/dist/styles/fab-menu.css +1 -1
  78. package/dist/styles/fab.css +1 -1
  79. package/dist/styles/icon-button.css +1 -1
  80. package/dist/styles/list.css +1 -1
  81. package/dist/styles/loading-indicator.css +1 -1
  82. package/dist/styles/menu.css +2 -2
  83. package/dist/styles/navigation-bar.css +1 -1
  84. package/dist/styles/navigation-rail.css +1 -1
  85. package/dist/styles/progress.css +1 -1
  86. package/dist/styles/radios.css +1 -1
  87. package/dist/styles/search.css +1 -1
  88. package/dist/styles/select.css +2 -2
  89. package/dist/styles/side-sheet.css +1 -1
  90. package/dist/styles/slider.css +2 -2
  91. package/dist/styles/snackbar.css +1 -1
  92. package/dist/styles/split-button.css +1 -1
  93. package/dist/styles/switch.css +1 -1
  94. package/dist/styles/tabs.css +2 -2
  95. package/dist/styles/text-field.css +1 -1
  96. package/dist/styles/timepicker.css +2 -2
  97. package/dist/styles/toolbar.css +1 -1
  98. package/dist/styles/tooltip.css +1 -1
  99. package/dist/styles/top-app-bar.css +1 -1
  100. package/dist/styles/typography.css +1 -1
  101. package/dist/styles/utilities.css +1 -1
  102. package/dist/styles.css +2 -2
  103. package/dist/theme/image.d.ts +2 -0
  104. package/dist/theme/image.js +5 -0
  105. package/dist/theme/index.d.ts +23 -0
  106. package/dist/theme/index.js +32 -0
  107. package/dist/theme/roles.js +68 -0
  108. package/dist/theme/variants.d.ts +9 -0
  109. package/dist/theme/variants.js +17 -0
  110. package/dist/theme/vendor/contrast/contrast.js +72 -0
  111. package/dist/theme/vendor/dislike/dislike_analyzer.js +31 -0
  112. package/dist/theme/vendor/dynamiccolor/color_spec_2021.d.ts +63 -0
  113. package/dist/theme/vendor/dynamiccolor/color_spec_2021.js +663 -0
  114. package/dist/theme/vendor/dynamiccolor/contrast_curve.js +42 -0
  115. package/dist/theme/vendor/dynamiccolor/dynamic_color.d.ts +24 -0
  116. package/dist/theme/vendor/dynamiccolor/dynamic_color.js +264 -0
  117. package/dist/theme/vendor/dynamiccolor/dynamic_scheme.d.ts +87 -0
  118. package/dist/theme/vendor/dynamiccolor/dynamic_scheme.js +418 -0
  119. package/dist/theme/vendor/dynamiccolor/material_dynamic_colors.d.ts +124 -0
  120. package/dist/theme/vendor/dynamiccolor/material_dynamic_colors.js +311 -0
  121. package/dist/theme/vendor/dynamiccolor/tone_delta_pair.js +27 -0
  122. package/dist/theme/vendor/dynamiccolor/variant.js +28 -0
  123. package/dist/theme/vendor/hct/cam16.js +249 -0
  124. package/dist/theme/vendor/hct/hct.d.ts +23 -0
  125. package/dist/theme/vendor/hct/hct.js +86 -0
  126. package/dist/theme/vendor/hct/hct_solver.js +390 -0
  127. package/dist/theme/vendor/hct/viewing_conditions.js +73 -0
  128. package/dist/theme/vendor/palettes/tonal_palette.js +114 -0
  129. package/dist/theme/vendor/quantize/lab_point_provider.js +31 -0
  130. package/dist/theme/vendor/quantize/quantizer_celebi.js +25 -0
  131. package/dist/theme/vendor/quantize/quantizer_map.js +31 -0
  132. package/dist/theme/vendor/quantize/quantizer_wsmeans.js +178 -0
  133. package/dist/theme/vendor/quantize/quantizer_wu.js +342 -0
  134. package/dist/theme/vendor/scheme/scheme_content.js +30 -0
  135. package/dist/theme/vendor/scheme/scheme_expressive.js +30 -0
  136. package/dist/theme/vendor/scheme/scheme_fidelity.js +30 -0
  137. package/dist/theme/vendor/scheme/scheme_monochrome.js +30 -0
  138. package/dist/theme/vendor/scheme/scheme_neutral.js +30 -0
  139. package/dist/theme/vendor/scheme/scheme_tonal_spot.js +30 -0
  140. package/dist/theme/vendor/scheme/scheme_vibrant.js +30 -0
  141. package/dist/theme/vendor/score/score.js +100 -0
  142. package/dist/theme/vendor/temperature/temperature_cache.js +198 -0
  143. package/dist/theme/vendor/utils/color_utils.js +173 -0
  144. package/dist/theme/vendor/utils/image_utils.js +72 -0
  145. package/dist/theme/vendor/utils/math_utils.js +75 -0
  146. package/dist/theme/vendor/utils/string_utils.js +61 -0
  147. package/dist/themes/autumn-contrast.css +2 -2
  148. package/dist/themes/autumn.css +2 -2
  149. package/dist/themes/baseline-contrast.css +2 -2
  150. package/dist/themes/baseline.css +2 -2
  151. package/dist/themes/brownbeige-contrast.css +2 -2
  152. package/dist/themes/brownbeige.css +2 -2
  153. package/dist/themes/content-contrast.css +2 -2
  154. package/dist/themes/content.css +2 -2
  155. package/dist/themes/desert-contrast.css +2 -2
  156. package/dist/themes/desert.css +2 -2
  157. package/dist/themes/expressive-contrast.css +2 -2
  158. package/dist/themes/expressive.css +2 -2
  159. package/dist/themes/fidelity-contrast.css +2 -2
  160. package/dist/themes/fidelity.css +2 -2
  161. package/dist/themes/forest-contrast.css +2 -2
  162. package/dist/themes/forest.css +2 -2
  163. package/dist/themes/fruit-salad-contrast.css +2 -2
  164. package/dist/themes/fruit-salad.css +2 -2
  165. package/dist/themes/highcontrast-contrast.css +2 -2
  166. package/dist/themes/highcontrast.css +2 -2
  167. package/dist/themes/monochrome-contrast.css +2 -2
  168. package/dist/themes/monochrome.css +2 -2
  169. package/dist/themes/neutral-contrast.css +2 -2
  170. package/dist/themes/neutral.css +2 -2
  171. package/dist/themes/ocean-contrast.css +2 -2
  172. package/dist/themes/ocean.css +2 -2
  173. package/dist/themes/rainbow-contrast.css +2 -2
  174. package/dist/themes/rainbow.css +2 -2
  175. package/dist/themes/sageivory-contrast.css +2 -2
  176. package/dist/themes/sageivory.css +2 -2
  177. package/dist/themes/spring-contrast.css +2 -2
  178. package/dist/themes/spring.css +2 -2
  179. package/dist/themes/summer-contrast.css +2 -2
  180. package/dist/themes/summer.css +2 -2
  181. package/dist/themes/sunset-contrast.css +2 -2
  182. package/dist/themes/sunset.css +2 -2
  183. package/dist/themes/tealcaramel-contrast.css +2 -2
  184. package/dist/themes/tealcaramel.css +2 -2
  185. package/dist/themes/vibrant-contrast.css +2 -2
  186. package/dist/themes/vibrant.css +2 -2
  187. package/package.json +15 -1
  188. package/src/styles/abstract/_base.scss +0 -1
  189. package/src/styles/abstract/_direction.scss +121 -152
  190. package/src/styles/abstract/_emit.scss +7 -16
  191. package/src/styles/abstract/_floating-placement.scss +9 -10
  192. package/src/styles/abstract/_functions.scss +64 -79
  193. package/src/styles/abstract/_mixins.scss +355 -459
  194. package/src/styles/abstract/_theme.scss +122 -136
  195. package/src/styles/abstract/_variables.scss +320 -390
  196. package/src/styles/abstract/chips/_assist.scss +2 -3
  197. package/src/styles/abstract/chips/_filter.scss +2 -3
  198. package/src/styles/abstract/chips/_input.scss +2 -3
  199. package/src/styles/abstract/chips/_suggestion.scss +2 -3
  200. package/src/styles/base/_body-theme.scss +10 -15
  201. package/src/styles/base/_document.scss +10 -33
  202. package/src/styles/base/_reset.scss +20 -40
  203. package/src/styles/base/_tokens.scss +6 -21
  204. package/src/styles/base/_typescale-tokens.scss +12 -16
  205. package/src/styles/base/_typography.scss +28 -37
  206. package/src/styles/components/_badge.scss +171 -193
  207. package/src/styles/components/_bottom-app-bar.scss +72 -90
  208. package/src/styles/components/_bottom-sheet.scss +188 -232
  209. package/src/styles/components/_button-group.scss +140 -189
  210. package/src/styles/components/_button.scss +382 -478
  211. package/src/styles/components/_card.scss +349 -473
  212. package/src/styles/components/_carousel.scss +134 -156
  213. package/src/styles/components/_checkbox.scss +208 -249
  214. package/src/styles/components/_chips.scss +239 -304
  215. package/src/styles/components/_datepicker.scss +172 -222
  216. package/src/styles/components/_dialog.scss +428 -553
  217. package/src/styles/components/_divider.scss +37 -46
  218. package/src/styles/components/_drawer.scss +571 -678
  219. package/src/styles/components/_extended-fab.scss +263 -294
  220. package/src/styles/components/_fab-menu.scss +225 -267
  221. package/src/styles/components/_fab.scss +197 -218
  222. package/src/styles/components/_icon-button.scss +483 -588
  223. package/src/styles/components/_list.scss +115 -144
  224. package/src/styles/components/_loading-indicator.scss +23 -29
  225. package/src/styles/components/_menu.scss +543 -699
  226. package/src/styles/components/_navigation-bar.scss +189 -234
  227. package/src/styles/components/_navigation-rail.scss +256 -312
  228. package/src/styles/components/_progress.scss +60 -85
  229. package/src/styles/components/_radios.scss +170 -207
  230. package/src/styles/components/_search.scss +369 -455
  231. package/src/styles/components/_select.scss +78 -185
  232. package/src/styles/components/_side-sheet.scss +234 -292
  233. package/src/styles/components/_slider.scss +289 -367
  234. package/src/styles/components/_snackbar.scss +149 -198
  235. package/src/styles/components/_split-button.scss +139 -228
  236. package/src/styles/components/_switch.scss +282 -349
  237. package/src/styles/components/_tabs.scss +350 -547
  238. package/src/styles/components/_text-field.scss +788 -980
  239. package/src/styles/components/_timepicker.scss +435 -506
  240. package/src/styles/components/_toolbar.scss +178 -242
  241. package/src/styles/components/_tooltip.scss +152 -197
  242. package/src/styles/components/_top-app-bar.scss +206 -230
  243. package/src/styles/elements/_badge.scss +42 -61
  244. package/src/styles/elements/_bottom-app-bar.scss +14 -20
  245. package/src/styles/elements/_bottom-sheet.scss +0 -3
  246. package/src/styles/elements/_button-group.scss +80 -80
  247. package/src/styles/elements/_button.scss +72 -88
  248. package/src/styles/elements/_card.scss +48 -57
  249. package/src/styles/elements/_carousel.scss +2 -5
  250. package/src/styles/elements/_checkbox.scss +32 -43
  251. package/src/styles/elements/_chips.scss +18 -22
  252. package/src/styles/elements/_config.scss +11 -26
  253. package/src/styles/elements/_datepicker.scss +17 -22
  254. package/src/styles/elements/_dialog.scss +0 -3
  255. package/src/styles/elements/_divider.scss +11 -13
  256. package/src/styles/elements/_drawer.scss +9 -14
  257. package/src/styles/elements/_extended-fab.scss +36 -40
  258. package/src/styles/elements/_fab-menu.scss +21 -25
  259. package/src/styles/elements/_fab.scss +17 -20
  260. package/src/styles/elements/_field.scss +93 -114
  261. package/src/styles/elements/_icon-button.scss +34 -38
  262. package/src/styles/elements/_index.scss +0 -4
  263. package/src/styles/elements/_list.scss +19 -26
  264. package/src/styles/elements/_loading-indicator.scss +6 -9
  265. package/src/styles/elements/_menu.scss +0 -3
  266. package/src/styles/elements/_navigation-bar.scss +5 -9
  267. package/src/styles/elements/_navigation-rail.scss +10 -15
  268. package/src/styles/elements/_progress.scss +15 -18
  269. package/src/styles/elements/_radios.scss +24 -49
  270. package/src/styles/elements/_search.scss +19 -24
  271. package/src/styles/elements/_select.scss +4 -9
  272. package/src/styles/elements/_side-sheet.scss +0 -3
  273. package/src/styles/elements/_slider.scss +15 -35
  274. package/src/styles/elements/_snackbar.scss +0 -3
  275. package/src/styles/elements/_split-button.scss +33 -39
  276. package/src/styles/elements/_switch.scss +50 -90
  277. package/src/styles/elements/_tabs.scss +9 -13
  278. package/src/styles/elements/_text-field.scss +150 -178
  279. package/src/styles/elements/_timepicker.scss +0 -3
  280. package/src/styles/elements/_toolbar.scss +30 -35
  281. package/src/styles/elements/_tooltip.scss +0 -3
  282. package/src/styles/elements/_top-app-bar.scss +38 -45
  283. package/src/styles/main.scss +0 -15
  284. package/src/styles/themes/_autumn.scss +258 -258
  285. package/src/styles/themes/_base-theme.scss +112 -134
  286. package/src/styles/themes/_baseline.scss +291 -314
  287. package/src/styles/themes/_brownbeige.scss +270 -250
  288. package/src/styles/themes/_content.scss +268 -248
  289. package/src/styles/themes/_desert.scss +270 -250
  290. package/src/styles/themes/_expressive.scss +270 -250
  291. package/src/styles/themes/_fidelity.scss +268 -248
  292. package/src/styles/themes/_forest.scss +260 -259
  293. package/src/styles/themes/_fruit-salad.scss +270 -250
  294. package/src/styles/themes/_highcontrast.scss +183 -172
  295. package/src/styles/themes/_index.scss +0 -1
  296. package/src/styles/themes/_monochrome.scss +254 -234
  297. package/src/styles/themes/_neutral.scss +270 -250
  298. package/src/styles/themes/_ocean.scss +260 -259
  299. package/src/styles/themes/_rainbow.scss +270 -250
  300. package/src/styles/themes/_sageivory.scss +270 -250
  301. package/src/styles/themes/_spring.scss +256 -255
  302. package/src/styles/themes/_summer.scss +270 -250
  303. package/src/styles/themes/_sunset.scss +260 -259
  304. package/src/styles/themes/_tealcaramel.scss +270 -250
  305. package/src/styles/themes/_vibrant.scss +270 -250
  306. package/src/styles/utilities/_colors.scss +44 -50
  307. package/src/styles/utilities/_flexbox.scss +48 -59
  308. package/src/styles/utilities/_layout.scss +516 -591
  309. package/src/styles/utilities/_ripple.scss +61 -70
  310. package/src/styles/utilities/_spacing.scss +120 -127
  311. package/src/styles/utilities/_typography.scss +45 -58
  312. package/src/styles/utilities/_visibility.scss +61 -76
  313. package/dist/package.json +0 -488
@@ -0,0 +1,25 @@
1
+ /*!
2
+ * @license
3
+ * Copyright 2021 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { QuantizerWsmeans } from "./quantizer_wsmeans.js";
18
+ import { QuantizerWu } from "./quantizer_wu.js";
19
+ export class QuantizerCelebi {
20
+ static quantize(pixels, maxColors) {
21
+ const wu = new QuantizerWu();
22
+ const wuResult = wu.quantize(pixels, maxColors);
23
+ return QuantizerWsmeans.quantize(pixels, wuResult, maxColors);
24
+ }
25
+ }
@@ -0,0 +1,31 @@
1
+ /*!
2
+ * @license
3
+ * Copyright 2021 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import * as utils from "../utils/color_utils.js";
18
+ export class QuantizerMap {
19
+ static quantize(pixels) {
20
+ const countByColor = new Map();
21
+ for (let i = 0; i < pixels.length; i++) {
22
+ const pixel = pixels[i];
23
+ const alpha = utils.alphaFromArgb(pixel);
24
+ if (alpha < 255) {
25
+ continue;
26
+ }
27
+ countByColor.set(pixel, (countByColor.get(pixel) ?? 0) + 1);
28
+ }
29
+ return countByColor;
30
+ }
31
+ }
@@ -0,0 +1,178 @@
1
+ /*!
2
+ * @license
3
+ * Copyright 2021 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { LabPointProvider } from "./lab_point_provider.js";
18
+ const MAX_ITERATIONS = 10;
19
+ const MIN_MOVEMENT_DISTANCE = 3.0;
20
+ export class QuantizerWsmeans {
21
+ static quantize(inputPixels, startingClusters, maxColors) {
22
+ const pixelToCount = new Map();
23
+ const points = new Array();
24
+ const pixels = new Array();
25
+ const pointProvider = new LabPointProvider();
26
+ let pointCount = 0;
27
+ for (let i = 0; i < inputPixels.length; i++) {
28
+ const inputPixel = inputPixels[i];
29
+ const pixelCount = pixelToCount.get(inputPixel);
30
+ if (pixelCount === undefined) {
31
+ pointCount++;
32
+ points.push(pointProvider.fromInt(inputPixel));
33
+ pixels.push(inputPixel);
34
+ pixelToCount.set(inputPixel, 1);
35
+ }
36
+ else {
37
+ pixelToCount.set(inputPixel, pixelCount + 1);
38
+ }
39
+ }
40
+ const counts = new Array();
41
+ for (let i = 0; i < pointCount; i++) {
42
+ const pixel = pixels[i];
43
+ const count = pixelToCount.get(pixel);
44
+ if (count !== undefined) {
45
+ counts[i] = count;
46
+ }
47
+ }
48
+ let clusterCount = Math.min(maxColors, pointCount);
49
+ if (startingClusters.length > 0) {
50
+ clusterCount = Math.min(clusterCount, startingClusters.length);
51
+ }
52
+ const clusters = new Array();
53
+ for (let i = 0; i < startingClusters.length; i++) {
54
+ clusters.push(pointProvider.fromInt(startingClusters[i]));
55
+ }
56
+ const additionalClustersNeeded = clusterCount - clusters.length;
57
+ if (startingClusters.length === 0 && additionalClustersNeeded > 0) {
58
+ for (let i = 0; i < additionalClustersNeeded; i++) {
59
+ const l = Math.random() * 100.0;
60
+ const a = Math.random() * (100.0 - (-100.0) + 1) + -100;
61
+ const b = Math.random() * (100.0 - (-100.0) + 1) + -100;
62
+ clusters.push(new Array(l, a, b));
63
+ }
64
+ }
65
+ const clusterIndices = new Array();
66
+ for (let i = 0; i < pointCount; i++) {
67
+ clusterIndices.push(Math.floor(Math.random() * clusterCount));
68
+ }
69
+ const indexMatrix = new Array();
70
+ for (let i = 0; i < clusterCount; i++) {
71
+ indexMatrix.push(new Array());
72
+ for (let j = 0; j < clusterCount; j++) {
73
+ indexMatrix[i].push(0);
74
+ }
75
+ }
76
+ const distanceToIndexMatrix = new Array();
77
+ for (let i = 0; i < clusterCount; i++) {
78
+ distanceToIndexMatrix.push(new Array());
79
+ for (let j = 0; j < clusterCount; j++) {
80
+ distanceToIndexMatrix[i].push(new DistanceAndIndex());
81
+ }
82
+ }
83
+ const pixelCountSums = new Array();
84
+ for (let i = 0; i < clusterCount; i++) {
85
+ pixelCountSums.push(0);
86
+ }
87
+ for (let iteration = 0; iteration < MAX_ITERATIONS; iteration++) {
88
+ for (let i = 0; i < clusterCount; i++) {
89
+ for (let j = i + 1; j < clusterCount; j++) {
90
+ const distance = pointProvider.distance(clusters[i], clusters[j]);
91
+ distanceToIndexMatrix[j][i].distance = distance;
92
+ distanceToIndexMatrix[j][i].index = i;
93
+ distanceToIndexMatrix[i][j].distance = distance;
94
+ distanceToIndexMatrix[i][j].index = j;
95
+ }
96
+ distanceToIndexMatrix[i].sort();
97
+ for (let j = 0; j < clusterCount; j++) {
98
+ indexMatrix[i][j] = distanceToIndexMatrix[i][j].index;
99
+ }
100
+ }
101
+ let pointsMoved = 0;
102
+ for (let i = 0; i < pointCount; i++) {
103
+ const point = points[i];
104
+ const previousClusterIndex = clusterIndices[i];
105
+ const previousCluster = clusters[previousClusterIndex];
106
+ const previousDistance = pointProvider.distance(point, previousCluster);
107
+ let minimumDistance = previousDistance;
108
+ let newClusterIndex = -1;
109
+ for (let j = 0; j < clusterCount; j++) {
110
+ if (distanceToIndexMatrix[previousClusterIndex][j].distance >=
111
+ 4 * previousDistance) {
112
+ continue;
113
+ }
114
+ const distance = pointProvider.distance(point, clusters[j]);
115
+ if (distance < minimumDistance) {
116
+ minimumDistance = distance;
117
+ newClusterIndex = j;
118
+ }
119
+ }
120
+ if (newClusterIndex !== -1) {
121
+ const distanceChange = Math.abs((Math.sqrt(minimumDistance) - Math.sqrt(previousDistance)));
122
+ if (distanceChange > MIN_MOVEMENT_DISTANCE) {
123
+ pointsMoved++;
124
+ clusterIndices[i] = newClusterIndex;
125
+ }
126
+ }
127
+ }
128
+ if (pointsMoved === 0 && iteration !== 0) {
129
+ break;
130
+ }
131
+ const componentASums = new Array(clusterCount).fill(0);
132
+ const componentBSums = new Array(clusterCount).fill(0);
133
+ const componentCSums = new Array(clusterCount).fill(0);
134
+ for (let i = 0; i < clusterCount; i++) {
135
+ pixelCountSums[i] = 0;
136
+ }
137
+ for (let i = 0; i < pointCount; i++) {
138
+ const clusterIndex = clusterIndices[i];
139
+ const point = points[i];
140
+ const count = counts[i];
141
+ pixelCountSums[clusterIndex] += count;
142
+ componentASums[clusterIndex] += (point[0] * count);
143
+ componentBSums[clusterIndex] += (point[1] * count);
144
+ componentCSums[clusterIndex] += (point[2] * count);
145
+ }
146
+ for (let i = 0; i < clusterCount; i++) {
147
+ const count = pixelCountSums[i];
148
+ if (count === 0) {
149
+ clusters[i] = [0.0, 0.0, 0.0];
150
+ continue;
151
+ }
152
+ const a = componentASums[i] / count;
153
+ const b = componentBSums[i] / count;
154
+ const c = componentCSums[i] / count;
155
+ clusters[i] = [a, b, c];
156
+ }
157
+ }
158
+ const argbToPopulation = new Map();
159
+ for (let i = 0; i < clusterCount; i++) {
160
+ const count = pixelCountSums[i];
161
+ if (count === 0) {
162
+ continue;
163
+ }
164
+ const possibleNewCluster = pointProvider.toInt(clusters[i]);
165
+ if (argbToPopulation.has(possibleNewCluster)) {
166
+ continue;
167
+ }
168
+ argbToPopulation.set(possibleNewCluster, count);
169
+ }
170
+ return argbToPopulation;
171
+ }
172
+ }
173
+ class DistanceAndIndex {
174
+ constructor() {
175
+ this.distance = -1;
176
+ this.index = -1;
177
+ }
178
+ }
@@ -0,0 +1,342 @@
1
+ /*!
2
+ * @license
3
+ * Copyright 2021 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import * as utils from "../utils/color_utils.js";
18
+ import { QuantizerMap } from "./quantizer_map.js";
19
+ const INDEX_BITS = 5;
20
+ const SIDE_LENGTH = 33;
21
+ const TOTAL_SIZE = 35937;
22
+ const directions = {
23
+ RED: 'red',
24
+ GREEN: 'green',
25
+ BLUE: 'blue',
26
+ };
27
+ export class QuantizerWu {
28
+ constructor(weights = [], momentsR = [], momentsG = [], momentsB = [], moments = [], cubes = []) {
29
+ this.weights = weights;
30
+ this.momentsR = momentsR;
31
+ this.momentsG = momentsG;
32
+ this.momentsB = momentsB;
33
+ this.moments = moments;
34
+ this.cubes = cubes;
35
+ }
36
+ quantize(pixels, maxColors) {
37
+ this.constructHistogram(pixels);
38
+ this.computeMoments();
39
+ const createBoxesResult = this.createBoxes(maxColors);
40
+ const results = this.createResult(createBoxesResult.resultCount);
41
+ return results;
42
+ }
43
+ constructHistogram(pixels) {
44
+ this.weights = Array.from({ length: TOTAL_SIZE }).fill(0);
45
+ this.momentsR = Array.from({ length: TOTAL_SIZE }).fill(0);
46
+ this.momentsG = Array.from({ length: TOTAL_SIZE }).fill(0);
47
+ this.momentsB = Array.from({ length: TOTAL_SIZE }).fill(0);
48
+ this.moments = Array.from({ length: TOTAL_SIZE }).fill(0);
49
+ const countByColor = QuantizerMap.quantize(pixels);
50
+ for (const [pixel, count] of countByColor.entries()) {
51
+ const red = utils.redFromArgb(pixel);
52
+ const green = utils.greenFromArgb(pixel);
53
+ const blue = utils.blueFromArgb(pixel);
54
+ const bitsToRemove = 8 - INDEX_BITS;
55
+ const iR = (red >> bitsToRemove) + 1;
56
+ const iG = (green >> bitsToRemove) + 1;
57
+ const iB = (blue >> bitsToRemove) + 1;
58
+ const index = this.getIndex(iR, iG, iB);
59
+ this.weights[index] = (this.weights[index] ?? 0) + count;
60
+ this.momentsR[index] += count * red;
61
+ this.momentsG[index] += count * green;
62
+ this.momentsB[index] += count * blue;
63
+ this.moments[index] += count * (red * red + green * green + blue * blue);
64
+ }
65
+ }
66
+ computeMoments() {
67
+ for (let r = 1; r < SIDE_LENGTH; r++) {
68
+ const area = Array.from({ length: SIDE_LENGTH }).fill(0);
69
+ const areaR = Array.from({ length: SIDE_LENGTH }).fill(0);
70
+ const areaG = Array.from({ length: SIDE_LENGTH }).fill(0);
71
+ const areaB = Array.from({ length: SIDE_LENGTH }).fill(0);
72
+ const area2 = Array.from({ length: SIDE_LENGTH }).fill(0.0);
73
+ for (let g = 1; g < SIDE_LENGTH; g++) {
74
+ let line = 0;
75
+ let lineR = 0;
76
+ let lineG = 0;
77
+ let lineB = 0;
78
+ let line2 = 0.0;
79
+ for (let b = 1; b < SIDE_LENGTH; b++) {
80
+ const index = this.getIndex(r, g, b);
81
+ line += this.weights[index];
82
+ lineR += this.momentsR[index];
83
+ lineG += this.momentsG[index];
84
+ lineB += this.momentsB[index];
85
+ line2 += this.moments[index];
86
+ area[b] += line;
87
+ areaR[b] += lineR;
88
+ areaG[b] += lineG;
89
+ areaB[b] += lineB;
90
+ area2[b] += line2;
91
+ const previousIndex = this.getIndex(r - 1, g, b);
92
+ this.weights[index] = this.weights[previousIndex] + area[b];
93
+ this.momentsR[index] = this.momentsR[previousIndex] + areaR[b];
94
+ this.momentsG[index] = this.momentsG[previousIndex] + areaG[b];
95
+ this.momentsB[index] = this.momentsB[previousIndex] + areaB[b];
96
+ this.moments[index] = this.moments[previousIndex] + area2[b];
97
+ }
98
+ }
99
+ }
100
+ }
101
+ createBoxes(maxColors) {
102
+ this.cubes =
103
+ Array.from({ length: maxColors }).fill(0).map(() => new Box());
104
+ const volumeVariance = Array.from({ length: maxColors }).fill(0.0);
105
+ this.cubes[0].r0 = 0;
106
+ this.cubes[0].g0 = 0;
107
+ this.cubes[0].b0 = 0;
108
+ this.cubes[0].r1 = SIDE_LENGTH - 1;
109
+ this.cubes[0].g1 = SIDE_LENGTH - 1;
110
+ this.cubes[0].b1 = SIDE_LENGTH - 1;
111
+ let generatedColorCount = maxColors;
112
+ let next = 0;
113
+ for (let i = 1; i < maxColors; i++) {
114
+ if (this.cut(this.cubes[next], this.cubes[i])) {
115
+ volumeVariance[next] =
116
+ this.cubes[next].vol > 1 ? this.variance(this.cubes[next]) : 0.0;
117
+ volumeVariance[i] =
118
+ this.cubes[i].vol > 1 ? this.variance(this.cubes[i]) : 0.0;
119
+ }
120
+ else {
121
+ volumeVariance[next] = 0.0;
122
+ i--;
123
+ }
124
+ next = 0;
125
+ let temp = volumeVariance[0];
126
+ for (let j = 1; j <= i; j++) {
127
+ if (volumeVariance[j] > temp) {
128
+ temp = volumeVariance[j];
129
+ next = j;
130
+ }
131
+ }
132
+ if (temp <= 0.0) {
133
+ generatedColorCount = i + 1;
134
+ break;
135
+ }
136
+ }
137
+ return new CreateBoxesResult(maxColors, generatedColorCount);
138
+ }
139
+ createResult(colorCount) {
140
+ const colors = [];
141
+ for (let i = 0; i < colorCount; ++i) {
142
+ const cube = this.cubes[i];
143
+ const weight = this.volume(cube, this.weights);
144
+ if (weight > 0) {
145
+ const r = Math.round(this.volume(cube, this.momentsR) / weight);
146
+ const g = Math.round(this.volume(cube, this.momentsG) / weight);
147
+ const b = Math.round(this.volume(cube, this.momentsB) / weight);
148
+ const color = (255 << 24) | ((r & 0x0ff) << 16) | ((g & 0x0ff) << 8) |
149
+ (b & 0x0ff);
150
+ colors.push(color);
151
+ }
152
+ }
153
+ return colors;
154
+ }
155
+ variance(cube) {
156
+ const dr = this.volume(cube, this.momentsR);
157
+ const dg = this.volume(cube, this.momentsG);
158
+ const db = this.volume(cube, this.momentsB);
159
+ const xx = this.moments[this.getIndex(cube.r1, cube.g1, cube.b1)] -
160
+ this.moments[this.getIndex(cube.r1, cube.g1, cube.b0)] -
161
+ this.moments[this.getIndex(cube.r1, cube.g0, cube.b1)] +
162
+ this.moments[this.getIndex(cube.r1, cube.g0, cube.b0)] -
163
+ this.moments[this.getIndex(cube.r0, cube.g1, cube.b1)] +
164
+ this.moments[this.getIndex(cube.r0, cube.g1, cube.b0)] +
165
+ this.moments[this.getIndex(cube.r0, cube.g0, cube.b1)] -
166
+ this.moments[this.getIndex(cube.r0, cube.g0, cube.b0)];
167
+ const hypotenuse = dr * dr + dg * dg + db * db;
168
+ const volume = this.volume(cube, this.weights);
169
+ return xx - hypotenuse / volume;
170
+ }
171
+ cut(one, two) {
172
+ const wholeR = this.volume(one, this.momentsR);
173
+ const wholeG = this.volume(one, this.momentsG);
174
+ const wholeB = this.volume(one, this.momentsB);
175
+ const wholeW = this.volume(one, this.weights);
176
+ const maxRResult = this.maximize(one, directions.RED, one.r0 + 1, one.r1, wholeR, wholeG, wholeB, wholeW);
177
+ const maxGResult = this.maximize(one, directions.GREEN, one.g0 + 1, one.g1, wholeR, wholeG, wholeB, wholeW);
178
+ const maxBResult = this.maximize(one, directions.BLUE, one.b0 + 1, one.b1, wholeR, wholeG, wholeB, wholeW);
179
+ let direction;
180
+ const maxR = maxRResult.maximum;
181
+ const maxG = maxGResult.maximum;
182
+ const maxB = maxBResult.maximum;
183
+ if (maxR >= maxG && maxR >= maxB) {
184
+ if (maxRResult.cutLocation < 0) {
185
+ return false;
186
+ }
187
+ direction = directions.RED;
188
+ }
189
+ else if (maxG >= maxR && maxG >= maxB) {
190
+ direction = directions.GREEN;
191
+ }
192
+ else {
193
+ direction = directions.BLUE;
194
+ }
195
+ two.r1 = one.r1;
196
+ two.g1 = one.g1;
197
+ two.b1 = one.b1;
198
+ switch (direction) {
199
+ case directions.RED:
200
+ one.r1 = maxRResult.cutLocation;
201
+ two.r0 = one.r1;
202
+ two.g0 = one.g0;
203
+ two.b0 = one.b0;
204
+ break;
205
+ case directions.GREEN:
206
+ one.g1 = maxGResult.cutLocation;
207
+ two.r0 = one.r0;
208
+ two.g0 = one.g1;
209
+ two.b0 = one.b0;
210
+ break;
211
+ case directions.BLUE:
212
+ one.b1 = maxBResult.cutLocation;
213
+ two.r0 = one.r0;
214
+ two.g0 = one.g0;
215
+ two.b0 = one.b1;
216
+ break;
217
+ default:
218
+ throw new Error('unexpected direction ' + direction);
219
+ }
220
+ one.vol = (one.r1 - one.r0) * (one.g1 - one.g0) * (one.b1 - one.b0);
221
+ two.vol = (two.r1 - two.r0) * (two.g1 - two.g0) * (two.b1 - two.b0);
222
+ return true;
223
+ }
224
+ maximize(cube, direction, first, last, wholeR, wholeG, wholeB, wholeW) {
225
+ const bottomR = this.bottom(cube, direction, this.momentsR);
226
+ const bottomG = this.bottom(cube, direction, this.momentsG);
227
+ const bottomB = this.bottom(cube, direction, this.momentsB);
228
+ const bottomW = this.bottom(cube, direction, this.weights);
229
+ let max = 0.0;
230
+ let cut = -1;
231
+ let halfR = 0;
232
+ let halfG = 0;
233
+ let halfB = 0;
234
+ let halfW = 0;
235
+ for (let i = first; i < last; i++) {
236
+ halfR = bottomR + this.top(cube, direction, i, this.momentsR);
237
+ halfG = bottomG + this.top(cube, direction, i, this.momentsG);
238
+ halfB = bottomB + this.top(cube, direction, i, this.momentsB);
239
+ halfW = bottomW + this.top(cube, direction, i, this.weights);
240
+ if (halfW === 0) {
241
+ continue;
242
+ }
243
+ let tempNumerator = (halfR * halfR + halfG * halfG + halfB * halfB) * 1.0;
244
+ let tempDenominator = halfW * 1.0;
245
+ let temp = tempNumerator / tempDenominator;
246
+ halfR = wholeR - halfR;
247
+ halfG = wholeG - halfG;
248
+ halfB = wholeB - halfB;
249
+ halfW = wholeW - halfW;
250
+ if (halfW === 0) {
251
+ continue;
252
+ }
253
+ tempNumerator = (halfR * halfR + halfG * halfG + halfB * halfB) * 1.0;
254
+ tempDenominator = halfW * 1.0;
255
+ temp += tempNumerator / tempDenominator;
256
+ if (temp > max) {
257
+ max = temp;
258
+ cut = i;
259
+ }
260
+ }
261
+ return new MaximizeResult(cut, max);
262
+ }
263
+ volume(cube, moment) {
264
+ return (moment[this.getIndex(cube.r1, cube.g1, cube.b1)] -
265
+ moment[this.getIndex(cube.r1, cube.g1, cube.b0)] -
266
+ moment[this.getIndex(cube.r1, cube.g0, cube.b1)] +
267
+ moment[this.getIndex(cube.r1, cube.g0, cube.b0)] -
268
+ moment[this.getIndex(cube.r0, cube.g1, cube.b1)] +
269
+ moment[this.getIndex(cube.r0, cube.g1, cube.b0)] +
270
+ moment[this.getIndex(cube.r0, cube.g0, cube.b1)] -
271
+ moment[this.getIndex(cube.r0, cube.g0, cube.b0)]);
272
+ }
273
+ bottom(cube, direction, moment) {
274
+ switch (direction) {
275
+ case directions.RED:
276
+ return (-moment[this.getIndex(cube.r0, cube.g1, cube.b1)] +
277
+ moment[this.getIndex(cube.r0, cube.g1, cube.b0)] +
278
+ moment[this.getIndex(cube.r0, cube.g0, cube.b1)] -
279
+ moment[this.getIndex(cube.r0, cube.g0, cube.b0)]);
280
+ case directions.GREEN:
281
+ return (-moment[this.getIndex(cube.r1, cube.g0, cube.b1)] +
282
+ moment[this.getIndex(cube.r1, cube.g0, cube.b0)] +
283
+ moment[this.getIndex(cube.r0, cube.g0, cube.b1)] -
284
+ moment[this.getIndex(cube.r0, cube.g0, cube.b0)]);
285
+ case directions.BLUE:
286
+ return (-moment[this.getIndex(cube.r1, cube.g1, cube.b0)] +
287
+ moment[this.getIndex(cube.r1, cube.g0, cube.b0)] +
288
+ moment[this.getIndex(cube.r0, cube.g1, cube.b0)] -
289
+ moment[this.getIndex(cube.r0, cube.g0, cube.b0)]);
290
+ default:
291
+ throw new Error('unexpected direction $direction');
292
+ }
293
+ }
294
+ top(cube, direction, position, moment) {
295
+ switch (direction) {
296
+ case directions.RED:
297
+ return (moment[this.getIndex(position, cube.g1, cube.b1)] -
298
+ moment[this.getIndex(position, cube.g1, cube.b0)] -
299
+ moment[this.getIndex(position, cube.g0, cube.b1)] +
300
+ moment[this.getIndex(position, cube.g0, cube.b0)]);
301
+ case directions.GREEN:
302
+ return (moment[this.getIndex(cube.r1, position, cube.b1)] -
303
+ moment[this.getIndex(cube.r1, position, cube.b0)] -
304
+ moment[this.getIndex(cube.r0, position, cube.b1)] +
305
+ moment[this.getIndex(cube.r0, position, cube.b0)]);
306
+ case directions.BLUE:
307
+ return (moment[this.getIndex(cube.r1, cube.g1, position)] -
308
+ moment[this.getIndex(cube.r1, cube.g0, position)] -
309
+ moment[this.getIndex(cube.r0, cube.g1, position)] +
310
+ moment[this.getIndex(cube.r0, cube.g0, position)]);
311
+ default:
312
+ throw new Error('unexpected direction $direction');
313
+ }
314
+ }
315
+ getIndex(r, g, b) {
316
+ return (r << (INDEX_BITS * 2)) + (r << (INDEX_BITS + 1)) + r +
317
+ (g << INDEX_BITS) + g + b;
318
+ }
319
+ }
320
+ class Box {
321
+ constructor(r0 = 0, r1 = 0, g0 = 0, g1 = 0, b0 = 0, b1 = 0, vol = 0) {
322
+ this.r0 = r0;
323
+ this.r1 = r1;
324
+ this.g0 = g0;
325
+ this.g1 = g1;
326
+ this.b0 = b0;
327
+ this.b1 = b1;
328
+ this.vol = vol;
329
+ }
330
+ }
331
+ class CreateBoxesResult {
332
+ constructor(requestedCount, resultCount) {
333
+ this.requestedCount = requestedCount;
334
+ this.resultCount = resultCount;
335
+ }
336
+ }
337
+ class MaximizeResult {
338
+ constructor(cutLocation, maximum) {
339
+ this.cutLocation = cutLocation;
340
+ this.maximum = maximum;
341
+ }
342
+ }
@@ -0,0 +1,30 @@
1
+ /*!
2
+ * @license
3
+ * Copyright 2023 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { DynamicScheme } from "../dynamiccolor/dynamic_scheme.js";
18
+ import { Variant } from "../dynamiccolor/variant.js";
19
+ export class SchemeContent extends DynamicScheme {
20
+ constructor(sourceColorHct, isDark, contrastLevel, specVersion = DynamicScheme.DEFAULT_SPEC_VERSION, platform = DynamicScheme.DEFAULT_PLATFORM) {
21
+ super({
22
+ sourceColorHct,
23
+ variant: Variant.CONTENT,
24
+ contrastLevel,
25
+ isDark,
26
+ platform,
27
+ specVersion,
28
+ });
29
+ }
30
+ }
@@ -0,0 +1,30 @@
1
+ /*!
2
+ * @license
3
+ * Copyright 2022 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { DynamicScheme } from "../dynamiccolor/dynamic_scheme.js";
18
+ import { Variant } from "../dynamiccolor/variant.js";
19
+ export class SchemeExpressive extends DynamicScheme {
20
+ constructor(sourceColorHct, isDark, contrastLevel, specVersion = DynamicScheme.DEFAULT_SPEC_VERSION, platform = DynamicScheme.DEFAULT_PLATFORM) {
21
+ super({
22
+ sourceColorHct,
23
+ variant: Variant.EXPRESSIVE,
24
+ contrastLevel,
25
+ isDark,
26
+ platform,
27
+ specVersion,
28
+ });
29
+ }
30
+ }
@@ -0,0 +1,30 @@
1
+ /*!
2
+ * @license
3
+ * Copyright 2023 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { DynamicScheme } from "../dynamiccolor/dynamic_scheme.js";
18
+ import { Variant } from "../dynamiccolor/variant.js";
19
+ export class SchemeFidelity extends DynamicScheme {
20
+ constructor(sourceColorHct, isDark, contrastLevel, specVersion = DynamicScheme.DEFAULT_SPEC_VERSION, platform = DynamicScheme.DEFAULT_PLATFORM) {
21
+ super({
22
+ sourceColorHct,
23
+ variant: Variant.FIDELITY,
24
+ contrastLevel,
25
+ isDark,
26
+ platform,
27
+ specVersion,
28
+ });
29
+ }
30
+ }
@@ -0,0 +1,30 @@
1
+ /*!
2
+ * @license
3
+ * Copyright 2022 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { DynamicScheme } from "../dynamiccolor/dynamic_scheme.js";
18
+ import { Variant } from "../dynamiccolor/variant.js";
19
+ export class SchemeMonochrome extends DynamicScheme {
20
+ constructor(sourceColorHct, isDark, contrastLevel, specVersion = DynamicScheme.DEFAULT_SPEC_VERSION, platform = DynamicScheme.DEFAULT_PLATFORM) {
21
+ super({
22
+ sourceColorHct,
23
+ variant: Variant.MONOCHROME,
24
+ contrastLevel,
25
+ isDark,
26
+ platform,
27
+ specVersion,
28
+ });
29
+ }
30
+ }