@shortfuse/materialdesignweb 0.7.6 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +87 -90
- package/bin/mdw-css.js +1 -1
- package/components/Badge.js +14 -7
- package/components/Body.js +3 -0
- package/components/BottomAppBar.js +4 -13
- package/components/BottomSheet.js +424 -0
- package/components/Box.js +20 -28
- package/components/Button.js +85 -79
- package/components/Button.md +9 -9
- package/components/Card.js +60 -72
- package/components/Checkbox.js +33 -42
- package/components/CheckboxIcon.js +11 -29
- package/components/Chip.js +13 -11
- package/components/Dialog.js +214 -394
- package/components/DialogActions.js +2 -2
- package/components/Display.js +55 -0
- package/components/Divider.js +3 -3
- package/components/Fab.js +83 -18
- package/components/FabContainer.js +48 -0
- package/components/FilterChip.js +35 -33
- package/components/Grid.js +176 -0
- package/components/Headline.js +5 -28
- package/components/Icon.js +61 -76
- package/components/IconButton.js +72 -126
- package/components/Input.js +859 -1
- package/components/InputChip.js +161 -0
- package/components/Label.js +3 -0
- package/components/List.js +4 -6
- package/components/ListItem.js +46 -30
- package/components/ListOption.js +86 -53
- package/components/Listbox.js +248 -0
- package/components/Menu.js +69 -528
- package/components/MenuItem.js +33 -36
- package/components/NavBar.js +49 -86
- package/components/NavDrawer.js +16 -15
- package/components/NavDrawerItem.js +4 -5
- package/components/NavItem.js +58 -41
- package/components/NavRail.js +30 -20
- package/components/NavRailItem.js +8 -3
- package/components/Page.js +105 -0
- package/components/Pane.js +11 -274
- package/components/Popup.js +29 -0
- package/components/Progress.js +24 -23
- package/components/Radio.js +40 -36
- package/components/RadioIcon.js +12 -16
- package/components/Ripple.js +13 -10
- package/components/Root.js +209 -0
- package/components/Scrim.js +87 -0
- package/components/Search.js +77 -0
- package/components/SegmentedButton.js +33 -45
- package/components/SegmentedButtonGroup.js +25 -13
- package/components/Select.js +10 -11
- package/components/Shape.js +5 -65
- package/components/SideSheet.js +308 -0
- package/components/Slider.js +108 -78
- package/components/Snackbar.js +26 -21
- package/components/SnackbarContainer.js +42 -0
- package/components/Surface.js +17 -12
- package/components/Switch.js +45 -24
- package/components/SwitchIcon.js +49 -39
- package/components/Tab.js +64 -43
- package/components/TabContent.js +5 -3
- package/components/TabList.js +62 -34
- package/components/TabPanel.js +11 -8
- package/components/Table.js +116 -0
- package/components/TextArea.js +54 -50
- package/components/Title.js +4 -9
- package/components/Tooltip.js +44 -22
- package/components/TopAppBar.js +68 -172
- package/constants/shapes.js +36 -0
- package/constants/typography.js +127 -0
- package/core/Composition.js +1164 -645
- package/core/CompositionAdapter.js +314 -0
- package/core/CustomElement.js +701 -286
- package/core/css.js +121 -15
- package/core/customTypes.js +157 -40
- package/core/dom.js +17 -11
- package/{utils → core}/jsonMergePatch.js +42 -18
- package/core/observe.js +343 -244
- package/core/optimizations.js +23 -0
- package/core/template.js +19 -56
- package/core/uid.js +13 -0
- package/dist/index.min.js +85 -184
- package/dist/index.min.js.map +4 -4
- package/dist/meta.json +1 -1
- package/dom/HTMLOptionsCollectionProxy.js +106 -0
- package/loaders/palette.js +13 -0
- package/loaders/theme.js +12 -0
- package/mixins/AriaReflectorMixin.js +53 -14
- package/mixins/AriaToolbarMixin.js +5 -3
- package/mixins/ControlMixin.js +92 -41
- package/mixins/DelegatesFocusMixin.js +54 -0
- package/mixins/DensityMixin.js +2 -3
- package/mixins/ElevationMixin.js +62 -0
- package/mixins/FlexableMixin.js +67 -39
- package/mixins/FormAssociatedMixin.js +71 -16
- package/mixins/HyperlinkMixin.js +66 -0
- package/mixins/InputMixin.js +205 -39
- package/mixins/KeyboardNavMixin.js +22 -7
- package/mixins/NavigationListenerMixin.js +33 -0
- package/mixins/PopupMixin.js +725 -0
- package/mixins/RTLObserverMixin.js +0 -1
- package/mixins/ResizeObserverMixin.js +16 -5
- package/mixins/RippleMixin.js +11 -10
- package/mixins/ScrollListenerMixin.js +42 -33
- package/mixins/SemiStickyMixin.js +97 -0
- package/mixins/ShapeMaskedMixin.js +117 -0
- package/mixins/ShapeMixin.js +17 -194
- package/mixins/StateMixin.js +80 -39
- package/mixins/TextFieldMixin.js +139 -183
- package/mixins/ThemableMixin.js +71 -161
- package/mixins/TooltipTriggerMixin.js +292 -366
- package/mixins/TouchTargetMixin.js +5 -4
- package/mixins/TypographyMixin.js +121 -0
- package/package.json +111 -71
- package/services/rtl.js +10 -0
- package/services/svgAlias.js +17 -0
- package/{theming/index.js → services/theme.js} +25 -175
- package/types/bin/mdw-css.d.ts +3 -0
- package/types/bin/mdw-css.d.ts.map +1 -0
- package/types/components/Badge.d.ts +39 -0
- package/types/components/Badge.d.ts.map +1 -0
- package/types/components/Body.d.ts +29 -0
- package/types/components/Body.d.ts.map +1 -0
- package/types/components/BottomAppBar.d.ts +73 -0
- package/types/components/BottomAppBar.d.ts.map +1 -0
- package/types/components/BottomSheet.d.ts +109 -0
- package/types/components/BottomSheet.d.ts.map +1 -0
- package/types/components/Box.d.ts +16 -0
- package/types/components/Box.d.ts.map +1 -0
- package/types/components/Button.d.ts +714 -0
- package/types/components/Button.d.ts.map +1 -0
- package/types/components/Card.d.ts +412 -0
- package/types/components/Card.d.ts.map +1 -0
- package/types/components/Checkbox.d.ts +205 -0
- package/types/components/Checkbox.d.ts.map +1 -0
- package/types/components/CheckboxIcon.d.ts +44 -0
- package/types/components/CheckboxIcon.d.ts.map +1 -0
- package/types/components/Chip.d.ts +1425 -0
- package/types/components/Chip.d.ts.map +1 -0
- package/types/components/Dialog.d.ts +286 -0
- package/types/components/Dialog.d.ts.map +1 -0
- package/types/components/DialogActions.d.ts +4 -0
- package/types/components/DialogActions.d.ts.map +1 -0
- package/types/components/Display.d.ts +45 -0
- package/types/components/Display.d.ts.map +1 -0
- package/types/components/Divider.d.ts +10 -0
- package/types/components/Divider.d.ts.map +1 -0
- package/types/components/Fab.d.ts +741 -0
- package/types/components/Fab.d.ts.map +1 -0
- package/types/components/FabContainer.d.ts +10 -0
- package/types/components/FabContainer.d.ts.map +1 -0
- package/types/components/FilterChip.d.ts +4283 -0
- package/types/components/FilterChip.d.ts.map +1 -0
- package/types/components/Grid.d.ts +37 -0
- package/types/components/Grid.d.ts.map +1 -0
- package/types/components/Headline.d.ts +47 -0
- package/types/components/Headline.d.ts.map +1 -0
- package/types/components/Icon.d.ts +103 -0
- package/types/components/Icon.d.ts.map +1 -0
- package/types/components/IconButton.d.ts +1486 -0
- package/types/components/IconButton.d.ts.map +1 -0
- package/types/components/Input.d.ts +51288 -0
- package/types/components/Input.d.ts.map +1 -0
- package/types/components/InputChip.d.ts +243 -0
- package/types/components/InputChip.d.ts.map +1 -0
- package/types/components/Label.d.ts +29 -0
- package/types/components/Label.d.ts.map +1 -0
- package/types/components/List.d.ts +31 -0
- package/types/components/List.d.ts.map +1 -0
- package/types/components/ListItem.d.ts +349 -0
- package/types/components/ListItem.d.ts.map +1 -0
- package/types/components/ListOption.d.ts +1493 -0
- package/types/components/ListOption.d.ts.map +1 -0
- package/types/components/Listbox.d.ts +12012 -0
- package/types/components/Listbox.d.ts.map +1 -0
- package/types/components/Menu.d.ts +119 -0
- package/types/components/Menu.d.ts.map +1 -0
- package/types/components/MenuItem.d.ts +3109 -0
- package/types/components/MenuItem.d.ts.map +1 -0
- package/types/components/NavBar.d.ts +18 -0
- package/types/components/NavBar.d.ts.map +1 -0
- package/types/components/NavBarItem.d.ts +186 -0
- package/types/components/NavBarItem.d.ts.map +1 -0
- package/types/components/NavDrawer.d.ts +108 -0
- package/types/components/NavDrawer.d.ts.map +1 -0
- package/types/components/NavDrawerItem.d.ts +186 -0
- package/types/components/NavDrawerItem.d.ts.map +1 -0
- package/types/components/NavItem.d.ts +190 -0
- package/types/components/NavItem.d.ts.map +1 -0
- package/types/components/NavRail.d.ts +109 -0
- package/types/components/NavRail.d.ts.map +1 -0
- package/types/components/NavRailItem.d.ts +186 -0
- package/types/components/NavRailItem.d.ts.map +1 -0
- package/types/components/Page.d.ts +24 -0
- package/types/components/Page.d.ts.map +1 -0
- package/types/components/Pane.d.ts +44 -0
- package/types/components/Pane.d.ts.map +1 -0
- package/types/components/Popup.d.ts +76 -0
- package/types/components/Popup.d.ts.map +1 -0
- package/types/components/Progress.d.ts +19 -0
- package/types/components/Progress.d.ts.map +1 -0
- package/types/components/Radio.d.ts +199 -0
- package/types/components/Radio.d.ts.map +1 -0
- package/types/components/RadioIcon.d.ts +46 -0
- package/types/components/RadioIcon.d.ts.map +1 -0
- package/types/components/Ripple.d.ts +34 -0
- package/types/components/Ripple.d.ts.map +1 -0
- package/types/components/Root.d.ts +68 -0
- package/types/components/Root.d.ts.map +1 -0
- package/types/components/Scrim.d.ts +6 -0
- package/types/components/Scrim.d.ts.map +1 -0
- package/types/components/Search.d.ts +16 -0
- package/types/components/Search.d.ts.map +1 -0
- package/types/components/SegmentedButton.d.ts +718 -0
- package/types/components/SegmentedButton.d.ts.map +1 -0
- package/types/components/SegmentedButtonGroup.d.ts +44 -0
- package/types/components/SegmentedButtonGroup.d.ts.map +1 -0
- package/types/components/Select.d.ts +1361 -0
- package/types/components/Select.d.ts.map +1 -0
- package/types/components/Shape.d.ts +10 -0
- package/types/components/Shape.d.ts.map +1 -0
- package/types/components/SideSheet.d.ts +106 -0
- package/types/components/SideSheet.d.ts.map +1 -0
- package/types/components/Slider.d.ts +382 -0
- package/types/components/Slider.d.ts.map +1 -0
- package/types/components/Snackbar.d.ts +65 -0
- package/types/components/Snackbar.d.ts.map +1 -0
- package/types/components/SnackbarContainer.d.ts +6 -0
- package/types/components/SnackbarContainer.d.ts.map +1 -0
- package/types/components/Surface.d.ts +45 -0
- package/types/components/Surface.d.ts.map +1 -0
- package/types/components/Switch.d.ts +183 -0
- package/types/components/Switch.d.ts.map +1 -0
- package/types/components/SwitchIcon.d.ts +169 -0
- package/types/components/SwitchIcon.d.ts.map +1 -0
- package/types/components/Tab.d.ts +879 -0
- package/types/components/Tab.d.ts.map +1 -0
- package/types/components/TabContent.d.ts +122 -0
- package/types/components/TabContent.d.ts.map +1 -0
- package/types/components/TabList.d.ts +6266 -0
- package/types/components/TabList.d.ts.map +1 -0
- package/types/components/TabPanel.d.ts +28 -0
- package/types/components/TabPanel.d.ts.map +1 -0
- package/types/components/Table.d.ts +2 -0
- package/types/components/Table.d.ts.map +1 -0
- package/types/components/TextArea.d.ts +1394 -0
- package/types/components/TextArea.d.ts.map +1 -0
- package/types/components/Title.d.ts +47 -0
- package/types/components/Title.d.ts.map +1 -0
- package/types/components/Tooltip.d.ts +49 -0
- package/types/components/Tooltip.d.ts.map +1 -0
- package/types/components/TopAppBar.d.ts +130 -0
- package/types/components/TopAppBar.d.ts.map +1 -0
- package/types/constants/colorKeywords.d.ts +2 -0
- package/types/constants/colorKeywords.d.ts.map +1 -0
- package/types/constants/shapes.d.ts +38 -0
- package/types/constants/shapes.d.ts.map +1 -0
- package/types/constants/typography.d.ts +212 -0
- package/types/constants/typography.d.ts.map +1 -0
- package/types/core/Composition.d.ts +252 -0
- package/types/core/Composition.d.ts.map +1 -0
- package/types/core/CompositionAdapter.d.ts +92 -0
- package/types/core/CompositionAdapter.d.ts.map +1 -0
- package/types/core/CustomElement.d.ts +302 -0
- package/types/core/CustomElement.d.ts.map +1 -0
- package/types/core/css.d.ts +44 -0
- package/types/core/css.d.ts.map +1 -0
- package/types/core/customTypes.d.ts +26 -0
- package/types/core/customTypes.d.ts.map +1 -0
- package/types/core/dom.d.ts +32 -0
- package/types/core/dom.d.ts.map +1 -0
- package/types/core/jsonMergePatch.d.ts +31 -0
- package/types/core/jsonMergePatch.d.ts.map +1 -0
- package/types/core/observe.d.ts +113 -0
- package/types/core/observe.d.ts.map +1 -0
- package/types/core/optimizations.d.ts +7 -0
- package/types/core/optimizations.d.ts.map +1 -0
- package/types/core/template.d.ts +47 -0
- package/types/core/template.d.ts.map +1 -0
- package/types/core/uid.d.ts +6 -0
- package/types/core/uid.d.ts.map +1 -0
- package/types/dom/HTMLOptionsCollectionProxy.d.ts +18 -0
- package/types/dom/HTMLOptionsCollectionProxy.d.ts.map +1 -0
- package/types/index.d.ts +88 -0
- package/types/index.d.ts.map +1 -0
- package/types/loaders/palette.d.ts +2 -0
- package/types/loaders/palette.d.ts.map +1 -0
- package/types/loaders/theme.d.ts +2 -0
- package/types/loaders/theme.d.ts.map +1 -0
- package/types/mixins/AriaReflectorMixin.d.ts +23 -0
- package/types/mixins/AriaReflectorMixin.d.ts.map +1 -0
- package/types/mixins/AriaToolbarMixin.d.ts +32 -0
- package/types/mixins/AriaToolbarMixin.d.ts.map +1 -0
- package/types/mixins/ControlMixin.d.ts +124 -0
- package/types/mixins/ControlMixin.d.ts.map +1 -0
- package/types/mixins/DelegatesFocusMixin.d.ts +5 -0
- package/types/mixins/DelegatesFocusMixin.d.ts.map +1 -0
- package/types/mixins/DensityMixin.d.ts +5 -0
- package/types/mixins/DensityMixin.d.ts.map +1 -0
- package/types/mixins/ElevationMixin.d.ts +33 -0
- package/types/mixins/ElevationMixin.d.ts.map +1 -0
- package/types/mixins/FlexableMixin.d.ts +13 -0
- package/types/mixins/FlexableMixin.d.ts.map +1 -0
- package/types/mixins/FormAssociatedMixin.d.ts +122 -0
- package/types/mixins/FormAssociatedMixin.d.ts.map +1 -0
- package/types/mixins/HyperlinkMixin.d.ts +22 -0
- package/types/mixins/HyperlinkMixin.d.ts.map +1 -0
- package/types/mixins/InputMixin.d.ts +179 -0
- package/types/mixins/InputMixin.d.ts.map +1 -0
- package/types/mixins/KeyboardNavMixin.d.ts +47 -0
- package/types/mixins/KeyboardNavMixin.d.ts.map +1 -0
- package/types/mixins/NavigationListenerMixin.d.ts +8 -0
- package/types/mixins/NavigationListenerMixin.d.ts.map +1 -0
- package/types/mixins/PopupMixin.d.ts +82 -0
- package/types/mixins/PopupMixin.d.ts.map +1 -0
- package/types/mixins/RTLObserverMixin.d.ts +7 -0
- package/types/mixins/RTLObserverMixin.d.ts.map +1 -0
- package/types/mixins/ResizeObserverMixin.d.ts +12 -0
- package/types/mixins/ResizeObserverMixin.d.ts.map +1 -0
- package/types/mixins/RippleMixin.d.ts +92 -0
- package/types/mixins/RippleMixin.d.ts.map +1 -0
- package/types/mixins/ScrollListenerMixin.d.ts +41 -0
- package/types/mixins/ScrollListenerMixin.d.ts.map +1 -0
- package/types/mixins/SemiStickyMixin.d.ts +50 -0
- package/types/mixins/SemiStickyMixin.d.ts.map +1 -0
- package/types/mixins/ShapeMaskedMixin.d.ts +9 -0
- package/types/mixins/ShapeMaskedMixin.d.ts.map +1 -0
- package/types/mixins/ShapeMixin.d.ts +38 -0
- package/types/mixins/ShapeMixin.d.ts.map +1 -0
- package/types/mixins/StateMixin.d.ts +27 -0
- package/types/mixins/StateMixin.d.ts.map +1 -0
- package/types/mixins/TextFieldMixin.d.ts +1354 -0
- package/types/mixins/TextFieldMixin.d.ts.map +1 -0
- package/types/mixins/ThemableMixin.d.ts +9 -0
- package/types/mixins/ThemableMixin.d.ts.map +1 -0
- package/types/mixins/TooltipTriggerMixin.d.ts +106 -0
- package/types/mixins/TooltipTriggerMixin.d.ts.map +1 -0
- package/types/mixins/TouchTargetMixin.d.ts +3 -0
- package/types/mixins/TouchTargetMixin.d.ts.map +1 -0
- package/types/mixins/TypographyMixin.d.ts +17 -0
- package/types/mixins/TypographyMixin.d.ts.map +1 -0
- package/types/services/rtl.d.ts +3 -0
- package/types/services/rtl.d.ts.map +1 -0
- package/types/services/svgAlias.d.ts +13 -0
- package/types/services/svgAlias.d.ts.map +1 -0
- package/types/services/theme.d.ts +45 -0
- package/types/services/theme.d.ts.map +1 -0
- package/types/utils/cli.d.ts +3 -0
- package/types/utils/cli.d.ts.map +1 -0
- package/types/utils/function.d.ts +3 -0
- package/types/utils/function.d.ts.map +1 -0
- package/types/utils/jsx-runtime.d.ts +20 -0
- package/types/utils/jsx-runtime.d.ts.map +1 -0
- package/types/utils/material-color/blend.d.ts +34 -0
- package/types/utils/material-color/blend.d.ts.map +1 -0
- package/types/utils/material-color/hct/Cam16.d.ts +142 -0
- package/types/utils/material-color/hct/Cam16.d.ts.map +1 -0
- package/types/utils/material-color/hct/Hct.d.ts +93 -0
- package/types/utils/material-color/hct/Hct.d.ts.map +1 -0
- package/types/utils/material-color/hct/ViewingConditions.d.ts +69 -0
- package/types/utils/material-color/hct/ViewingConditions.d.ts.map +1 -0
- package/types/utils/material-color/hct/hctSolver.d.ts +30 -0
- package/types/utils/material-color/hct/hctSolver.d.ts.map +1 -0
- package/types/utils/material-color/helper.d.ts +8 -0
- package/types/utils/material-color/helper.d.ts.map +1 -0
- package/types/utils/material-color/palettes/CorePalette.d.ts +75 -0
- package/types/utils/material-color/palettes/CorePalette.d.ts.map +1 -0
- package/types/utils/material-color/palettes/TonalPalette.d.ts +38 -0
- package/types/utils/material-color/palettes/TonalPalette.d.ts.map +1 -0
- package/types/utils/material-color/scheme/Scheme.d.ts +264 -0
- package/types/utils/material-color/scheme/Scheme.d.ts.map +1 -0
- package/types/utils/material-color/utils/color.d.ts +172 -0
- package/types/utils/material-color/utils/color.d.ts.map +1 -0
- package/types/utils/material-color/utils/math.d.ts +94 -0
- package/types/utils/material-color/utils/math.d.ts.map +1 -0
- package/types/utils/pixelmatch.d.ts +22 -0
- package/types/utils/pixelmatch.d.ts.map +1 -0
- package/types/utils/popup.d.ts +106 -0
- package/types/utils/popup.d.ts.map +1 -0
- package/types/utils/searchParams.d.ts +3 -0
- package/types/utils/searchParams.d.ts.map +1 -0
- package/types/utils/svg.d.ts +7 -0
- package/types/utils/svg.d.ts.map +1 -0
- package/utils/{hct → material-color}/blend.js +8 -10
- package/utils/{hct → material-color/hct}/Cam16.js +196 -69
- package/utils/{hct → material-color/hct}/Hct.js +61 -19
- package/utils/{hct → material-color/hct}/ViewingConditions.js +3 -3
- package/utils/{hct → material-color/hct}/hctSolver.js +9 -16
- package/utils/{hct → material-color}/helper.js +11 -18
- package/utils/{hct → material-color/palettes}/CorePalette.js +79 -19
- package/utils/{hct → material-color/palettes}/TonalPalette.js +12 -4
- package/utils/material-color/scheme/Scheme.js +376 -0
- package/utils/{hct/colorUtils.js → material-color/utils/color.js} +61 -1
- package/utils/pixelmatch.js +360 -0
- package/utils/popup.js +127 -30
- package/utils/searchParams.js +19 -0
- package/components/ExtendedFab.js +0 -36
- package/components/Layout.js +0 -35
- package/components/ListSelect.js +0 -220
- package/components/Nav.js +0 -40
- package/components/Option.js +0 -91
- package/core/ICustomElement.d.ts +0 -291
- package/core/ICustomElement.js +0 -1
- package/core/identify.js +0 -40
- package/core/typings.d.ts +0 -136
- package/core/typings.js +0 -1
- package/mixins/SurfaceMixin.js +0 -181
- package/theming/loader.js +0 -22
- package/utils/hct/Scheme.js +0 -587
- /package/{utils/color_keywords.js → constants/colorKeywords.js} +0 -0
- /package/utils/{hct/mathUtils.js → material-color/utils/math.js} +0 -0
|
@@ -0,0 +1,94 @@
|
|
|
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
|
+
/**
|
|
18
|
+
* Utility methods for mathematical operations.
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* The signum function.
|
|
22
|
+
* @param {number} num
|
|
23
|
+
* @return {1|-1|0} 1 if num > 0, -1 if num < 0, and 0 if num = 0
|
|
24
|
+
*/
|
|
25
|
+
export function signum(num: number): 1 | -1 | 0;
|
|
26
|
+
/**
|
|
27
|
+
* The linear interpolation function.
|
|
28
|
+
* @param {number} start
|
|
29
|
+
* @param {number} stop
|
|
30
|
+
* @param {number} amount
|
|
31
|
+
* @return {number} start if amount = 0 and stop if amount = 1
|
|
32
|
+
*/
|
|
33
|
+
export function lerp(start: number, stop: number, amount: number): number;
|
|
34
|
+
/**
|
|
35
|
+
* Clamps an integer between two integers.
|
|
36
|
+
* @param {number} min
|
|
37
|
+
* @param {number} max
|
|
38
|
+
* @param {number} input
|
|
39
|
+
* @return {number} input when min <= input <= max, and either min or max
|
|
40
|
+
* otherwise.
|
|
41
|
+
*/
|
|
42
|
+
export function clampInt(min: number, max: number, input: number): number;
|
|
43
|
+
/**
|
|
44
|
+
* Clamps an integer between two floating-point numbers.
|
|
45
|
+
* @param {number} min
|
|
46
|
+
* @param {number} max
|
|
47
|
+
* @param {number} input
|
|
48
|
+
* @return {number} input when min <= input <= max, and either min or max
|
|
49
|
+
* otherwise.
|
|
50
|
+
*/
|
|
51
|
+
export function clampDouble(min: number, max: number, input: number): number;
|
|
52
|
+
/**
|
|
53
|
+
* Sanitizes a degree measure as an integer.
|
|
54
|
+
* @param {number} degrees
|
|
55
|
+
* @return {number} a degree measure between 0 (inclusive) and 360
|
|
56
|
+
* (exclusive).
|
|
57
|
+
*/
|
|
58
|
+
export function sanitizeDegreesInt(degrees: number): number;
|
|
59
|
+
/**
|
|
60
|
+
* Sanitizes a degree measure as a floating-point number.
|
|
61
|
+
* @param {number} degrees
|
|
62
|
+
* @return {number} a degree measure between 0.0 (inclusive) and 360.0
|
|
63
|
+
* (exclusive).
|
|
64
|
+
*/
|
|
65
|
+
export function sanitizeDegreesDouble(degrees: number): number;
|
|
66
|
+
/**
|
|
67
|
+
* Sign of direction change needed to travel from one angle to
|
|
68
|
+
* another.
|
|
69
|
+
*
|
|
70
|
+
* For angles that are 180 degrees apart from each other, both
|
|
71
|
+
* directions have the same travel distance, so either direction is
|
|
72
|
+
* shortest. The value 1.0 is returned in this case.
|
|
73
|
+
* @param {number} from The angle travel starts from, in degrees.
|
|
74
|
+
* @param {number} to The angle travel ends at, in degrees.
|
|
75
|
+
* @return {number} -1 if decreasing from leads to the shortest travel
|
|
76
|
+
* distance, 1 if increasing from leads to the shortest travel
|
|
77
|
+
* distance.
|
|
78
|
+
*/
|
|
79
|
+
export function rotationDirection(from: number, to: number): number;
|
|
80
|
+
/**
|
|
81
|
+
* Distance of two points on a circle, represented using degrees.
|
|
82
|
+
* @param {number} a
|
|
83
|
+
* @param {number} b
|
|
84
|
+
* @return {number}
|
|
85
|
+
*/
|
|
86
|
+
export function differenceDegrees(a: number, b: number): number;
|
|
87
|
+
/**
|
|
88
|
+
* Multiplies a 1x3 row vector with a 3x3 matrix.
|
|
89
|
+
* @param {number[]} row
|
|
90
|
+
* @param {number[][]} matrix
|
|
91
|
+
* @return {number[]}
|
|
92
|
+
*/
|
|
93
|
+
export function matrixMultiply(row: number[], matrix: number[][]): number[];
|
|
94
|
+
//# sourceMappingURL=math.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"math.d.ts","sourceRoot":"","sources":["../../../../utils/material-color/utils/math.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH;;GAEG;AAEH;;;;GAIG;AACH,4BAHW,MAAM,GACL,CAAC,GAAC,CAAC,CAAC,GAAC,CAAC,CAUjB;AAED;;;;;;GAMG;AACH,4BALW,MAAM,QACN,MAAM,UACN,MAAM,GACL,MAAM,CAIjB;AAED;;;;;;;GAOG;AACH,8BANW,MAAM,OACN,MAAM,SACN,MAAM,GACL,MAAM,CAWjB;AAED;;;;;;;GAOG;AACH,iCANW,MAAM,OACN,MAAM,SACN,MAAM,GACL,MAAM,CAWjB;AAED;;;;;GAKG;AACH,4CAJW,MAAM,GACL,MAAM,CASjB;AAED;;;;;GAKG;AACH,+CAJW,MAAM,GACL,MAAM,CASjB;AAED;;;;;;;;;;;;GAYG;AACH,wCANW,MAAM,MACN,MAAM,GACL,MAAM,CAOjB;AAED;;;;;GAKG;AACH,qCAJW,MAAM,KACN,MAAM,GACL,MAAM,CAIjB;AAED;;;;;GAKG;AACH,oCAJW,MAAM,EAAE,UACR,MAAM,EAAE,EAAE,GACT,MAAM,EAAE,CAOnB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {Uint8Array|Uint8ClampedArray} img1
|
|
3
|
+
* @param {Uint8Array|Uint8ClampedArray} img2
|
|
4
|
+
* @param {Uint8Array|Uint8ClampedArray} output
|
|
5
|
+
* @param {number} width
|
|
6
|
+
* @param {number} height
|
|
7
|
+
* @param {typeof DEFAULT_OPTIONS} [options]
|
|
8
|
+
* @return {number}
|
|
9
|
+
*/
|
|
10
|
+
export function pixelmatch(img1: Uint8Array | Uint8ClampedArray, img2: Uint8Array | Uint8ClampedArray, output: Uint8Array | Uint8ClampedArray, width: number, height: number, options?: typeof DEFAULT_OPTIONS): number;
|
|
11
|
+
type DEFAULT_OPTIONS = Object;
|
|
12
|
+
declare namespace DEFAULT_OPTIONS {
|
|
13
|
+
let threshold: number;
|
|
14
|
+
let includeAA: boolean;
|
|
15
|
+
let alpha: number;
|
|
16
|
+
let aaColor: number[];
|
|
17
|
+
let diffColor: number[];
|
|
18
|
+
let diffColorAlt: Array<number>;
|
|
19
|
+
let diffMask: boolean;
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=pixelmatch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pixelmatch.d.ts","sourceRoot":"","sources":["../../utils/pixelmatch.js"],"names":[],"mappings":"AA2RA;;;;;;;;GAQG;AACH,iCARW,UAAU,GAAC,iBAAiB,QAC5B,UAAU,GAAC,iBAAiB,UAC5B,UAAU,GAAC,iBAAiB,SAC5B,MAAM,UACN,MAAM,YACN,OAAO,eAAe,GACrB,MAAM,CAqEjB;uBAtVU,MAAM;;;;;;;sBAcL,KAAK,CAAC,MAAM,CAAC"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} DOMRectLike
|
|
3
|
+
* @prop {number} left
|
|
4
|
+
* @prop {number} right
|
|
5
|
+
* @prop {number} top
|
|
6
|
+
* @prop {number} bottom
|
|
7
|
+
* @prop {number} width
|
|
8
|
+
* @prop {number} height
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* @typedef {Object} CanAnchorPopUpOptions
|
|
12
|
+
* @prop {Element|DOMRectLike} [anchor]
|
|
13
|
+
* @prop {number|'left'|'center'|'right'} [clientX]
|
|
14
|
+
* @prop {number|'top'|'center'|'bottom'} [clientY]
|
|
15
|
+
* @prop {number} [pageX]
|
|
16
|
+
* @prop {number} [pageY]
|
|
17
|
+
* @prop {Element|{width:number, height:number}} [popup]
|
|
18
|
+
* @prop {number} [width]
|
|
19
|
+
* @prop {number} [height]
|
|
20
|
+
* @prop {number} [offsetX] Offset from anchor
|
|
21
|
+
* @prop {number} [offsetY] Offset from anchor
|
|
22
|
+
* @prop {number} [margin] Margin from page
|
|
23
|
+
* @prop {'left'|'center'|'right'} [directionX='right']
|
|
24
|
+
* @prop {'up'|'center'|'down'} [directionY='down']
|
|
25
|
+
* @prop {boolean} [force=false]
|
|
26
|
+
*/
|
|
27
|
+
/** @param {CanAnchorPopUpOptions} options */
|
|
28
|
+
export function canAnchorPopup(options: CanAnchorPopUpOptions): {
|
|
29
|
+
top: number;
|
|
30
|
+
right: number;
|
|
31
|
+
bottom: number;
|
|
32
|
+
left: number;
|
|
33
|
+
visibility: number;
|
|
34
|
+
styles: {
|
|
35
|
+
top: string;
|
|
36
|
+
bottom: string;
|
|
37
|
+
left: string;
|
|
38
|
+
right: string;
|
|
39
|
+
maxWidth: string;
|
|
40
|
+
maxHeight: string;
|
|
41
|
+
transformOrigin: string;
|
|
42
|
+
};
|
|
43
|
+
anchor?: Element | DOMRectLike;
|
|
44
|
+
clientX?: number | "left" | "center" | "right";
|
|
45
|
+
clientY?: number | "top" | "center" | "bottom";
|
|
46
|
+
pageX?: number;
|
|
47
|
+
pageY?: number;
|
|
48
|
+
popup?: Element | {
|
|
49
|
+
width: number;
|
|
50
|
+
height: number;
|
|
51
|
+
};
|
|
52
|
+
width?: number;
|
|
53
|
+
height?: number;
|
|
54
|
+
/**
|
|
55
|
+
* Offset from anchor
|
|
56
|
+
*/
|
|
57
|
+
offsetX?: number;
|
|
58
|
+
/**
|
|
59
|
+
* Offset from anchor
|
|
60
|
+
*/
|
|
61
|
+
offsetY?: number;
|
|
62
|
+
/**
|
|
63
|
+
* Margin from page
|
|
64
|
+
*/
|
|
65
|
+
margin?: number;
|
|
66
|
+
directionX?: "left" | "center" | "right";
|
|
67
|
+
directionY?: "up" | "center" | "down";
|
|
68
|
+
force?: boolean;
|
|
69
|
+
};
|
|
70
|
+
export type DOMRectLike = {
|
|
71
|
+
left: number;
|
|
72
|
+
right: number;
|
|
73
|
+
top: number;
|
|
74
|
+
bottom: number;
|
|
75
|
+
width: number;
|
|
76
|
+
height: number;
|
|
77
|
+
};
|
|
78
|
+
export type CanAnchorPopUpOptions = {
|
|
79
|
+
anchor?: Element | DOMRectLike;
|
|
80
|
+
clientX?: number | "left" | "center" | "right";
|
|
81
|
+
clientY?: number | "top" | "center" | "bottom";
|
|
82
|
+
pageX?: number;
|
|
83
|
+
pageY?: number;
|
|
84
|
+
popup?: Element | {
|
|
85
|
+
width: number;
|
|
86
|
+
height: number;
|
|
87
|
+
};
|
|
88
|
+
width?: number;
|
|
89
|
+
height?: number;
|
|
90
|
+
/**
|
|
91
|
+
* Offset from anchor
|
|
92
|
+
*/
|
|
93
|
+
offsetX?: number;
|
|
94
|
+
/**
|
|
95
|
+
* Offset from anchor
|
|
96
|
+
*/
|
|
97
|
+
offsetY?: number;
|
|
98
|
+
/**
|
|
99
|
+
* Margin from page
|
|
100
|
+
*/
|
|
101
|
+
margin?: number;
|
|
102
|
+
directionX?: "left" | "center" | "right";
|
|
103
|
+
directionY?: "up" | "center" | "down";
|
|
104
|
+
force?: boolean;
|
|
105
|
+
};
|
|
106
|
+
//# sourceMappingURL=popup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"popup.d.ts","sourceRoot":"","sources":["../../utils/popup.js"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;;GAgBG;AAEH,6CAA6C;AAC7C,wCADY,qBAAqB;;;;;;;;;;;;;;;aAhBvB,OAAO,GAAC,WAAW;cACnB,MAAM,GAAC,MAAM,GAAC,QAAQ,GAAC,OAAO;cAC9B,MAAM,GAAC,KAAK,GAAC,QAAQ,GAAC,QAAQ;YAC9B,MAAM;YACN,MAAM;YACN,OAAO,GAAC;QAAC,KAAK,EAAC,MAAM,CAAC;QAAC,MAAM,EAAC,MAAM,CAAA;KAAC;YACrC,MAAM;aACN,MAAM;;;;cACN,MAAM;;;;cACN,MAAM;;;;aACN,MAAM;iBACN,MAAM,GAAC,QAAQ,GAAC,OAAO;iBACvB,IAAI,GAAC,QAAQ,GAAC,MAAM;YACpB,OAAO;EA4LhB;;UAnNS,MAAM;WACN,MAAM;SACN,MAAM;YACN,MAAM;WACN,MAAM;YACN,MAAM;;;aAKN,OAAO,GAAC,WAAW;cACnB,MAAM,GAAC,MAAM,GAAC,QAAQ,GAAC,OAAO;cAC9B,MAAM,GAAC,KAAK,GAAC,QAAQ,GAAC,QAAQ;YAC9B,MAAM;YACN,MAAM;YACN,OAAO,GAAC;QAAC,KAAK,EAAC,MAAM,CAAC;QAAC,MAAM,EAAC,MAAM,CAAA;KAAC;YACrC,MAAM;aACN,MAAM;;;;cACN,MAAM;;;;cACN,MAAM;;;;aACN,MAAM;iBACN,MAAM,GAAC,QAAQ,GAAC,OAAO;iBACvB,IAAI,GAAC,QAAQ,GAAC,MAAM;YACpB,OAAO"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"searchParams.d.ts","sourceRoot":"","sources":["../../utils/searchParams.js"],"names":[],"mappings":"AAGA,gCAAgC;AAChC,0CADa,eAAe,CAe3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"svg.d.ts","sourceRoot":"","sources":["../../utils/svg.js"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,iCAHW,MAAM,GACL,MAAM,CAQjB"}
|
|
@@ -15,16 +15,14 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
// tslint:disable:class-as-namespace
|
|
18
|
+
import Cam16 from './hct/Cam16.js';
|
|
19
|
+
import Hct from './hct/Hct.js';
|
|
20
|
+
import * as colorUtils from './utils/color.js';
|
|
21
|
+
import * as mathUtils from './utils/math.js';
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
import * as mathUtils from './mathUtils.js';
|
|
23
|
+
/**
|
|
24
|
+
* Functions for blending in HCT and CAM16.
|
|
25
|
+
*/
|
|
28
26
|
|
|
29
27
|
/**
|
|
30
28
|
* Blend the design color's HCT hue towards the key color's HCT
|
|
@@ -43,7 +41,7 @@ export function harmonize(designColor, sourceColor) {
|
|
|
43
41
|
const rotationDegrees = Math.min(differenceDegrees * 0.5, 15);
|
|
44
42
|
const outputHue = mathUtils.sanitizeDegreesDouble(
|
|
45
43
|
fromHct.hue
|
|
46
|
-
|
|
44
|
+
+ rotationDegrees * mathUtils.rotationDirection(fromHct.hue, toHct.hue),
|
|
47
45
|
);
|
|
48
46
|
return Hct.from(outputHue, fromHct.chroma, fromHct.tone).toInt();
|
|
49
47
|
}
|
|
@@ -15,9 +15,10 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
+
import * as utils from '../utils/color.js';
|
|
19
|
+
import * as math from '../utils/math.js';
|
|
20
|
+
|
|
18
21
|
import ViewingConditions from './ViewingConditions.js';
|
|
19
|
-
import * as utils from './colorUtils.js';
|
|
20
|
-
import * as math from './mathUtils.js';
|
|
21
22
|
|
|
22
23
|
/**
|
|
23
24
|
* CAM16, a color appearance model. Colors are not just defined by their hex
|
|
@@ -37,62 +38,6 @@ import * as math from './mathUtils.js';
|
|
|
37
38
|
* hue 203, chroma 3, lightness 100)
|
|
38
39
|
*/
|
|
39
40
|
export default class Cam16 {
|
|
40
|
-
/**
|
|
41
|
-
* All of the CAM16 dimensions can be calculated from 3 of the dimensions, in
|
|
42
|
-
* the following combinations:
|
|
43
|
-
* - {j or q} and {c, m, or s} and hue
|
|
44
|
-
* - jstar, astar, bstar
|
|
45
|
-
* Prefer using a static method that constructs from 3 of those dimensions.
|
|
46
|
-
* This constructor is intended for those methods to use to return all
|
|
47
|
-
* possible dimensions.
|
|
48
|
-
* @param {number} hue
|
|
49
|
-
* @param {number} chroma informally, colorfulness / color intensity. like saturation
|
|
50
|
-
* in HSL, except perceptually accurate.
|
|
51
|
-
* @param {number} j lightness
|
|
52
|
-
* @param {number} q brightness; ratio of lightness to white point's lightness
|
|
53
|
-
* @param {number} m colorfulness
|
|
54
|
-
* @param {number} s saturation; ratio of chroma to white point's chroma
|
|
55
|
-
* @param {number} jstar CAM16-UCS J coordinate
|
|
56
|
-
* @param {number} astar CAM16-UCS a coordinate
|
|
57
|
-
* @param {number} bstar CAM16-UCS b coordinate
|
|
58
|
-
*/
|
|
59
|
-
constructor(hue, chroma, j, q, m, s, jstar, astar, bstar) {
|
|
60
|
-
/** @readonly */
|
|
61
|
-
this.hue = hue;
|
|
62
|
-
/** @readonly */
|
|
63
|
-
this.chroma = chroma;
|
|
64
|
-
/** @readonly */
|
|
65
|
-
this.j = j;
|
|
66
|
-
/** @readonly */
|
|
67
|
-
this.q = q;
|
|
68
|
-
/** @readonly */
|
|
69
|
-
this.m = m;
|
|
70
|
-
/** @readonly */
|
|
71
|
-
this.s = s;
|
|
72
|
-
/** @readonly */
|
|
73
|
-
this.jstar = jstar;
|
|
74
|
-
/** @readonly */
|
|
75
|
-
this.astar = astar;
|
|
76
|
-
/** @readonly */
|
|
77
|
-
this.bstar = bstar;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* CAM16 instances also have coordinates in the CAM16-UCS space, called J*,
|
|
82
|
-
* a*, b*, or jstar, astar, bstar in code. CAM16-UCS is included in the CAM16
|
|
83
|
-
* specification, and is used to measure distances between colors.
|
|
84
|
-
* @param {Cam16} other
|
|
85
|
-
* @return {number}
|
|
86
|
-
*/
|
|
87
|
-
distance(other) {
|
|
88
|
-
const dJ = this.jstar - other.jstar;
|
|
89
|
-
const dA = this.astar - other.astar;
|
|
90
|
-
const dB = this.bstar - other.bstar;
|
|
91
|
-
const dEPrime = Math.sqrt(dJ * dJ + dA * dA + dB * dB);
|
|
92
|
-
const dE = 1.41 * dEPrime ** 0.63;
|
|
93
|
-
return dE;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
41
|
/**
|
|
97
42
|
* @param {number} argb ARGB representation of a color.
|
|
98
43
|
* @return {Cam16} CAM16 color, assuming the color was viewed in default viewing
|
|
@@ -148,19 +93,19 @@ export default class Cam16 {
|
|
|
148
93
|
|
|
149
94
|
const ac = p2 * viewingConditions.nbb;
|
|
150
95
|
const j = 100
|
|
151
|
-
|
|
96
|
+
* (ac / viewingConditions.aw) ** (viewingConditions.c * viewingConditions.z);
|
|
152
97
|
const q = (4 / viewingConditions.c) * Math.sqrt(j / 100)
|
|
153
|
-
|
|
98
|
+
* (viewingConditions.aw + 4) * viewingConditions.fLRoot;
|
|
154
99
|
const huePrime = hue < 20.14 ? hue + 360 : hue;
|
|
155
100
|
const eHue = 0.25 * (Math.cos((huePrime * Math.PI) / 180 + 2) + 3.8);
|
|
156
101
|
const p1 = (50_000 / 13) * eHue * viewingConditions.nc * viewingConditions.ncb;
|
|
157
102
|
const t = (p1 * Math.sqrt(a * a + b * b)) / (u + 0.305);
|
|
158
103
|
const alpha = t ** 0.9
|
|
159
|
-
|
|
104
|
+
* (1.64 - 0.29 ** viewingConditions.n) ** 0.73;
|
|
160
105
|
const c = alpha * Math.sqrt(j / 100);
|
|
161
106
|
const m = c * viewingConditions.fLRoot;
|
|
162
107
|
const s = 50
|
|
163
|
-
|
|
108
|
+
* Math.sqrt((alpha * viewingConditions.c) / (viewingConditions.aw + 4));
|
|
164
109
|
const jstar = ((1 + 100 * 0.007) * j) / (1 + 0.007 * j);
|
|
165
110
|
const mstar = (1 / 0.0228) * Math.log(1 + 0.0228 * m);
|
|
166
111
|
const astar = mstar * Math.cos(hueRadians);
|
|
@@ -188,11 +133,11 @@ export default class Cam16 {
|
|
|
188
133
|
*/
|
|
189
134
|
static fromJchInViewingConditions(j, c, h, viewingConditions) {
|
|
190
135
|
const q = (4 / viewingConditions.c) * Math.sqrt(j / 100)
|
|
191
|
-
|
|
136
|
+
* (viewingConditions.aw + 4) * viewingConditions.fLRoot;
|
|
192
137
|
const m = c * viewingConditions.fLRoot;
|
|
193
138
|
const alpha = c / Math.sqrt(j / 100);
|
|
194
139
|
const s = 50
|
|
195
|
-
|
|
140
|
+
* Math.sqrt((alpha * viewingConditions.c) / (viewingConditions.aw + 4));
|
|
196
141
|
const hueRadians = (h * Math.PI) / 180;
|
|
197
142
|
const jstar = ((1 + 100 * 0.007) * j) / (1 + 0.007 * j);
|
|
198
143
|
const mstar = (1 / 0.0228) * Math.log(1 + 0.0228 * m);
|
|
@@ -236,6 +181,137 @@ export default class Cam16 {
|
|
|
236
181
|
return Cam16.fromJchInViewingConditions(j, c, h, viewingConditions);
|
|
237
182
|
}
|
|
238
183
|
|
|
184
|
+
/**
|
|
185
|
+
* Given color expressed in XYZ and viewed in [viewingConditions], convert to
|
|
186
|
+
* CAM16.
|
|
187
|
+
* @param {number} x
|
|
188
|
+
* @param {number} y
|
|
189
|
+
* @param {number} z
|
|
190
|
+
* @param {ViewingConditions} viewingConditions
|
|
191
|
+
* @return {Cam16}
|
|
192
|
+
*/
|
|
193
|
+
static fromXyzInViewingConditions(x, y, z, viewingConditions) {
|
|
194
|
+
// Transform XYZ to 'cone'/'rgb' responses
|
|
195
|
+
|
|
196
|
+
const rC = 0.401_288 * x + 0.650_173 * y - 0.051_461 * z;
|
|
197
|
+
const gC = -0.250_268 * x + 1.204_414 * y + 0.045_854 * z;
|
|
198
|
+
const bC = -0.002_079 * x + 0.048_952 * y + 0.953_127 * z;
|
|
199
|
+
|
|
200
|
+
// Discount illuminant
|
|
201
|
+
const rD = viewingConditions.rgbD[0] * rC;
|
|
202
|
+
const gD = viewingConditions.rgbD[1] * gC;
|
|
203
|
+
const bD = viewingConditions.rgbD[2] * bC;
|
|
204
|
+
|
|
205
|
+
// chromatic adaptation
|
|
206
|
+
const rAF = ((viewingConditions.fl * Math.abs(rD)) / 100) ** 0.42;
|
|
207
|
+
const gAF = ((viewingConditions.fl * Math.abs(gD)) / 100) ** 0.42;
|
|
208
|
+
const bAF = ((viewingConditions.fl * Math.abs(bD)) / 100) ** 0.42;
|
|
209
|
+
const rA = (math.signum(rD) * 400 * rAF) / (rAF + 27.13);
|
|
210
|
+
const gA = (math.signum(gD) * 400 * gAF) / (gAF + 27.13);
|
|
211
|
+
const bA = (math.signum(bD) * 400 * bAF) / (bAF + 27.13);
|
|
212
|
+
|
|
213
|
+
// redness-greenness
|
|
214
|
+
const a = (11 * rA + -12 * gA + bA) / 11;
|
|
215
|
+
// yellowness-blueness
|
|
216
|
+
const b = (rA + gA - 2 * bA) / 9;
|
|
217
|
+
|
|
218
|
+
// auxiliary components
|
|
219
|
+
const u = (20 * rA + 20 * gA + 21 * bA) / 20;
|
|
220
|
+
const p2 = (40 * rA + 20 * gA + bA) / 20;
|
|
221
|
+
|
|
222
|
+
// hue
|
|
223
|
+
const atan2 = Math.atan2(b, a);
|
|
224
|
+
const atanDegrees = (atan2 * 180) / Math.PI;
|
|
225
|
+
const hue = atanDegrees < 0 ? atanDegrees + 360
|
|
226
|
+
: (atanDegrees >= 360 ? atanDegrees - 360
|
|
227
|
+
: atanDegrees);
|
|
228
|
+
const hueRadians = (hue * Math.PI) / 180;
|
|
229
|
+
|
|
230
|
+
// achromatic response to color
|
|
231
|
+
const ac = p2 * viewingConditions.nbb;
|
|
232
|
+
|
|
233
|
+
// CAM16 lightness and brightness
|
|
234
|
+
const J = 100
|
|
235
|
+
* (ac / viewingConditions.aw) ** (viewingConditions.c * viewingConditions.z);
|
|
236
|
+
const Q = (4 / viewingConditions.c) * Math.sqrt(J / 100)
|
|
237
|
+
* (viewingConditions.aw + 4) * (viewingConditions.fLRoot);
|
|
238
|
+
|
|
239
|
+
const huePrime = (hue < 20.14) ? hue + 360 : hue;
|
|
240
|
+
const eHue = (1 / 4) * (Math.cos((huePrime * Math.PI) / 180 + 2) + 3.8);
|
|
241
|
+
const p1 = (50_000 / 13) * eHue * viewingConditions.nc * viewingConditions.ncb;
|
|
242
|
+
const t = (p1 * Math.sqrt(a * a + b * b)) / (u + 0.305);
|
|
243
|
+
const alpha = t ** 0.9
|
|
244
|
+
* (1.64 - 0.29 ** viewingConditions.n) ** 0.73;
|
|
245
|
+
// CAM16 chroma, colorfulness, chroma
|
|
246
|
+
const C = alpha * Math.sqrt(J / 100);
|
|
247
|
+
const M = C * viewingConditions.fLRoot;
|
|
248
|
+
const s = 50
|
|
249
|
+
* Math.sqrt((alpha * viewingConditions.c) / (viewingConditions.aw + 4));
|
|
250
|
+
|
|
251
|
+
// CAM16-UCS components
|
|
252
|
+
const jstar = ((1 + 100 * 0.007) * J) / (1 + 0.007 * J);
|
|
253
|
+
const mstar = Math.log(1 + 0.0228 * M) / 0.0228;
|
|
254
|
+
const astar = mstar * Math.cos(hueRadians);
|
|
255
|
+
const bstar = mstar * Math.sin(hueRadians);
|
|
256
|
+
return new Cam16(hue, C, J, Q, M, s, jstar, astar, bstar);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* All of the CAM16 dimensions can be calculated from 3 of the dimensions, in
|
|
261
|
+
* the following combinations:
|
|
262
|
+
* - {j or q} and {c, m, or s} and hue
|
|
263
|
+
* - jstar, astar, bstar
|
|
264
|
+
* Prefer using a static method that constructs from 3 of those dimensions.
|
|
265
|
+
* This constructor is intended for those methods to use to return all
|
|
266
|
+
* possible dimensions.
|
|
267
|
+
* @param {number} hue
|
|
268
|
+
* @param {number} chroma informally, colorfulness / color intensity. like saturation
|
|
269
|
+
* in HSL, except perceptually accurate.
|
|
270
|
+
* @param {number} j lightness
|
|
271
|
+
* @param {number} q brightness; ratio of lightness to white point's lightness
|
|
272
|
+
* @param {number} m colorfulness
|
|
273
|
+
* @param {number} s saturation; ratio of chroma to white point's chroma
|
|
274
|
+
* @param {number} jstar CAM16-UCS J coordinate
|
|
275
|
+
* @param {number} astar CAM16-UCS a coordinate
|
|
276
|
+
* @param {number} bstar CAM16-UCS b coordinate
|
|
277
|
+
*/
|
|
278
|
+
constructor(hue, chroma, j, q, m, s, jstar, astar, bstar) {
|
|
279
|
+
/** @readonly */
|
|
280
|
+
this.hue = hue;
|
|
281
|
+
/** @readonly */
|
|
282
|
+
this.chroma = chroma;
|
|
283
|
+
/** @readonly */
|
|
284
|
+
this.j = j;
|
|
285
|
+
/** @readonly */
|
|
286
|
+
this.q = q;
|
|
287
|
+
/** @readonly */
|
|
288
|
+
this.m = m;
|
|
289
|
+
/** @readonly */
|
|
290
|
+
this.s = s;
|
|
291
|
+
/** @readonly */
|
|
292
|
+
this.jstar = jstar;
|
|
293
|
+
/** @readonly */
|
|
294
|
+
this.astar = astar;
|
|
295
|
+
/** @readonly */
|
|
296
|
+
this.bstar = bstar;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* CAM16 instances also have coordinates in the CAM16-UCS space, called J*,
|
|
301
|
+
* a*, b*, or jstar, astar, bstar in code. CAM16-UCS is included in the CAM16
|
|
302
|
+
* specification, and is used to measure distances between colors.
|
|
303
|
+
* @param {Cam16} other
|
|
304
|
+
* @return {number}
|
|
305
|
+
*/
|
|
306
|
+
distance(other) {
|
|
307
|
+
const dJ = this.jstar - other.jstar;
|
|
308
|
+
const dA = this.astar - other.astar;
|
|
309
|
+
const dB = this.bstar - other.bstar;
|
|
310
|
+
const dEPrime = Math.sqrt(dJ * dJ + dA * dA + dB * dB);
|
|
311
|
+
const dE = 1.41 * dEPrime ** 0.63;
|
|
312
|
+
return dE;
|
|
313
|
+
}
|
|
314
|
+
|
|
239
315
|
/**
|
|
240
316
|
* @return {number} ARGB representation of color, assuming the color was viewed in
|
|
241
317
|
* default viewing conditions, which are near-identical to the default
|
|
@@ -260,7 +336,7 @@ export default class Cam16 {
|
|
|
260
336
|
|
|
261
337
|
const eHue = 0.25 * (Math.cos(hRad + 2) + 3.8);
|
|
262
338
|
const ac = viewingConditions.aw
|
|
263
|
-
|
|
339
|
+
* (this.j / 100) ** (1 / viewingConditions.c / viewingConditions.z);
|
|
264
340
|
const p1 = eHue * (50_000 / 13) * viewingConditions.nc * viewingConditions.ncb;
|
|
265
341
|
const p2 = ac / viewingConditions.nbb;
|
|
266
342
|
|
|
@@ -268,7 +344,7 @@ export default class Cam16 {
|
|
|
268
344
|
const hCos = Math.cos(hRad);
|
|
269
345
|
|
|
270
346
|
const gamma = (23 * (p2 + 0.305) * t)
|
|
271
|
-
|
|
347
|
+
/ (23 * p1 + 11 * t * hCos + 108 * t * hSin);
|
|
272
348
|
const a = gamma * hCos;
|
|
273
349
|
const b = gamma * hSin;
|
|
274
350
|
const rA = (460 * p2 + 451 * a + 288 * b) / 1403;
|
|
@@ -277,13 +353,13 @@ export default class Cam16 {
|
|
|
277
353
|
|
|
278
354
|
const rCBase = Math.max(0, (27.13 * Math.abs(rA)) / (400 - Math.abs(rA)));
|
|
279
355
|
const rC = math.signum(rA) * (100 / viewingConditions.fl)
|
|
280
|
-
|
|
356
|
+
* rCBase ** (1 / 0.42);
|
|
281
357
|
const gCBase = Math.max(0, (27.13 * Math.abs(gA)) / (400 - Math.abs(gA)));
|
|
282
358
|
const gC = math.signum(gA) * (100 / viewingConditions.fl)
|
|
283
|
-
|
|
359
|
+
* gCBase ** (1 / 0.42);
|
|
284
360
|
const bCBase = Math.max(0, (27.13 * Math.abs(bA)) / (400 - Math.abs(bA)));
|
|
285
361
|
const bC = math.signum(bA) * (100 / viewingConditions.fl)
|
|
286
|
-
|
|
362
|
+
* bCBase ** (1 / 0.42);
|
|
287
363
|
const rF = rC / viewingConditions.rgbD[0];
|
|
288
364
|
const gF = gC / viewingConditions.rgbD[1];
|
|
289
365
|
const bF = bC / viewingConditions.rgbD[2];
|
|
@@ -295,4 +371,55 @@ export default class Cam16 {
|
|
|
295
371
|
const argb = utils.argbFromXyz(x, y, z);
|
|
296
372
|
return argb;
|
|
297
373
|
}
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* XYZ representation of CAM16 seen in [viewingConditions].
|
|
377
|
+
* @param {ViewingConditions} viewingConditions
|
|
378
|
+
* @return {number[]}
|
|
379
|
+
*/
|
|
380
|
+
xyzInViewingConditions(viewingConditions) {
|
|
381
|
+
const alpha = (this.chroma === 0 || this.j === 0)
|
|
382
|
+
? 0
|
|
383
|
+
: this.chroma / Math.sqrt(this.j / 100);
|
|
384
|
+
|
|
385
|
+
const t = (alpha / (1.64 - 0.29 ** viewingConditions.n) ** 0.73) ** (1 / 0.9);
|
|
386
|
+
const hRad = (this.hue * Math.PI) / 180;
|
|
387
|
+
|
|
388
|
+
const eHue = 0.25 * (Math.cos(hRad + 2) + 3.8);
|
|
389
|
+
const ac = viewingConditions.aw
|
|
390
|
+
* (this.j / 100) ** (1 / viewingConditions.c / viewingConditions.z);
|
|
391
|
+
const p1 = eHue * (50_000 / 13) * viewingConditions.nc * viewingConditions.ncb;
|
|
392
|
+
|
|
393
|
+
const p2 = (ac / viewingConditions.nbb);
|
|
394
|
+
|
|
395
|
+
const hSin = Math.sin(hRad);
|
|
396
|
+
const hCos = Math.cos(hRad);
|
|
397
|
+
|
|
398
|
+
const gamma = (23 * (p2 + 0.305) * t)
|
|
399
|
+
/ (23 * p1 + 11 * t * hCos + 108 * t * hSin);
|
|
400
|
+
const a = gamma * hCos;
|
|
401
|
+
const b = gamma * hSin;
|
|
402
|
+
const rA = (460 * p2 + 451 * a + 288 * b) / 1403;
|
|
403
|
+
const gA = (460 * p2 - 891 * a - 261 * b) / 1403;
|
|
404
|
+
const bA = (460 * p2 - 220 * a - 6300 * b) / 1403;
|
|
405
|
+
|
|
406
|
+
const rCBase = Math.max(0, (27.13 * Math.abs(rA)) / (400 - Math.abs(rA)));
|
|
407
|
+
const rC = math.signum(rA) * (100 / viewingConditions.fl)
|
|
408
|
+
* rCBase ** (1 / 0.42);
|
|
409
|
+
const gCBase = Math.max(0, (27.13 * Math.abs(gA)) / (400 - Math.abs(gA)));
|
|
410
|
+
const gC = math.signum(gA) * (100 / viewingConditions.fl)
|
|
411
|
+
* gCBase ** (1 / 0.42);
|
|
412
|
+
const bCBase = Math.max(0, (27.13 * Math.abs(bA)) / (400 - Math.abs(bA)));
|
|
413
|
+
const bC = math.signum(bA) * (100 / viewingConditions.fl)
|
|
414
|
+
* bCBase ** (1 / 0.42);
|
|
415
|
+
const rF = rC / viewingConditions.rgbD[0];
|
|
416
|
+
const gF = gC / viewingConditions.rgbD[1];
|
|
417
|
+
const bF = bC / viewingConditions.rgbD[2];
|
|
418
|
+
|
|
419
|
+
const x = 1.862_067_86 * rF - 1.011_254_63 * gF + 0.149_186_77 * bF;
|
|
420
|
+
const y = 0.387_526_54 * rF + 0.621_447_44 * gF - 0.008_973_98 * bF;
|
|
421
|
+
const z = -0.015_841_5 * rF - 0.034_122_94 * gF + 1.049_964_44 * bF;
|
|
422
|
+
|
|
423
|
+
return [x, y, z];
|
|
424
|
+
}
|
|
298
425
|
}
|