material 3.7.3 → 3.8.1
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/NOTICE +223 -0
- package/README.md +6 -4
- package/dist/components/badge/badge.d.ts +4 -0
- package/dist/components/badge/constants.d.ts +4 -0
- package/dist/components/badge/index.d.ts +1 -0
- package/dist/components/badge/types.d.ts +102 -0
- package/dist/components/bottom-app-bar/bottom-app-bar.d.ts +4 -0
- package/dist/components/bottom-app-bar/constants.d.ts +3 -0
- package/dist/components/bottom-app-bar/types.d.ts +42 -0
- package/dist/components/bottom-sheet/bottom-sheet.d.ts +4 -0
- package/dist/components/bottom-sheet/constants.d.ts +9 -0
- package/dist/components/bottom-sheet/types.d.ts +52 -0
- package/dist/components/button/button.d.ts +4 -0
- package/dist/components/button/constants.d.ts +20 -0
- package/dist/components/button/index.d.ts +1 -0
- package/dist/components/button/types.d.ts +190 -0
- package/dist/components/button-group/button-group.d.ts +4 -0
- package/dist/components/button-group/constants.d.ts +54 -0
- package/dist/components/button-group/index.d.ts +1 -0
- package/dist/components/button-group/types.d.ts +125 -0
- package/dist/components/card/card.d.ts +4 -0
- package/dist/components/card/constants.d.ts +11 -0
- package/dist/components/card/content.d.ts +16 -0
- package/dist/components/card/index.d.ts +2 -0
- package/dist/components/card/types.d.ts +123 -0
- package/dist/components/carousel/carousel.d.ts +1 -0
- package/dist/components/carousel/constants.d.ts +10 -0
- package/dist/components/carousel/types.d.ts +16 -0
- package/dist/components/checkbox/checkbox.d.ts +5 -0
- package/dist/components/checkbox/constants.d.ts +13 -0
- package/dist/components/checkbox/index.d.ts +2 -0
- package/dist/components/checkbox/types.d.ts +94 -0
- package/dist/components/chips/chips.d.ts +4 -0
- package/dist/components/chips/constants.d.ts +1 -0
- package/dist/components/chips/factories.d.ts +4 -0
- package/dist/components/chips/types.d.ts +140 -0
- package/dist/components/datepicker/constants.d.ts +38 -0
- package/dist/components/datepicker/datepicker.d.ts +2 -0
- package/dist/components/datepicker/types.d.ts +139 -0
- package/dist/components/dialog/constants.d.ts +45 -0
- package/dist/components/dialog/dialog.d.ts +5 -0
- package/dist/components/dialog/index.d.ts +1 -0
- package/dist/components/dialog/types.d.ts +196 -0
- package/dist/components/divider/config.d.ts +30 -0
- package/dist/components/divider/constants.d.ts +15 -0
- package/dist/components/divider/divider.d.ts +4 -0
- package/dist/components/divider/types.d.ts +27 -0
- package/dist/components/drawer/constants.d.ts +39 -0
- package/dist/components/drawer/drawer.d.ts +4 -0
- package/dist/components/drawer/index.d.ts +1 -0
- package/dist/components/drawer/types.d.ts +109 -0
- package/dist/components/extended-fab/constants.d.ts +32 -0
- package/dist/components/extended-fab/extended-fab.d.ts +4 -0
- package/dist/components/extended-fab/types.d.ts +126 -0
- package/dist/components/fab/constants.d.ts +26 -0
- package/dist/components/fab/fab.d.ts +4 -0
- package/dist/components/fab/types.d.ts +103 -0
- package/dist/components/fab-menu/constants.d.ts +9 -0
- package/dist/components/fab-menu/fab-menu.d.ts +4 -0
- package/dist/components/fab-menu/types.d.ts +41 -0
- package/dist/components/icon-button/constants.d.ts +34 -0
- package/dist/components/icon-button/icon-button.d.ts +4 -0
- package/dist/components/icon-button/types.d.ts +157 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/list/constants.d.ts +30 -0
- package/dist/components/list/index.d.ts +1 -0
- package/dist/components/list/list.d.ts +4 -0
- package/dist/components/list/types.d.ts +110 -0
- package/dist/components/loading-indicator/constants.d.ts +16 -0
- package/dist/components/loading-indicator/features/renderer.d.ts +13 -0
- package/dist/components/loading-indicator/loading-indicator.d.ts +4 -0
- package/dist/components/loading-indicator/types.d.ts +21 -0
- package/dist/components/menu/constants.d.ts +51 -0
- package/dist/components/menu/features/controller.js +1 -1
- package/dist/components/menu/features/keyboard.js +8 -3
- package/dist/components/menu/features/opener.js +2 -16
- package/dist/components/menu/index.d.ts +2 -0
- package/dist/components/menu/inner.d.ts +2 -0
- package/dist/components/menu/menu.d.ts +4 -0
- package/dist/components/menu/on-demand.d.ts +9 -0
- package/dist/components/menu/types.d.ts +185 -1
- package/dist/components/navigation-bar/navigation-bar.d.ts +1 -0
- package/dist/components/navigation-bar/types.d.ts +12 -0
- package/dist/components/navigation-rail/constants.d.ts +2 -0
- package/dist/components/navigation-rail/navigation-rail.d.ts +1 -0
- package/dist/components/navigation-rail/types.d.ts +18 -0
- package/dist/components/progress/constants.d.ts +37 -0
- package/dist/components/progress/progress.d.ts +4 -0
- package/dist/components/progress/types.d.ts +136 -0
- package/dist/components/radios/constants.d.ts +14 -0
- package/dist/components/radios/radios.d.ts +4 -0
- package/dist/components/radios/types.d.ts +89 -0
- package/dist/components/search/constants.d.ts +34 -0
- package/dist/components/search/search.d.ts +4 -0
- package/dist/components/search/types.d.ts +109 -0
- package/dist/components/select/constants.d.ts +46 -0
- package/dist/components/select/features.js +9 -1
- package/dist/components/select/index.d.ts +2 -0
- package/dist/components/select/select.d.ts +4 -0
- package/dist/components/select/types.d.ts +95 -0
- package/dist/components/side-sheet/constants.d.ts +9 -0
- package/dist/components/side-sheet/side-sheet.d.ts +4 -0
- package/dist/components/side-sheet/types.d.ts +51 -0
- package/dist/components/slider/constants.d.ts +62 -0
- package/dist/components/slider/slider.d.ts +4 -0
- package/dist/components/slider/types.d.ts +78 -0
- package/dist/components/snackbar/constants.d.ts +37 -0
- package/dist/components/snackbar/snackbar.d.ts +5 -0
- package/dist/components/snackbar/types.d.ts +67 -0
- package/dist/components/split-button/api.js +13 -3
- package/dist/components/split-button/constants.d.ts +13 -0
- package/dist/components/split-button/split-button.d.ts +4 -0
- package/dist/components/split-button/types.d.ts +50 -0
- package/dist/components/switch/constants.d.ts +34 -0
- package/dist/components/switch/switch.d.ts +4 -0
- package/dist/components/switch/types.d.ts +55 -0
- package/dist/components/tabs/constants.d.ts +49 -0
- package/dist/components/tabs/indicator.d.ts +22 -0
- package/dist/components/tabs/responsive.d.ts +17 -0
- package/dist/components/tabs/tab.d.ts +5 -0
- package/dist/components/tabs/tabs.d.ts +4 -0
- package/dist/components/tabs/types.d.ts +170 -0
- package/dist/components/tabs/utils.d.ts +24 -0
- package/dist/components/text-field/constants.d.ts +61 -0
- package/dist/components/text-field/features/trailing-icon.d.ts +25 -0
- package/dist/components/text-field/text-field.d.ts +4 -0
- package/dist/components/text-field/types.d.ts +84 -0
- package/dist/components/timepicker/constants.d.ts +61 -0
- package/dist/components/timepicker/types.d.ts +145 -0
- package/dist/components/toolbar/constants.d.ts +8 -0
- package/dist/components/toolbar/toolbar.d.ts +4 -0
- package/dist/components/toolbar/types.d.ts +75 -0
- package/dist/components/tooltip/constants.d.ts +43 -0
- package/dist/components/tooltip/tooltip.d.ts +4 -0
- package/dist/components/tooltip/types.d.ts +78 -0
- package/dist/components/top-app-bar/constants.d.ts +29 -0
- package/dist/components/top-app-bar/top-app-bar.d.ts +4 -0
- package/dist/components/top-app-bar/types.d.ts +55 -0
- package/dist/core/canvas/animation.d.ts +6 -0
- package/dist/core/canvas/drawing.d.ts +47 -0
- package/dist/core/canvas/index.d.ts +1 -0
- package/dist/core/canvas/resize.d.ts +7 -0
- package/dist/core/canvas/utils.d.ts +39 -0
- package/dist/core/compose/base.d.ts +9 -0
- package/dist/core/compose/cleanup.d.ts +2 -0
- package/dist/core/compose/component.d.ts +13 -0
- package/dist/core/compose/features/badge.d.ts +10 -0
- package/dist/core/compose/features/checkable.d.ts +13 -0
- package/dist/core/compose/features/debounce.d.ts +19 -0
- package/dist/core/compose/features/disabled.d.ts +11 -0
- package/dist/core/compose/features/events.d.ts +19 -0
- package/dist/core/compose/features/icon.d.ts +20 -0
- package/dist/core/compose/features/input.d.ts +31 -0
- package/dist/core/compose/features/lifecycle.d.ts +16 -0
- package/dist/core/compose/features/position.d.ts +13 -0
- package/dist/core/compose/features/ripple.d.ts +17 -0
- package/dist/core/compose/features/size.d.ts +5 -0
- package/dist/core/compose/features/style.d.ts +5 -0
- package/dist/core/compose/features/text.d.ts +20 -0
- package/dist/core/compose/features/textinput.d.ts +39 -0
- package/dist/core/compose/features/textlabel.d.ts +18 -0
- package/dist/core/compose/features/throttle.d.ts +18 -0
- package/dist/core/compose/features/track.d.ts +12 -0
- package/dist/core/compose/features/variant.d.ts +5 -0
- package/dist/core/compose/features/withEvents.d.ts +12 -0
- package/dist/core/compose/pipe.d.ts +12 -0
- package/dist/core/compose/utils/type-guards.d.ts +5 -0
- package/dist/core/config/component.d.ts +17 -0
- package/dist/core/config/global.d.ts +15 -0
- package/dist/core/config.d.ts +34 -0
- package/dist/core/dom/attributes.d.ts +25 -0
- package/dist/core/dom/classes.d.ts +24 -0
- package/dist/core/dom/create.d.ts +47 -0
- package/dist/core/dom/events.d.ts +26 -0
- package/dist/core/dom/focus.d.ts +11 -0
- package/dist/core/dom/html.d.ts +6 -0
- package/dist/core/dom/layer.d.ts +36 -0
- package/dist/core/dom/roving.d.ts +7 -0
- package/dist/core/navigation/destinations.d.ts +10 -0
- package/dist/core/shapes/cubic.d.ts +8 -0
- package/dist/core/shapes/material.d.ts +45 -0
- package/dist/core/shapes/polygon.d.ts +11 -0
- package/dist/core/state/emitter.d.ts +19 -0
- package/dist/core/state/events.d.ts +17 -0
- package/dist/core/state/store.d.ts +40 -0
- package/dist/core/theme/shape.d.ts +3 -0
- package/dist/core/theme/tokens.d.ts +6 -0
- package/dist/core/utils/background.d.ts +7 -0
- package/dist/core/utils/color.d.ts +5 -0
- package/dist/core/utils/index.d.ts +9 -0
- package/dist/core/utils/mobile.d.ts +10 -0
- package/dist/core/utils/object.d.ts +9 -0
- package/dist/core/utils/performance.d.ts +20 -0
- package/dist/core/utils/theme.d.ts +8 -0
- package/dist/core/utils/url.d.ts +3 -0
- package/dist/elements/adapter.d.ts +24 -0
- package/dist/elements/badge.d.ts +4 -0
- package/dist/elements/bottom-app-bar.d.ts +4 -0
- package/dist/elements/bottom-sheet.d.ts +6 -0
- package/dist/elements/button-group.d.ts +8 -0
- package/dist/elements/button.d.ts +5 -0
- package/dist/elements/card.d.ts +4 -0
- package/dist/elements/carousel.d.ts +5 -0
- package/dist/elements/checkbox.d.ts +4 -0
- package/dist/elements/chips.d.ts +9 -0
- package/dist/elements/css/menu.css +1 -1
- package/dist/elements/css/menu.js +1 -1
- package/dist/elements/datepicker.d.ts +6 -0
- package/dist/elements/define.d.ts +48 -0
- package/dist/elements/dialog.d.ts +5 -0
- package/dist/elements/divider.d.ts +4 -0
- package/dist/elements/drawer.d.ts +6 -0
- package/dist/elements/extended-fab.d.ts +6 -0
- package/dist/elements/fab-menu.d.ts +10 -0
- package/dist/elements/fab.d.ts +6 -0
- package/dist/elements/icon-button.d.ts +6 -0
- package/dist/elements/index.d.ts +4 -0
- package/dist/elements/list.d.ts +8 -0
- package/dist/elements/loading-indicator.d.ts +4 -0
- package/dist/elements/menu.d.ts +12 -0
- package/dist/elements/navigation-bar.d.ts +6 -0
- package/dist/elements/navigation-rail.d.ts +10 -0
- package/dist/elements/preupgrade/badge.css +1 -1
- package/dist/elements/preupgrade/bottom-app-bar.css +1 -1
- package/dist/elements/preupgrade/bottom-sheet.css +1 -1
- package/dist/elements/preupgrade/button-group.css +1 -1
- package/dist/elements/preupgrade/button.css +1 -1
- package/dist/elements/preupgrade/card.css +1 -1
- package/dist/elements/preupgrade/carousel.css +1 -1
- package/dist/elements/preupgrade/checkbox.css +1 -1
- package/dist/elements/preupgrade/chips.css +1 -1
- package/dist/elements/preupgrade/datepicker.css +1 -1
- package/dist/elements/preupgrade/dialog.css +1 -1
- package/dist/elements/preupgrade/divider.css +1 -1
- package/dist/elements/preupgrade/drawer.css +1 -1
- package/dist/elements/preupgrade/extended-fab.css +1 -1
- package/dist/elements/preupgrade/fab-menu.css +1 -1
- package/dist/elements/preupgrade/fab.css +1 -1
- package/dist/elements/preupgrade/icon-button.css +1 -1
- package/dist/elements/preupgrade/list.css +1 -1
- package/dist/elements/preupgrade/loading-indicator.css +1 -1
- package/dist/elements/preupgrade/menu.css +1 -1
- package/dist/elements/preupgrade/navigation-bar.css +1 -1
- package/dist/elements/preupgrade/navigation-rail.css +1 -1
- package/dist/elements/preupgrade/progress.css +1 -1
- package/dist/elements/preupgrade/radios.css +1 -1
- package/dist/elements/preupgrade/search.css +1 -1
- package/dist/elements/preupgrade/select.css +1 -1
- package/dist/elements/preupgrade/side-sheet.css +1 -1
- package/dist/elements/preupgrade/slider.css +1 -1
- package/dist/elements/preupgrade/snackbar.css +1 -1
- package/dist/elements/preupgrade/split-button.css +1 -1
- package/dist/elements/preupgrade/switch.css +1 -1
- package/dist/elements/preupgrade/tabs.css +1 -1
- package/dist/elements/preupgrade/text-field.css +1 -1
- package/dist/elements/preupgrade/timepicker.css +1 -1
- package/dist/elements/preupgrade/toolbar.css +1 -1
- package/dist/elements/preupgrade/tooltip.css +1 -1
- package/dist/elements/preupgrade/top-app-bar.css +1 -1
- package/dist/elements/preupgrade.css +1 -1
- package/dist/elements/progress.d.ts +4 -0
- package/dist/elements/radios.d.ts +5 -0
- package/dist/elements/search.d.ts +15 -0
- package/dist/elements/select.d.ts +6 -0
- package/dist/elements/side-sheet.d.ts +5 -0
- package/dist/elements/slider.d.ts +7 -0
- package/dist/elements/snackbar.d.ts +4 -0
- package/dist/elements/split-button.d.ts +8 -0
- package/dist/elements/styles.d.ts +11 -0
- package/dist/elements/switch.d.ts +5 -0
- package/dist/elements/tabs.d.ts +6 -0
- package/dist/elements/text-field.d.ts +9 -0
- package/dist/elements/timepicker.d.ts +9 -0
- package/dist/elements/toolbar.d.ts +4 -0
- package/dist/elements/tooltip.d.ts +4 -0
- package/dist/elements/top-app-bar.d.ts +4 -0
- package/dist/index.d.ts +1 -0
- package/dist/react/create.d.ts +15 -0
- package/dist/react/index.d.ts +1 -0
- package/dist/react/jsx.d.ts +3 -0
- package/dist/solid/create.d.ts +16 -0
- package/dist/solid/index.d.ts +1 -0
- package/dist/solid/jsx.d.ts +4 -0
- package/dist/ssr/index.d.ts +3 -0
- package/dist/ssr/solid.d.ts +1 -0
- package/dist/ssr/svelte.d.ts +1 -0
- package/dist/ssr/vue.d.ts +1 -0
- package/dist/styles/badge.css +1 -1
- package/dist/styles/base-lite.css +2 -2
- package/dist/styles/base.css +2 -2
- package/dist/styles/bottom-app-bar.css +1 -1
- package/dist/styles/bottom-sheet.css +1 -1
- package/dist/styles/button-group.css +1 -1
- package/dist/styles/button.css +1 -1
- package/dist/styles/card.css +1 -1
- package/dist/styles/carousel.css +1 -1
- package/dist/styles/checkbox.css +1 -1
- package/dist/styles/chips.css +1 -1
- package/dist/styles/contrast.css +2 -2
- package/dist/styles/datepicker.css +1 -1
- package/dist/styles/dialog.css +1 -1
- package/dist/styles/divider.css +1 -1
- package/dist/styles/drawer.css +1 -1
- package/dist/styles/extended-fab.css +1 -1
- package/dist/styles/fab-menu.css +1 -1
- package/dist/styles/fab.css +1 -1
- package/dist/styles/icon-button.css +1 -1
- package/dist/styles/list.css +1 -1
- package/dist/styles/loading-indicator.css +1 -1
- package/dist/styles/menu.css +2 -2
- package/dist/styles/navigation-bar.css +1 -1
- package/dist/styles/navigation-rail.css +1 -1
- package/dist/styles/progress.css +1 -1
- package/dist/styles/radios.css +1 -1
- package/dist/styles/search.css +1 -1
- package/dist/styles/select.css +1 -1
- package/dist/styles/side-sheet.css +1 -1
- package/dist/styles/slider.css +1 -1
- package/dist/styles/snackbar.css +1 -1
- package/dist/styles/split-button.css +1 -1
- package/dist/styles/switch.css +1 -1
- package/dist/styles/tabs.css +1 -1
- package/dist/styles/text-field.css +1 -1
- package/dist/styles/timepicker.css +1 -1
- package/dist/styles/toolbar.css +1 -1
- package/dist/styles/tooltip.css +1 -1
- package/dist/styles/top-app-bar.css +1 -1
- package/dist/styles/typography.css +1 -1
- package/dist/styles/utilities.css +1 -1
- package/dist/styles.css +2 -2
- package/dist/svelte/runtime.d.ts +21 -0
- package/dist/theme/image.d.ts +4 -0
- package/dist/theme/image.js +5 -0
- package/dist/theme/index.d.ts +43 -0
- package/dist/theme/index.js +32 -0
- package/dist/theme/roles.js +68 -0
- package/dist/theme/variants.d.ts +15 -0
- package/dist/theme/variants.js +17 -0
- package/dist/theme/vendor/contrast/contrast.js +72 -0
- package/dist/theme/vendor/dislike/dislike_analyzer.js +31 -0
- package/dist/theme/vendor/dynamiccolor/color_spec_2021.d.ts +64 -0
- package/dist/theme/vendor/dynamiccolor/color_spec_2021.js +663 -0
- package/dist/theme/vendor/dynamiccolor/contrast_curve.js +42 -0
- package/dist/theme/vendor/dynamiccolor/dynamic_color.d.ts +63 -0
- package/dist/theme/vendor/dynamiccolor/dynamic_color.js +264 -0
- package/dist/theme/vendor/dynamiccolor/dynamic_scheme.d.ts +100 -0
- package/dist/theme/vendor/dynamiccolor/dynamic_scheme.js +418 -0
- package/dist/theme/vendor/dynamiccolor/material_dynamic_colors.d.ts +125 -0
- package/dist/theme/vendor/dynamiccolor/material_dynamic_colors.js +311 -0
- package/dist/theme/vendor/dynamiccolor/tone_delta_pair.js +27 -0
- package/dist/theme/vendor/dynamiccolor/variant.js +28 -0
- package/dist/theme/vendor/hct/cam16.js +249 -0
- package/dist/theme/vendor/hct/hct.d.ts +32 -0
- package/dist/theme/vendor/hct/hct.js +86 -0
- package/dist/theme/vendor/hct/hct_solver.js +390 -0
- package/dist/theme/vendor/hct/viewing_conditions.js +73 -0
- package/dist/theme/vendor/palettes/tonal_palette.js +114 -0
- package/dist/theme/vendor/quantize/lab_point_provider.js +31 -0
- package/dist/theme/vendor/quantize/quantizer_celebi.js +25 -0
- package/dist/theme/vendor/quantize/quantizer_map.js +31 -0
- package/dist/theme/vendor/quantize/quantizer_wsmeans.js +178 -0
- package/dist/theme/vendor/quantize/quantizer_wu.js +342 -0
- package/dist/theme/vendor/scheme/scheme_content.js +30 -0
- package/dist/theme/vendor/scheme/scheme_expressive.js +30 -0
- package/dist/theme/vendor/scheme/scheme_fidelity.js +30 -0
- package/dist/theme/vendor/scheme/scheme_monochrome.js +30 -0
- package/dist/theme/vendor/scheme/scheme_neutral.js +30 -0
- package/dist/theme/vendor/scheme/scheme_tonal_spot.js +30 -0
- package/dist/theme/vendor/scheme/scheme_vibrant.js +30 -0
- package/dist/theme/vendor/score/score.js +100 -0
- package/dist/theme/vendor/temperature/temperature_cache.js +198 -0
- package/dist/theme/vendor/utils/color_utils.js +173 -0
- package/dist/theme/vendor/utils/image_utils.js +72 -0
- package/dist/theme/vendor/utils/math_utils.js +75 -0
- package/dist/theme/vendor/utils/string_utils.js +61 -0
- package/dist/themes/autumn-contrast.css +2 -2
- package/dist/themes/autumn.css +2 -2
- package/dist/themes/baseline-contrast.css +2 -2
- package/dist/themes/baseline.css +2 -2
- package/dist/themes/brownbeige-contrast.css +2 -2
- package/dist/themes/brownbeige.css +2 -2
- package/dist/themes/content-contrast.css +2 -2
- package/dist/themes/content.css +2 -2
- package/dist/themes/desert-contrast.css +2 -2
- package/dist/themes/desert.css +2 -2
- package/dist/themes/expressive-contrast.css +2 -2
- package/dist/themes/expressive.css +2 -2
- package/dist/themes/fidelity-contrast.css +2 -2
- package/dist/themes/fidelity.css +2 -2
- package/dist/themes/forest-contrast.css +2 -2
- package/dist/themes/forest.css +2 -2
- package/dist/themes/fruit-salad-contrast.css +2 -2
- package/dist/themes/fruit-salad.css +2 -2
- package/dist/themes/highcontrast-contrast.css +2 -2
- package/dist/themes/highcontrast.css +2 -2
- package/dist/themes/monochrome-contrast.css +2 -2
- package/dist/themes/monochrome.css +2 -2
- package/dist/themes/neutral-contrast.css +2 -2
- package/dist/themes/neutral.css +2 -2
- package/dist/themes/ocean-contrast.css +2 -2
- package/dist/themes/ocean.css +2 -2
- package/dist/themes/rainbow-contrast.css +2 -2
- package/dist/themes/rainbow.css +2 -2
- package/dist/themes/sageivory-contrast.css +2 -2
- package/dist/themes/sageivory.css +2 -2
- package/dist/themes/spring-contrast.css +2 -2
- package/dist/themes/spring.css +2 -2
- package/dist/themes/summer-contrast.css +2 -2
- package/dist/themes/summer.css +2 -2
- package/dist/themes/sunset-contrast.css +2 -2
- package/dist/themes/sunset.css +2 -2
- package/dist/themes/tealcaramel-contrast.css +2 -2
- package/dist/themes/tealcaramel.css +2 -2
- package/dist/themes/vibrant-contrast.css +2 -2
- package/dist/themes/vibrant.css +2 -2
- package/dist/vue/create.d.ts +18 -0
- package/dist/vue/index.d.ts +1 -0
- package/package.json +14 -1
- package/src/styles/components/_menu.scss +14 -1
- package/src/styles/themes/_autumn.scss +20 -2
- package/src/styles/themes/_base-theme.scss +34 -24
- package/src/styles/themes/_baseline.scss +18 -0
- package/src/styles/themes/_brownbeige.scss +30 -2
- package/src/styles/themes/_content.scss +30 -2
- package/src/styles/themes/_desert.scss +30 -2
- package/src/styles/themes/_expressive.scss +30 -2
- package/src/styles/themes/_fidelity.scss +30 -2
- package/src/styles/themes/_forest.scss +20 -2
- package/src/styles/themes/_fruit-salad.scss +30 -2
- package/src/styles/themes/_highcontrast.scss +21 -2
- package/src/styles/themes/_monochrome.scss +30 -2
- package/src/styles/themes/_neutral.scss +30 -2
- package/src/styles/themes/_ocean.scss +20 -2
- package/src/styles/themes/_rainbow.scss +30 -2
- package/src/styles/themes/_sageivory.scss +30 -2
- package/src/styles/themes/_spring.scss +20 -2
- package/src/styles/themes/_summer.scss +30 -2
- package/src/styles/themes/_sunset.scss +20 -2
- package/src/styles/themes/_tealcaramel.scss +30 -2
- package/src/styles/themes/_vibrant.scss +30 -2
|
@@ -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
|
+
}
|