diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index d39017e2..cad930c8 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -1,2 +1 @@
-This repo is not accepting external contributions, but feature requests and bug
-reports are welcome on [Github](https://github.com/material-foundation/material-color-utilities/issues).
+This repo is not accepting external contributions.
diff --git a/cheat_sheet.png b/cheat_sheet.png
deleted file mode 100644
index a079ac03..00000000
Binary files a/cheat_sheet.png and /dev/null differ
diff --git a/concepts/color_extraction.md b/concepts/color_extraction.md
deleted file mode 100644
index 7e2c5931..00000000
--- a/concepts/color_extraction.md
+++ /dev/null
@@ -1,59 +0,0 @@
-# Color Extraction
-
-## Background
-
-### From a wallpaper
-
-User-generated color comes from a user's personal wallpaper. The wallpaper is
-digitally analyzed through a process called quantization, and a single color is
-selected as the source color.
-
-
-
-### From in-app content
-
-Content-based color comes from in-app content, like an album thumbnail image,
-logo, or video preview. Like user-generated color, the image is digitally
-analyzed through quantization, and a single color selected as the source color.
-
-
-
-## Extracting colors from an image
-
-### Quantize
-
-This is a lossy compression process to select a limited number of distinct
-colors that best reproduces the original image's appearance. The recommended
-quantizer is Celebi, which uses results from Wu and WSMeans.
-
-### Scoring
-
-Evaluate and rank colors based on their suitability for UI themes. It
-prioritizes colors that are both visually appealing and frequently used within a
-given image. The main usage of scoring is to extract a set of dominant and
-vibrant colors to use as source color to generate a dynamic color scheme.
-
-Key metrics include:
-
-- **Color diversity:** The algorithm promotes visually distinct colors by
- giving higher scores to hues that are well-represented in the image within a
- 30-degree neighborhood on the color wheel. It also iteratively tests
- different minimum hue differences to find a set that meets the desired
- number of colors while maintaining good hue distribution.
-
-- **Vibrant chroma:** Colors closer to the target chroma of 48.0 receive
- higher scores. Colors with very low chroma (close to grayscale) or those
- that are extremely rare in the image will be filtered out.
-
-## To color themes
-
-Ever wonder how Pixel extracts colors from a phone wallpaper to create
-accessible and beautiful UIs? The steps can be summarized as follows:
-
-1. Quantize to obtain a representative set of colors from the wallpaper.
-1. Score to obtain suitable source colors.
-1. Present theme options by pairing the resulting source colors with available
- scheme variants to the user and let them pick.
-1. Create tonal palettes from the user-selected theme.
-1. Assign Material color roles with values from these tonal palettes.
-1. Colors get applied to UIs via Material tokens.
diff --git a/concepts/color_spaces.md b/concepts/color_spaces.md
deleted file mode 100644
index d887191d..00000000
--- a/concepts/color_spaces.md
+++ /dev/null
@@ -1,262 +0,0 @@
-# Color spaces in MCU
-
-
-
-## Overview
-
-Color spaces are used to describe color. A color does not change when moved
-between color spaces. Using different “distance spaces” like kilometers, or
-miles, does not change where you are - it just changes the measure of where you
-are.
-
-Color spaces used in design today, RGB, HSL, CMYK, etc., specify colors, but are
-flawed in several fundamental ways. They describe colors, but do not do a good
-job of describing the relationships between colors. As such, MCU uses multiple
-**color spaces** to create a dynamic design system. Each color space is useful
-in a different area and provides a way to understand colors.
-
-For example, sRGB is easy for machine to display but not for humans. You get the
-colors but not the characteristics. HCT provides a way to define different
-characteristics of the color such as hue, chroma, and tone. MCU does most of
-calculation in HCT then converts the colors to sRGB for consumption.
-
-## Basics
-
-In each color space, colors are represented as points in a coordinate system.
-Any point can be located by rectangular (Cartesian) or circular (polar)
-coordinates. For instance, this particular color, which occurs naturally, can be
-described in each each space using three numerical values.
-
-{style="float: left; padding: 50px"}
-
-Color space | Coordinates
------------ | -------------------------------
-sRGB | 255, 102, 0 (hex code: #ff6600)
-linear RGB | 100.00, 13.29, 0.00
-XYZ | 45.99, 30.76, 3.52
-L\*a\*b\* | 62.31, 54.99, 71.33
-Cam16-JCH | 55.16, 79.39, 42.39
-Cam16-UCS | 67.65, 28.75, 26.24
-HCT | 42.39, 79.39, 62.31
-
-Most color spaces are three-dimensional is not a coincidence. Human eyes
-typically possess three types of cone cells: one that is most sensitive to
-shorter wavelengths (commonly referred to as blue), another that is most
-sensitive to medium wavelengths (commonly referred to as green), and a third
-that is most sensitive to longer wavelengths (commonly referred to as red).
-Cells respond with varying strength to signals produced by lights of different
-wavelengths. Hence, the human perception of any color can be described using
-three numerical values.
-
-The range of colors that can be represented differs for each color space. Color
-spaces like **XYZ** can represent any color that human eyes can see. They serve
-as a helpful basis for describing colors objectively. Conversely, the **sRGB**
-color space is useful for displaying colors; however, due to the shape of the
-Gamut, certain colors cannot be represented using three displayable primaries,
-resulting in their absence in the sRGB color space.
-
-## Color spaces used in MCU
-
-### sRGB
-
-RGB represents colors as a combination of red, green, and blue. This is
-primarily used for display. The bit depth for each channel is usually 8, meaning
-there are 2563 = 16 777 216 colors available.
-
-In MCU, an sRGB color usually appears as a hexadecimal number in ARGB format:
-for example, `#abcdef` is `0xffabcdef`. The leading `ff` means that this is an
-opaque color (alpha = `0xff`).
-
-### HCT
-
-The combination of Cam16-JCH and L*a*b* was used to introduce HCT in MCU. This
-color space is crucial for creating color schemes, blending colors, and handling
-disliked colors.
-
-Note that while HCT is infinite, it can describe colors like H26 C231 T100.
-However, that color isn’t “real.” There is no such color as a red (H26) that is
-*extremely* colorful (C231) and the same brightness as white (T100). When it is
-converted to RGB to be displayed, HCT keeps the tone, and reduces chroma until
-the color is feasible.
-
-### Cam16
-
-CAM16 is a **color appearance model**, which accounts for **viewing
-conditions**. The same red color patch will look different at noon, and at
-night, and even in situations as simple as the background color being different.
-
-Its aim is to represent the human perception of colors accurately. The Cam16
-model uses the class `ViewingCondition` to define the environment, and employing
-various `ViewingCondition` objects with the same hex code can result in distinct
-"Cam16" objects. The library offers a standard default `ViewingCondition`.
-
-A `Cam16` object contains 9 components, and can be determined uniquely if any of
-the following are given:
-
-- A triple consisting of one of {`j`, `q`}, one of {`chroma`, `m`, `s`}, and
- `hue`
-- A triple of `jstar`, `astar`, and `bstar`
-
-Technically speaking, Cam16 is not a single color space but encompasses multiple
-color spaces. MCU uses the color spaces **Cam16-JCH** (using the components `j`,
-`chroma`, `hue`) and **Cam16-UCS** (using the components `jstar`, `astar`,
-`bstar`) for different purposes.
-
-### XYZ (CIEXYZ)
-
-XYZ is sometimes called a **connector space**, every color space can convert to
-and from it. It is used often in conversion, but it is inappropriate for design.
-It does not attempt to provide perceptually accurate attributes of colors, and
-the three channels are visually interdependent.
-
-This linear color space closely relates to how the cone cells response to light.
-
-### L\*a\*b\* (CIELAB)
-
-A color space intended to be perceptually uniform. Used internally for image
-quantization.
-
-L*a*b*, like RGB, is in a cube.
-
-- L* is the Z axis, representing lightness.
-- a* is the X axis, left to right, green to red.
-- b* is the Y axis, bottom to top, blue to yellow.
-
-### Linear RGB (`linrgb`)
-
-A linearization of the sRGB color space, with no restriction on bit depth.
-
-Used internally for the HCT Solver.
-
-## Conversions between color spaces
-
-
-
-###### Dart
-
-* sRGB ⇌ HCT
- - `Hct.fromInt(argb)`
- - `Hct.from(h, c, t).toInt()`
-* sRGB ⇌ XYZ
- - `ColorUtils.xyzFromArgb(argb)`
- - `ColorUtils.argbFromXyz(x, y, z)`
-* sRGB ⇌ Cam16
- - `Cam16.fromInt(argb)`
- - `cam16.toInt()`
- - Constructing a Cam16 from JCH or UCS:
- - `Cam16.fromJch(j, c, h)`
- - `Cam16.fromUcs(jstar, astar, bstar)`
-* XYZ ⇌ Cam16
- - `Cam16.fromXyzInViewingConditions(x, y, z, vc)`
- - `cam16.xyzInViewingConditions(vc)`
-* sRGB ⇌ L\*a\*b\*
- - `ColorUtils.labFromArgb(argb)`
- - `ColorUtils.argbFromLab(l, a, b)`
-* linRGB → sRGB
- - `ColorUtils.argbFromLinrgb(linrgb)`
-
-###### Java
-
-* sRGB ⇌ HCT
- - `Hct.fromInt(argb)`
- - `Hct.from(h, c, t).toInt()`
-* sRGB ⇌ XYZ
- - `ColorUtils.xyzFromArgb(argb)`
- - `ColorUtils.argbFromXyz(x, y, z)`
-* sRGB ⇌ Cam16
- - `Cam16.fromInt(argb)`
- - `cam16.toInt()`
- - Constructing a Cam16 from JCH or UCS:
- - `Cam16.fromJch(j, c, h)`
- - `Cam16.fromUcs(jstar, astar, bstar)`
-* XYZ ⇌ Cam16
- - `Cam16.fromXyzInViewingConditions(x, y, z, vc)`
- - `cam16.xyzInViewingConditions(vc, returnArray)`
-* sRGB ⇌ L\*a\*b\*
- - `ColorUtils.labFromArgb(argb)`
- - `ColorUtils.argbFromLab(l, a, b)`
-* linRGB → sRGB
- - `ColorUtils.argbFromLinrgb(linrgb)`
-
-###### TypeScript
-
-* sRGB ⇌ HCT
- - `Hct.fromInt(argb)`
- - `Hct.from(h, c, t).toInt()`
-* sRGB ⇌ XYZ
- - `colorUtils.xyzFromArgb(argb)`
- - `colorUtils.argbFromXyz(x, y, z)`
-* sRGB ⇌ Cam16
- - `Cam16.fromInt(argb)`
- - `cam16.toInt()`
- - Constructing a Cam16 from JCH or UCS:
- - `Cam16.fromJch(j, c, h)`
- - `Cam16.fromUcs(jstar, astar, bstar)`
-* XYZ ⇌ Cam16
- - `Cam16.fromXyzInViewingConditions(x, y, z, vc)`
- - `cam16.xyzInViewingConditions(vc)`
-* sRGB ⇌ L\*a\*b\*
- - `colorUtils.labFromArgb(argb)`
- - `colorUtils.argbFromLab(l, a, b)`
-* linRGB → sRGB
- - `colorUtils.argbFromLinrgb(linrgb)`
-
-###### C++
-
-* sRGB ⇌ HCT
- - `Hct::Hct(argb)`
- - `Hct::ToInt()`
-* sRGB ⇌ XYZ — *not provided yet*
-* sRGB ⇌ Cam16
- - `CamFromInt(argb)`
- - `IntFromCam(cam)`
- - (*Cam16 from JCH is not available yet*)
- - Constructing a Cam16 from UCS:
- - `CamFromUcsAndViewingConditions(jstar, astar, bstar, vc)`
-* XYZ ⇌ Cam16
- - `CamFromXyzAndViewingConditions(x, y, z, vc)`
- - (*Cam16 to XYZ is not available yet*)
-* sRGB ⇌ L\*a\*b\*
- - `LabFromInt(argb)`
- - `IntFromLab(lab)`
-* linRGB → sRGB
- - `ArgbFromLinrgb(linrgb)`
-
-###### Swift
-
-* sRGB ⇌ HCT
- - `Hct.fromInt(argb)`
- - `Hct.from(h, c, t).toInt()`
-* sRGB ⇌ XYZ
- - `ColorUtils.xyzFromArgb(argb)`
- - `ColorUtils.argbFromXyz(x, y, z)`
-* sRGB ⇌ Cam16
- - `Cam16.fromInt(argb)`
- - `cam16.toInt()`
- - Constructing a Cam16 from JCH or UCS:
- - `Cam16.fromJch(j, c, h)`
- - `Cam16.fromUcs(jstar, astar, bstar)`
-* XYZ ⇌ Cam16
- - `Cam16.fromXyzInViewingConditions(x, y, z, vc)`
- - `cam16.xyzInViewingConditions(vc)`
-* sRGB ⇌ L\*a\*b\*
- - `ColorUtils.labFromArgb(argb)`
- - `ColorUtils.argbFromLab(l, a, b)`
-* linRGB → sRGB
- - `ColorUtils.argbFromLinrgb(linrgb)`
-
-
-
-## References
-
-### Wikipedia
-
-- [Color space](https://en.wikipedia.org/wiki/Color_space)
-- [Color model](https://en.wikipedia.org/wiki/Color_model)
-- [sRGB](https://en.wikipedia.org/wiki/SRGB)
- - [sRGB: Gamma](https://en.wikipedia.org/wiki/SRGB#Transfer_function_\(%22gamma%22\))
-- [Gamma correction](https://en.wikipedia.org/wiki/Gamma_correction)
-- [CIE 1931 color space (CIEXYZ and others)](https://en.wikipedia.org/wiki/CIE_1931_color_space)
-- [CIELAB color space (L\*a\*b\*)](https://en.wikipedia.org/wiki/CIELAB_color_space)
-- [Color appearance model (CAM)](https://en.wikipedia.org/wiki/Color_appearance_model)
- - [Cam16](https://en.wikipedia.org/wiki/Color_appearance_model#CAM16)
diff --git a/concepts/color_terms.md b/concepts/color_terms.md
deleted file mode 100644
index 9d53ae85..00000000
--- a/concepts/color_terms.md
+++ /dev/null
@@ -1,89 +0,0 @@
-# Color terms
-
-### Dynamic Color
-
-Dynamic Color represents a Material color role, and its value is determined by
-constraints in Dynamic Scheme.
-
-### Material Color Roles
-
-[Material color roles](https://m3.material.io/styles/color/roles) are like the
-"numbers" on a paint-by-number canvas. They are the connective tissue between
-elements of the UI and what color goes where. Roughly speaking, MCU assigns each
-color role with a value from a specific tonal palette. For example, the
-`onSurface` color uses a color from the Neutral Palette with tone 30 in light
-scheme.
-
-### Dynamic Scheme
-
-The Dynamic Scheme is comprised of color attributes that are combined in a
-predetermined way to meet the needs of a user context or preference. It is
-essentially a mapping of color roles to color at specific tone in a tonal
-palette. For example, primary = *207H 80C 90T*, onPrimary = *207H 80C 40T*.
-
-### Scheme Variant
-
-Each variant is a set of design decisions on the assignment of color values from
-tonal palettes to color roles.
-
-### Tonal Palette
-
-A set of colors that share hue and chroma in HCT color space and vary in tones.
-From a perception perspective, we can say that they are "tones of the same
-color".
-
-MCU produces 6 tonal palettes: primary, secondary, tertiary, neutral, neutral
-variant, and error. Each comprises tones ranging from 0 to 100 that serves as
-the basis for mapping specific tones to specific roles.
-
-### Source Color
-
-The single color that’s extracted to define all five key colors is called a
-source color. While it may not be needed in code, it’s a useful distinction for
-understanding that a dynamic color scheme has its root in one initiating color,
-AKA hue, chroma, and tone.
-
-### Key Color
-
-Key colors are a concept useful to understanding dynamic color. The term
-describes any color that undergoes hue and chroma transformation of a source
-color. It is not an extracted color, it’s a derivation of the source color.
-
-Key color is a color that represents the hue and chroma of a tonal palette.
-Dynamic color uses 5 key colors to generate 5 tonal palettes as a foundation for
-dynamic scheme generation.
-
-### HCT
-
-HCT is an abbreviation of hue, chroma, tone. It’s the name of a new color space
-that enables dynamic color. HCT is based on
-[CAM16](https://onlinelibrary.wiley.com/doi/10.1002/col.22131) hue and chroma;
-the L* construct for luminance from L*a*b* (CIELAB, 1976) is represented as
-tone.
-
-### Hue
-
-Examples are red, orange, yellow, green, etc. A hue can range from 0 to 359
-degrees.
-
-### Chroma
-
-Informally, chroma describes degrees of colorfulness. It’s similar to saturation
-in the HSL color space, but note two distinctions: chroma in HCT is perceptually
-accurate; for every combination of hue and tone there’s a different maximum
-chroma.
-
-### Tone
-
-Informally, tone means degrees of lightness. T in HCT color space equals L* in
-L*a*b* color space.
-
-### Contrast
-
-The difference between colors. For accessibility, contrast refers strictly to
-the difference in tone. A difference of 40 in tone guarantees a WCAG contrast
-ratio ≥ 3.0; a difference of 50 in tone guarantees a contrast ratio ≥ 4.5.
-
-## For more information
-
-See https://m3.material.io/foundations/glossary for more Material terms.
diff --git a/concepts/contrast_for_accessibility.md b/concepts/contrast_for_accessibility.md
deleted file mode 100644
index ebacb60f..00000000
--- a/concepts/contrast_for_accessibility.md
+++ /dev/null
@@ -1,117 +0,0 @@
-# Contrast for Accessibility
-
-## Contrast standards
-
-Google Accessibility Rating (GAR) are a set of guidelines for ensuring digital
-products are accessible to people with disabilities. Color contrast is a
-critical component of GAR compliance.
-
-For web apps, this means adhering to WCAG’s contrast ratio recommendations.
-Sufficient contrast is vital in cases where we aim to make content easily
-readable for all users, including those with visual impairments. This can be
-achieved by using colors that provide enough contrast between the text and
-background.
-
-### Contrast ratio
-
-Color contrast ratio refers to the difference in tone or lightness, without
-considering the hue or chroma. A helpful way to think about a user interface
-with good contrast ratios is that it remains functional even in its gray-scale
-format.
-
-Contrast ratio is based on `Y`, a component in the CIEXYZ color space that
-measures brightness. `Y` is in a one-to-one relationship with `L*` from CIELab.
-Given two colors where the lighter color's `Y` is `yL` and the darker color's
-`Y` is `yD`, the contrast ratio is defined as:
-
-```
-contrast_ratio = (yL + 5.0) / (yD + 5.0)
-```
-
-Examples:
-
-- The contrast ratio between a color and itself is 1.0.
-- The contrast ratio between black and white is 21.0.
-- Contrast ratios can range from 1 to 21 (commonly written 1:1 to 21:1), think
- black text on a white background.
-
-When we say "not enough contrast", it means that the contrast ratio between the
-background and foreground colors is not sufficiently high for a threshold. For
-example, a difference of 40 in tone guarantees a WCAG contrast ratio ≥ 3.0; a
-difference of 50 in tone guarantees a contrast ratio ≥ 4.5. Generally, text is
-considered legible against a background when the two colors have a contrast
-ratio of at least 4.5.
-
-## How MCU schemes comply GAR/WCAG
-
-The color schemes for default, medium and high contrast levels are designed
-according to various contrast ratios specified at each level for text and
-non-text elements. These contrast ratios operate in two ways:
-
-- **Guaranteed minimum contrast ratios**: defined based on GAR/WCAG standards.
- Colors meet or exceed these ratios on the relevant UI elements.
-
-- **Discretionary contrast ratios**: defined based on desirable visual design.
- Colors approach these ratios on the relevant UI elements. Because of the
- physical limits of color, it may be impossible for those colors to reach or
- exceed these ratios, which is why they operate as targets rather than
- guaranteed minimums.
-
-#### Default contrast
-
-- Meets AA accessibility level
-
- - **Guaranteed minimum contrast ratios:**
-
- - 4.5:1 for all text and icons
- - 3:1 for required non-text elements (GAR/WCAG standards allow certain
- non-text elements to fall below 3:1 contrast based on other design
- criteria)
-
- - **Discretionary contrast ratios:**
-
- - 7:1 for higher emphasis text
-
-#### Medium contrast
-
-- Exceeds AA accessibility level
-
- - **Guaranteed minimum contrast ratios:**
-
- - 4.5:1 for all text and icons
- - 3:1 for all non-text elements, including those not required to meet
- 3:1
-
- - **Discretionary contrast ratios:**
-
- - 7:1 for text
- - 11:1 for higher emphasis text
-
-#### High contrast
-
-- Meets AAA accessibility level
-
- - **Guaranteed minimum contrast ratios:**
-
- - 7:1 for all text and icons
- - 4.5:1 for all non-text elements
-
- - **Discretionary contrast ratios:**
-
- - 11:1 for text
- - 21:1 for higher emphasis text
-
-## How MCU derives schemes for accessibility
-
-MCU achieves GAR/WCAG compliance through:
-
-- **Color Roles:** Assigning semantic roles to colors (e.g., primary,
- secondary, background) ensures accessibility. The color system is built on
- accessible color pairings; MCU measures the contrast ratio between adjacent
- colors or overlaid colors (foreground / background) and adjusts them
- accordingly to meet the required contrast ratio. These color pairs provide
- an accessible minimum of 3:1 contrast.
-
-- **Contrast libraries:** These libraries provide pre-defined color palettes
- and algorithms to adjust tone of the of colors in the pair to reach the
- target contrast ratio.
diff --git a/concepts/dynamic_color_scheme.md b/concepts/dynamic_color_scheme.md
deleted file mode 100644
index baa8d716..00000000
--- a/concepts/dynamic_color_scheme.md
+++ /dev/null
@@ -1,80 +0,0 @@
-# Dynamic Color Scheme
-
-## Color space in MCU
-
-Material uses a color spaces called HCT, which quantifies all colors using three
-dimensions, Hue, Chroma, and Tone. The color space enables the system to create
-and manipulate colors in flexible but predictable ways and allows designers to
-identify and relate colors.
-
-**Hue** quantifies the perception of a color as red, yellow, blue, and so on.
-Hue is quantified by a number ranging from 0 to 360 and is a circular spectrum.
-That is, values 0 and 360 are the same hue.
-
-**Chroma** describes how colorful or neutral, gray, a color appears. Chroma is
-quantified by a number ranging from 0, completely gray, to theoretically
-infinite, most vibrant, though chroma values in HCT top out at roughly 120.
-
-**Tone** describes how light or dark a color appears. Tone is sometimes also
-referred to as luminance. Tone is quantified by a number ranging from 0, pure
-black, no luminance, to 100, pure white, complete luminance. For visual
-accessibility, tone is crucial because it determines control contrast. Colors
-with a greater difference in tone create higher contrast while those with a
-smaller difference create lower contrast.
-
-## What is Dynamic Scheme?
-
-`DynamicScheme` is the most important interface for dynamic color clients. It is
-a scheme that clients can use to choose what color goes to which elements of the
-UI. A helpful analogy is to think of UI as a paint-by-number canvas, with color
-roles representing the "numbers" and `DynamicScheme` acting as a guideline to
-map from those numbers to actual colors. `DynamicScheme` abstracts away the
-exact color values, and the app developers only need to choose which color role
-to use at each element of the UI.
-
-More specifically, `DynamicScheme` comprises assignments of color values from
-tonal palettes generated from user or app developer's preference to color roles.
-The assignment focuses on meeting the requirements of contrast control for
-visual accessibility and/or color fidelity for visual expression and trueness of
-colors. The requirements comprise both hard constraints, such as accessibility
-and fidelity, and soft constraints, such as visual preferences.
-
-## How to generate Dynamic Scheme
-
-Material color schemes start from a source color, a single color from which all
-other scheme colors are derived. Source colors can be picked by a designer, or
-if the scheme is based on an image like a user's wallpaper, they can be
-extracted through a process called quantization. Quantization filters an image
-down to its most representative colors. One of those colors is selected as the
-source color.
-
-First, the color algorithm systematically manipulates the source color's hue and
-chroma to create four additional visually complementary key colors.
-
-Next, those five key colors - the source color plus the four additional colors -
-are each used to create a tonal palette. The tonal palette contains 13 tones
-from black, tone 0, to white, tone 100. Lower tones are darker in luminance, and
-higher tones are lighter in luminance. This full set of five tonal palettes is
-the basis of a Material color scheme. Individual tones are selected from each
-palette and assigned to color roles within a scheme.
-
-The variety of colors in each scheme provide for different needs like
-accessibility and expression. For example, color roles that may be used in
-pairs, like container and on container colors, are chosen to maintain accessible
-visual control contrast. Colors in the primary, secondary, and tertiary groups
-maintain those contrasts while providing a range of style for visual expression.
-Both light and dark schemes are created from this process.
-
-## Applying colors to apps using design tokens
-
-Colors are applied using design tokens, which store values for small, repeated
-design decisions such as the color that make up a design system's visual style.
-A Material token consists of a meaningful code like name and its associated
-value. This allows styles to be applied consistently across designs, code,
-tools, and platforms.
-
-## For more information
-
-See
-[How the system works](https://m3.material.io/styles/color/system/how-the-system-works)
-for more information on Material color system.
diff --git a/concepts/images/content_based_color.png b/concepts/images/content_based_color.png
deleted file mode 100644
index e3996437..00000000
Binary files a/concepts/images/content_based_color.png and /dev/null differ
diff --git a/concepts/images/fidelity_spec.png b/concepts/images/fidelity_spec.png
deleted file mode 100644
index dbabca84..00000000
Binary files a/concepts/images/fidelity_spec.png and /dev/null differ
diff --git a/concepts/images/hue_chroma_spec.png b/concepts/images/hue_chroma_spec.png
deleted file mode 100644
index 3792b709..00000000
Binary files a/concepts/images/hue_chroma_spec.png and /dev/null differ
diff --git a/concepts/images/orange.png b/concepts/images/orange.png
deleted file mode 100644
index d3a6fcfb..00000000
Binary files a/concepts/images/orange.png and /dev/null differ
diff --git a/concepts/images/tone_spec.png b/concepts/images/tone_spec.png
deleted file mode 100644
index fec5324f..00000000
Binary files a/concepts/images/tone_spec.png and /dev/null differ
diff --git a/concepts/images/wallpaper_based_color.png b/concepts/images/wallpaper_based_color.png
deleted file mode 100644
index b48f22dc..00000000
Binary files a/concepts/images/wallpaper_based_color.png and /dev/null differ
diff --git a/concepts/scheme_generation.md b/concepts/scheme_generation.md
deleted file mode 100644
index c4df8273..00000000
--- a/concepts/scheme_generation.md
+++ /dev/null
@@ -1,90 +0,0 @@
-# MCU Scheme Generation
-
-## Requirements for Dynamic Scheme
-
-As described in [Dynamic Color Scheme](dynamic_color_scheme.md), `DynamicScheme`
-generation aims to generate colors that satisfy constraints on visual
-accessibility and visual expression and trueness of colors.
-
-### Hard constraints
-
-1. The contrast ratio between the foreground and background should fall within
- a specified range.
-1. Certain color roles ought to fall within a specified range of tones.
-1. Tone delta between x and xContainer pairs, such as primary and
- primaryContainer, should be higher than a minimum.
-1. secondaryContainer prioritizes matching chroma over tone. This implies that
- it may adjust tone, in a specific direction, to achieve chroma as close as
- possible to the desired chroma.
-1. tertiaryContainer should not be disliked, otherwise it would be lightened.
-
-### Soft constraints
-
-1. Tone should be as close to a "reference standard" as possible.
-1. The distribution of tones should be even across colors.
-1. The contrast level should ideally be at a certain level, but it is not
- required.
-
-## How MCU derives Dynamic Scheme
-
-Above constraints are expressed as algebraic formulas and solved in the
-following steps:
-
-### 1. Starting tone specs
-
-MCU assigns all colors a "starting" tone value according to design spec. All
-colors are assigned one starting tone for the light theme and one for dark
-theme. For example, primary uses Tone 40 (more white) in Light theme and Tone 80
-in Dark theme
-
-
-
-In non-fidelity schemes, the tone level for each dynamic color remains fixed. In
-fidelity schemes, MCU can adjust the tones to achieve a preferred chroma as
-explained in Step 3.
-
-### 2. Hue & chroma spec
-
-MCU assigns all colors their hue and chroma values according to the scheme
-variant spec.
-
-
-
-For instance, the scheme variant here sets the primary palette to use the same
-hue with the source color (H270), while the tertiary palette shifts the hue by
-30 (H300).
-
-### 3. Fidelity tone adjustments
-
-After the above steps (1) and (2), each color in the scheme has the necessary
-HCT values to create a color. However, the resulting color may need revision
-because it is visually suboptimal or "impossible", i.e. the color of the given
-Hue cannot reach the assigned Chroma at the assigned Tone.
-
-
-
-To revise such colors, MCU can adjust their tones using one of two possible
-"fidelity" behaviors.
-
-- Source: Adjust the color's tone to match that of the source color.
-- Reach Chroma: Adjust the color's tone until the color's chroma reaches that
- specified by the Variant.
-
-### 4. Global tone constraints
-
-While adjusting colors' tones, MCU follows global constraints to ensure visual
-hierarchy and quality. Where fidelity tone adjustments and global tone
-constraints conflict, global tone constraints take priority.
-
-### 5. Contrast tone adjustments & requirements
-
-Finally, MCU adjusts tones to meet contrast requirements by assessing the
-contrast ratios between colors and their assigned backgrounds. In
-color/background pairings where the target contrast ratio is not met, MCU
-adjusts the tone of the foreground color to reach the target ratio, according to
-the contrast level that is set.
-
-Note that contrast ratios may not always reach the targets. For example, if a
-background color is a mid-tone T50, its highest contrast on-color (white) only
-reaches a contrast ratio of ~4.5:1. However, the targets will ensure that
-GAR/WCAAG minimum requirements are met.
diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt
new file mode 100644
index 00000000..c27133a2
--- /dev/null
+++ b/cpp/CMakeLists.txt
@@ -0,0 +1,33 @@
+cmake_minimum_required(VERSION 3.15)
+project(MyProject LANGUAGES CXX)
+
+# add_executable(material-colors src/main.cc)
+add_library(material-colors STATIC src/mylib/mylib.cc)
+
+target_link_libraries(material-colors PUBLIC material_color_utilities_lib)
+
+set_property(TARGET material-colors PROPERTY CXX_STANDARD 17)
+set_property(TARGET material-colors PROPERTY CXX_STANDARD_REQUIRED ON)
+set_target_properties(material-colors PROPERTIES
+ ARCHIVE_OUTPUT_DIRECTORY ../../libs
+)
+
+add_library(material_color_utilities_lib STATIC
+ src/material-color-utilities/cpp/cam/hct.cc
+ src/material-color-utilities/cpp/cam/hct_solver.cc
+ src/material-color-utilities/cpp/cam/cam.cc
+ src/material-color-utilities/cpp/cam/viewing_conditions.cc
+ src/material-color-utilities/cpp/utils/utils.cc
+)
+set_target_properties(material_color_utilities_lib PROPERTIES
+ ARCHIVE_OUTPUT_DIRECTORY ../../libs
+)
+
+target_include_directories(material-colors PRIVATE
+ src/material-color-utilities
+ src
+)
+
+target_include_directories(material_color_utilities_lib PRIVATE
+ src/material-color-utilities
+)
\ No newline at end of file
diff --git a/cpp/blend/blend.cc b/cpp/blend/blend.cc
deleted file mode 100644
index 4b8c34b5..00000000
--- a/cpp/blend/blend.cc
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright 2022 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "cpp/blend/blend.h"
-
-#include
-#include
-
-#include "cpp/cam/cam.h"
-#include "cpp/cam/hct.h"
-#include "cpp/cam/viewing_conditions.h"
-#include "cpp/utils/utils.h"
-
-namespace material_color_utilities {
-
-Argb BlendHarmonize(const Argb design_color, const Argb key_color) {
- Hct from_hct(design_color);
- Hct to_hct(key_color);
- double difference_degrees = DiffDegrees(from_hct.get_hue(), to_hct.get_hue());
- double rotation_degrees = std::min(difference_degrees * 0.5, 15.0);
- double output_hue = SanitizeDegreesDouble(
- from_hct.get_hue() +
- rotation_degrees *
- RotationDirection(from_hct.get_hue(), to_hct.get_hue()));
- from_hct.set_hue(output_hue);
- return from_hct.ToInt();
-}
-
-Argb BlendHctHue(const Argb from, const Argb to, const double amount) {
- int ucs = BlendCam16Ucs(from, to, amount);
- Hct ucs_hct(ucs);
- Hct from_hct(from);
- from_hct.set_hue(ucs_hct.get_hue());
- return from_hct.ToInt();
-}
-
-Argb BlendCam16Ucs(const Argb from, const Argb to, const double amount) {
- Cam from_cam = CamFromInt(from);
- Cam to_cam = CamFromInt(to);
-
- const double a_j = from_cam.jstar;
- const double a_a = from_cam.astar;
- const double a_b = from_cam.bstar;
-
- const double b_j = to_cam.jstar;
- const double b_a = to_cam.astar;
- const double b_b = to_cam.bstar;
-
- const double jstar = a_j + (b_j - a_j) * amount;
- const double astar = a_a + (b_a - a_a) * amount;
- const double bstar = a_b + (b_b - a_b) * amount;
-
- const Cam blended = CamFromUcsAndViewingConditions(jstar, astar, bstar,
- kDefaultViewingConditions);
- return IntFromCam(blended);
-}
-
-} // namespace material_color_utilities
diff --git a/cpp/blend/blend.h b/cpp/blend/blend.h
deleted file mode 100644
index ca730ae5..00000000
--- a/cpp/blend/blend.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright 2022 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef CPP_BLEND_BLEND_H_
-#define CPP_BLEND_BLEND_H_
-
-#include
-
-#include "cpp/utils/utils.h"
-
-namespace material_color_utilities {
-
-Argb BlendHarmonize(const Argb design_color, const Argb key_color);
-Argb BlendHctHue(const Argb from, const Argb to, const double amount);
-Argb BlendCam16Ucs(const Argb from, const Argb to, const double amount);
-
-} // namespace material_color_utilities
-#endif // CPP_BLEND_BLEND_H_
diff --git a/cpp/blend/blend_test.cc b/cpp/blend/blend_test.cc
deleted file mode 100644
index 20462d25..00000000
--- a/cpp/blend/blend_test.cc
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright 2022 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "cpp/blend/blend.h"
-
-#include "testing/base/public/gunit.h"
-#include "cpp/utils/utils.h"
-
-namespace material_color_utilities {
-
-namespace {
-TEST(BlendTest, RedToBlue) {
- int blended = BlendHctHue(0xffff0000, 0xff0000ff, 0.8);
- EXPECT_EQ(HexFromArgb(blended), "ff905eff");
-}
-} // namespace
-
-} // namespace material_color_utilities
diff --git a/cpp/contrast/contrast.cc b/cpp/contrast/contrast.cc
deleted file mode 100644
index c94d444e..00000000
--- a/cpp/contrast/contrast.cc
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright 2023 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "cpp/contrast/contrast.h"
-
-#include
-#include
-
-#include "cpp/utils/utils.h"
-
-namespace material_color_utilities {
-// Given a color and a contrast ratio to reach, the luminance of a color that
-// reaches that ratio with the color can be calculated. However, that luminance
-// may not contrast as desired, i.e. the contrast ratio of the input color
-// and the returned luminance may not reach the contrast ratio asked for.
-//
-// When the desired contrast ratio and the result contrast ratio differ by
-// more than this amount, an error value should be returned, or the method
-// should be documented as 'unsafe', meaning, it will return a valid luminance
-// but that luminance may not meet the requested contrast ratio.
-//
-// 0.04 selected because it ensures the resulting ratio rounds to the
-// same tenth.
-constexpr double CONTRAST_RATIO_EPSILON = 0.04;
-
-// Color spaces that measure luminance, such as Y in XYZ, L* in L*a*b*,
-// or T in HCT, are known as perceptual accurate color spaces.
-//
-// To be displayed, they must gamut map to a "display space", one that has
-// a defined limit on the number of colors. Display spaces include sRGB,
-// more commonly understood as RGB/HSL/HSV/HSB.
-//
-// Gamut mapping is undefined and not defined by the color space. Any
-// gamut mapping algorithm must choose how to sacrifice accuracy in hue,
-// saturation, and/or lightness.
-//
-// A principled solution is to maintain lightness, thus maintaining
-// contrast/a11y, maintain hue, thus maintaining aesthetic intent, and reduce
-// chroma until the color is in gamut.
-//
-// HCT chooses this solution, but, that doesn't mean it will _exactly_ matched
-// desired lightness, if only because RGB is quantized: RGB is expressed as
-// a set of integers: there may be an RGB color with, for example,
-// 47.892 lightness, but not 47.891.
-//
-// To allow for this inherent incompatibility between perceptually accurate
-// color spaces and display color spaces, methods that take a contrast ratio
-// and luminance, and return a luminance that reaches that contrast ratio for
-// the input luminance, purposefully darken/lighten their result such that
-// the desired contrast ratio will be reached even if inaccuracy is introduced.
-//
-// 0.4 is generous, ex. HCT requires much less delta. It was chosen because
-// it provides a rough guarantee that as long as a percetual color space
-// gamut maps lightness such that the resulting lightness rounds to the same
-// as the requested, the desired contrast ratio will be reached.
-constexpr double LUMINANCE_GAMUT_MAP_TOLERANCE = 0.4;
-
-double RatioOfYs(double y1, double y2) {
- double lighter = y1 > y2 ? y1 : y2;
- double darker = (lighter == y2) ? y1 : y2;
- return (lighter + 5.0) / (darker + 5.0);
-}
-
-double RatioOfTones(double tone_a, double tone_b) {
- tone_a = std::clamp(tone_a, 0.0, 100.0);
- tone_b = std::clamp(tone_b, 0.0, 100.0);
- return RatioOfYs(YFromLstar(tone_a), YFromLstar(tone_b));
-}
-
-double Lighter(double tone, double ratio) {
- if (tone < 0.0 || tone > 100.0) {
- return -1.0;
- }
-
- double dark_y = YFromLstar(tone);
- double light_y = ratio * (dark_y + 5.0) - 5.0;
- double real_contrast = RatioOfYs(light_y, dark_y);
- double delta = abs(real_contrast - ratio);
- if (real_contrast < ratio && delta > CONTRAST_RATIO_EPSILON) {
- return -1;
- }
-
- // ensure gamut mapping, which requires a 'range' on tone, will still result
- // the correct ratio by darkening slightly.
- double value = LstarFromY(light_y) + LUMINANCE_GAMUT_MAP_TOLERANCE;
- if (value < 0 || value > 100) {
- return -1;
- }
- return value;
-}
-
-double Darker(double tone, double ratio) {
- if (tone < 0.0 || tone > 100.0) {
- return -1.0;
- }
-
- double light_y = YFromLstar(tone);
- double dark_y = ((light_y + 5.0) / ratio) - 5.0;
- double real_contrast = RatioOfYs(light_y, dark_y);
-
- double delta = abs(real_contrast - ratio);
- if (real_contrast < ratio && delta > CONTRAST_RATIO_EPSILON) {
- return -1;
- }
-
- // ensure gamut mapping, which requires a 'range' on tone, will still result
- // the correct ratio by darkening slightly.
- double value = LstarFromY(dark_y) - LUMINANCE_GAMUT_MAP_TOLERANCE;
- if (value < 0 || value > 100) {
- return -1;
- }
- return value;
-}
-
-double LighterUnsafe(double tone, double ratio) {
- double lighter_safe = Lighter(tone, ratio);
- return (lighter_safe < 0.0) ? 100.0 : lighter_safe;
-}
-
-double DarkerUnsafe(double tone, double ratio) {
- double darker_safe = Darker(tone, ratio);
- return (darker_safe < 0.0) ? 0.0 : darker_safe;
-}
-
-} // namespace material_color_utilities
diff --git a/cpp/contrast/contrast.h b/cpp/contrast/contrast.h
deleted file mode 100644
index 6ff0bdec..00000000
--- a/cpp/contrast/contrast.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright 2023 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef CPP_CONTRAST_CONTRAST_H_
-#define CPP_CONTRAST_CONTRAST_H_
-
-/**
- * Utility methods for calculating contrast given two colors, or calculating a
- * color given one color and a contrast ratio.
- *
- * Contrast ratio is calculated using XYZ's Y. When linearized to match human
- * perception, Y becomes HCT's tone and L*a*b*'s' L*. Informally, this is the
- * lightness of a color.
- *
- * Methods refer to tone, T in the the HCT color space.
- * Tone is equivalent to L* in the L*a*b* color space, or L in the LCH color
- * space.
- */
-namespace material_color_utilities {
-/**
- * @return a contrast ratio, which ranges from 1 to 21.
- * @param tone_a Tone between 0 and 100. Values outside will be clamped.
- * @param tone_b Tone between 0 and 100. Values outside will be clamped.
- */
-double RatioOfTones(double tone_a, double tone_b);
-
-/**
- * @return a tone >= [tone] that ensures [ratio].
- * Return value is between 0 and 100.
- * Returns -1 if [ratio] cannot be achieved with [tone].
- *
- * @param tone Tone return value must contrast with.
- * Range is 0 to 100. Invalid values will result in -1 being returned.
- * @param ratio Contrast ratio of return value and [tone].
- * Range is 1 to 21, invalid values have undefined behavior.
- */
-double Lighter(double tone, double ratio);
-
-/**
- * @return a tone <= [tone] that ensures [ratio].
- * Return value is between 0 and 100.
- * Returns -1 if [ratio] cannot be achieved with [tone].
- *
- * @param tone Tone return value must contrast with.
- * Range is 0 to 100. Invalid values will result in -1 being returned.
- * @param ratio Contrast ratio of return value and [tone].
- * Range is 1 to 21, invalid values have undefined behavior.
- */
-double Darker(double tone, double ratio);
-
-/**
- * @return a tone >= [tone] that ensures [ratio].
- * Return value is between 0 and 100.
- * Returns 100 if [ratio] cannot be achieved with [tone].
- *
- * This method is unsafe because the returned value is guaranteed to be in
- * bounds for tone, i.e. between 0 and 100. However, that value may not reach
- * the [ratio] with [tone]. For example, there is no color lighter than T100.
- *
- * @param tone Tone return value must contrast with.
- * Range is 0 to 100. Invalid values will result in 100 being returned.
- * @param ratio Desired contrast ratio of return value and tone parameter.
- * Range is 1 to 21, invalid values have undefined behavior.
- */
-double LighterUnsafe(double tone, double ratio);
-
-/**
- * @return a tone <= [tone] that ensures [ratio].
- * Return value is between 0 and 100.
- * Returns 0 if [ratio] cannot be achieved with [tone].
- *
- * This method is unsafe because the returned value is guaranteed to be in
- * bounds for tone, i.e. between 0 and 100. However, that value may not reach
- * the [ratio] with [tone]. For example, there is no color darker than T0.
- *
- * @param tone Tone return value must contrast with.
- * Range is 0 to 100. Invalid values will result in 0 being returned.
- * @param ratio Desired contrast ratio of return value and tone parameter.
- * Range is 1 to 21, invalid values have undefined behavior.
- */
-double DarkerUnsafe(double tone, double ratio);
-} // namespace material_color_utilities
-
-#endif // CPP_CONTRAST_CONTRAST_H_
diff --git a/cpp/contrast/contrast_test.cc b/cpp/contrast/contrast_test.cc
deleted file mode 100644
index 38a85c0c..00000000
--- a/cpp/contrast/contrast_test.cc
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright 2023 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "cpp/contrast/contrast.h"
-
-#include "testing/base/public/gunit.h"
-
-namespace material_color_utilities {
-
-namespace {
-TEST(ContrastTest, RatioOfTonesOutOfBoundsInput) {
- EXPECT_NEAR(RatioOfTones(-10.0, 110.0), 21.0, 0.001);
-}
-
-TEST(ContrastTest, LighterImpossibleRatioErrors) {
- EXPECT_NEAR(Lighter(90.0, 10.0), -1.0, 0.001);
-}
-
-TEST(ContrastTest, LighterOutOfBoundsInputAboveErrors) {
- EXPECT_NEAR(Lighter(110.0, 2.0), -1.0, 0.001);
-}
-
-TEST(ContrastTest, LighterOutOfBoundsInputBelowErrors) {
- EXPECT_NEAR(Lighter(-10.0, 2.0), -1.0, 0.001);
-}
-
-TEST(ContrastTest, LighterUnsafeReturnsMaxTone) {
- EXPECT_NEAR(LighterUnsafe(100.0, 2.0), 100, 0.001);
-}
-
-TEST(ContrastTest, DarkerImpossibleRatioErrors) {
- EXPECT_NEAR(Darker(10.0, 20.0), -1.0, 0.001);
-}
-
-TEST(ContrastTest, DarkerOutOfBoundsInputAboveErrors) {
- EXPECT_NEAR(Darker(110.0, 2.0), -1.0, 0.001);
-}
-
-TEST(ContrastTest, DarkerOutOfBoundsInputBelowErrors) {
- EXPECT_NEAR(Darker(-10.0, 2.0), -1.0, 0.001);
-}
-
-TEST(ContrastTest, DarkerUnsafeReturnsMinTone) {
- EXPECT_NEAR(DarkerUnsafe(0.0, 2.0), 0.0, 0.001);
-}
-} // namespace
-
-} // namespace material_color_utilities
diff --git a/cpp/dislike/dislike.cc b/cpp/dislike/dislike.cc
deleted file mode 100644
index a07f3607..00000000
--- a/cpp/dislike/dislike.cc
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2023 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "cpp/dislike/dislike.h"
-
-#include
-
-#include "cpp/cam/hct.h"
-
-namespace material_color_utilities {
-
-bool IsDisliked(Hct hct) {
- double roundedHue = std::round(hct.get_hue());
-
- bool hue_passes = roundedHue >= 90.0 && roundedHue <= 111.0;
- bool chroma_passes = std::round(hct.get_chroma()) > 16.0;
- bool tone_passes = std::round(hct.get_tone()) < 65.0;
-
- return hue_passes && chroma_passes && tone_passes;
-}
-
-Hct FixIfDisliked(Hct hct) {
- if (IsDisliked(hct)) {
- return Hct(hct.get_hue(), hct.get_chroma(), 70.0);
- }
-
- return hct;
-}
-} // namespace material_color_utilities
diff --git a/cpp/dislike/dislike.h b/cpp/dislike/dislike.h
deleted file mode 100644
index 3d09fab6..00000000
--- a/cpp/dislike/dislike.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright 2023 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef CPP_DISLIKE_DISLIKE_H_
-#define CPP_DISLIKE_DISLIKE_H_
-
-#include "cpp/cam/hct.h"
-
-namespace material_color_utilities {
-
-/**
- * Checks and/or fixes universally disliked colors.
- *
- * Color science studies of color preference indicate universal distaste for
- * dark yellow-greens, and also show this is correlated to distate for
- * biological waste and rotting food.
- *
- * See Palmer and Schloss, 2010 or Schloss and Palmer's Chapter 21 in Handbook
- * of Color Psychology (2015).
- */
-
-/**
- * @return whether the color is disliked.
- *
- * Disliked is defined as a dark yellow-green that is not neutral.
- * @param hct The color to be tested.
- */
-bool IsDisliked(Hct hct);
-
-/**
- * If a color is disliked, lightens it to make it likable.
- *
- * The original color is not modified.
- *
- * @param hct The color to be tested (and fixed, if needed).
- * @return The original color if it is not disliked; otherwise, the fixed
- * color.
- */
-Hct FixIfDisliked(Hct hct);
-} // namespace material_color_utilities
-
-#endif // CPP_DISLIKE_DISLIKE_H_
diff --git a/cpp/dislike/dislike_test.cc b/cpp/dislike/dislike_test.cc
deleted file mode 100644
index 0d2b2079..00000000
--- a/cpp/dislike/dislike_test.cc
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright 2023 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "cpp/dislike/dislike.h"
-
-#include "testing/base/public/gunit.h"
-#include "cpp/cam/hct.h"
-
-namespace material_color_utilities {
-
-namespace {
-
-using testing::TestWithParam;
-using testing::Values;
-using SkinToneTest = TestWithParam;
-
-TEST_P(SkinToneTest, MonkSkinToneScaleColorsLiked) {
- int argb = GetParam();
-
- EXPECT_FALSE(IsDisliked(Hct(argb)));
-}
-
-INSTANTIATE_TEST_SUITE_P(DislikeTest, SkinToneTest,
- Values(0xfff6ede4, 0xfff3e7db, 0xfff7ead0, 0xffeadaba,
- 0xffd7bd96, 0xffa07e56, 0xff825c43, 0xff604134,
- 0xff3a312a, 0xff292420));
-
-using BileTest = TestWithParam;
-
-TEST_P(BileTest, BileColorsDisliked) {
- int argb = GetParam();
-
- EXPECT_TRUE(IsDisliked(Hct(argb)));
-}
-
-INSTANTIATE_TEST_SUITE_P(DislikeTest, BileTest,
- Values(0xff95884B, 0xff716B40, 0xffB08E00, 0xff4C4308,
- 0xff464521));
-
-using BileFixingTest = TestWithParam;
-
-TEST_P(BileFixingTest, BileColorsFixed) {
- int argb = GetParam();
-
- Hct bile_color = Hct(argb);
- EXPECT_TRUE(IsDisliked(bile_color));
- Hct fixed_bile_color = FixIfDisliked(bile_color);
- EXPECT_FALSE(IsDisliked(fixed_bile_color));
-}
-
-INSTANTIATE_TEST_SUITE_P(DislikeTest, BileFixingTest,
- Values(0xff95884B, 0xff716B40, 0xffB08E00, 0xff4C4308,
- 0xff464521));
-
-
-TEST(DislikeTest, Tone67Liked) {
- Hct color = Hct(100.0, 50.0, 67.0);
- EXPECT_FALSE(IsDisliked(color));
- EXPECT_EQ(FixIfDisliked(color).ToInt(), color.ToInt());
-}
-
-} // namespace
-
-} // namespace material_color_utilities
diff --git a/cpp/dynamiccolor/contrast_curve.h b/cpp/dynamiccolor/contrast_curve.h
deleted file mode 100644
index 864e8cff..00000000
--- a/cpp/dynamiccolor/contrast_curve.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright 2023 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef CPP_DYNAMICCOLOR_CONTRAST_CURVE_H_
-#define CPP_DYNAMICCOLOR_CONTRAST_CURVE_H_
-
-#include "cpp/utils/utils.h"
-
-namespace material_color_utilities {
-
-/**
- * A class containing a value that changes with the contrast level.
- *
- * Usually represents the contrast requirements for a dynamic color on its
- * background. The four values correspond to values for contrast levels -1.0,
- * 0.0, 0.5, and 1.0, respectively.
- */
-struct ContrastCurve {
- double low;
- double normal;
- double medium;
- double high;
-
- /**
- * Creates a `ContrastCurve` object.
- *
- * @param low Value for contrast level -1.0
- * @param normal Value for contrast level 0.0
- * @param medium Value for contrast level 0.5
- * @param high Value for contrast level 1.0
- */
- ContrastCurve(double low, double normal, double medium, double high)
- : low(low), normal(normal), medium(medium), high(high) {}
-
- /**
- * Returns the value at a given contrast level.
- *
- * @param contrastLevel The contrast level. 0.0 is the default (normal); -1.0
- * is the lowest; 1.0 is the highest.
- * @return The value. For contrast ratios, a number between 1.0 and 21.0.
- */
- double get(double contrastLevel) {
- if (contrastLevel <= -1.0) {
- return low;
- } else if (contrastLevel < 0.0) {
- return Lerp(low, normal, (contrastLevel - (-1)) / 1);
- } else if (contrastLevel < 0.5) {
- return Lerp(normal, medium, (contrastLevel - 0) / 0.5);
- } else if (contrastLevel < 1.0) {
- return Lerp(medium, high, (contrastLevel - 0.5) / 0.5);
- } else {
- return high;
- }
- }
-};
-
-} // namespace material_color_utilities
-
-#endif // CPP_DYNAMICCOLOR_CONTRAST_CURVE_H_
diff --git a/cpp/dynamiccolor/dynamic_color.cc b/cpp/dynamiccolor/dynamic_color.cc
deleted file mode 100644
index 3f4259d9..00000000
--- a/cpp/dynamiccolor/dynamic_color.cc
+++ /dev/null
@@ -1,306 +0,0 @@
-/*
- * Copyright 2023 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "cpp/dynamiccolor/dynamic_color.h"
-
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include "cpp/cam/hct.h"
-#include "cpp/contrast/contrast.h"
-#include "cpp/dynamiccolor/dynamic_scheme.h"
-#include "cpp/dynamiccolor/tone_delta_pair.h"
-#include "cpp/palettes/tones.h"
-
-namespace material_color_utilities {
-
-using std::function;
-using std::nullopt;
-using std::optional;
-
-using DoubleFunction = function;
-
-template
-optional SafeCall(optional(const T&)>> f, const T& x) {
- if (f == nullopt) {
- return nullopt;
- } else {
- return f.value()(x);
- }
-}
-
-template
-optional SafeCallCleanResult(optional> f, T x) {
- if (f == nullopt) {
- return nullopt;
- } else {
- return f.value()(x);
- }
-}
-
-double ForegroundTone(double bg_tone, double ratio) {
- double lighter_tone = LighterUnsafe(/*tone*/ bg_tone, /*ratio*/ ratio);
- double darker_tone = DarkerUnsafe(/*tone*/ bg_tone, /*ratio*/ ratio);
- double lighter_ratio = RatioOfTones(lighter_tone, bg_tone);
- double darker_ratio = RatioOfTones(darker_tone, bg_tone);
- double prefer_lighter = TonePrefersLightForeground(bg_tone);
-
- if (prefer_lighter) {
- double negligible_difference =
- (abs(lighter_ratio - darker_ratio) < 0.1 && lighter_ratio < ratio &&
- darker_ratio < ratio);
- return lighter_ratio >= ratio || lighter_ratio >= darker_ratio ||
- negligible_difference
- ? lighter_tone
- : darker_tone;
- } else {
- return darker_ratio >= ratio || darker_ratio >= lighter_ratio
- ? darker_tone
- : lighter_tone;
- }
-}
-
-double EnableLightForeground(double tone) {
- if (TonePrefersLightForeground(tone) && !ToneAllowsLightForeground(tone)) {
- return 49.0;
- }
- return tone;
-}
-
-bool TonePrefersLightForeground(double tone) { return round(tone) < 60; }
-
-bool ToneAllowsLightForeground(double tone) { return round(tone) <= 49; }
-
-/**
- * Default constructor.
- */
-DynamicColor::DynamicColor(
- std::string name, std::function palette,
- std::function tone, bool is_background,
-
- std::optional> background,
- std::optional>
- second_background,
- std::optional contrast_curve,
- std::optional>
- tone_delta_pair)
- : name_(name),
- palette_(palette),
- tone_(tone),
- is_background_(is_background),
- background_(background),
- second_background_(second_background),
- contrast_curve_(contrast_curve),
- tone_delta_pair_(tone_delta_pair) {}
-
-DynamicColor DynamicColor::FromPalette(
- std::string name, std::function palette,
- std::function tone) {
- return DynamicColor(name, palette, tone,
- /*is_background=*/false,
- /*background=*/nullopt,
- /*second_background=*/nullopt,
- /*contrast_curve=*/nullopt,
- /*tone_delta_pair=*/nullopt);
-}
-
-Argb DynamicColor::GetArgb(const DynamicScheme& scheme) {
- return palette_(scheme).get(GetTone(scheme));
-}
-
-Hct DynamicColor::GetHct(const DynamicScheme& scheme) {
- return Hct(GetArgb(scheme));
-}
-
-double DynamicColor::GetTone(const DynamicScheme& scheme) {
- bool decreasingContrast = scheme.contrast_level < 0;
-
- // Case 1: dual foreground, pair of colors with delta constraint.
- if (tone_delta_pair_ != std::nullopt) {
- ToneDeltaPair tone_delta_pair = tone_delta_pair_.value()(scheme);
- DynamicColor role_a = tone_delta_pair.role_a_;
- DynamicColor role_b = tone_delta_pair.role_b_;
- double delta = tone_delta_pair.delta_;
- TonePolarity polarity = tone_delta_pair.polarity_;
- bool stay_together = tone_delta_pair.stay_together_;
-
- DynamicColor bg = background_.value()(scheme);
- double bg_tone = bg.GetTone(scheme);
-
- bool a_is_nearer =
- (polarity == TonePolarity::kNearer ||
- (polarity == TonePolarity::kLighter && !scheme.is_dark) ||
- (polarity == TonePolarity::kDarker && scheme.is_dark));
- DynamicColor nearer = a_is_nearer ? role_a : role_b;
- DynamicColor farther = a_is_nearer ? role_b : role_a;
- bool am_nearer = this->name_ == nearer.name_;
- double expansion_dir = scheme.is_dark ? 1 : -1;
-
- // 1st round: solve to min, each
- double n_contrast =
- nearer.contrast_curve_.value().get(scheme.contrast_level);
- double f_contrast =
- farther.contrast_curve_.value().get(scheme.contrast_level);
-
- // If a color is good enough, it is not adjusted.
- // Initial and adjusted tones for `nearer`
- double n_initial_tone = nearer.tone_(scheme);
- double n_tone = RatioOfTones(bg_tone, n_initial_tone) >= n_contrast
- ? n_initial_tone
- : ForegroundTone(bg_tone, n_contrast);
- // Initial and adjusted tones for `farther`
- double f_initial_tone = farther.tone_(scheme);
- double f_tone = RatioOfTones(bg_tone, f_initial_tone) >= f_contrast
- ? f_initial_tone
- : ForegroundTone(bg_tone, f_contrast);
-
- if (decreasingContrast) {
- // If decreasing contrast, adjust color to the "bare minimum"
- // that satisfies contrast.
- n_tone = ForegroundTone(bg_tone, n_contrast);
- f_tone = ForegroundTone(bg_tone, f_contrast);
- }
-
- if ((f_tone - n_tone) * expansion_dir >= delta) {
- // Good! Tones satisfy the constraint; no change needed.
- } else {
- // 2nd round: expand farther to match delta.
- f_tone = std::clamp(n_tone + delta * expansion_dir, 0.0, 100.0);
- if ((f_tone - n_tone) * expansion_dir >= delta) {
- // Good! Tones now satisfy the constraint; no change needed.
- } else {
- // 3rd round: contract nearer to match delta.
- n_tone = std::clamp(f_tone - delta * expansion_dir, 0.0, 100.0);
- }
- }
-
- // Avoids the 50-59 awkward zone.
- if (50 <= n_tone && n_tone < 60) {
- // If `nearer` is in the awkward zone, move it away, together with
- // `farther`.
- if (expansion_dir > 0) {
- n_tone = 60;
- f_tone = std::max(f_tone, n_tone + delta * expansion_dir);
- } else {
- n_tone = 49;
- f_tone = std::min(f_tone, n_tone + delta * expansion_dir);
- }
- } else if (50 <= f_tone && f_tone < 60) {
- if (stay_together) {
- // Fixes both, to avoid two colors on opposite sides of the "awkward
- // zone".
- if (expansion_dir > 0) {
- n_tone = 60;
- f_tone = std::max(f_tone, n_tone + delta * expansion_dir);
- } else {
- n_tone = 49;
- f_tone = std::min(f_tone, n_tone + delta * expansion_dir);
- }
- } else {
- // Not required to stay together; fixes just one.
- if (expansion_dir > 0) {
- f_tone = 60;
- } else {
- f_tone = 49;
- }
- }
- }
-
- // Returns `n_tone` if this color is `nearer`, otherwise `f_tone`.
- return am_nearer ? n_tone : f_tone;
- } else {
- // Case 2: No contrast pair; just solve for itself.
- double answer = tone_(scheme);
-
- if (background_ == std::nullopt) {
- return answer; // No adjustment for colors with no background.
- }
-
- double bg_tone = background_.value()(scheme).GetTone(scheme);
-
- double desired_ratio = contrast_curve_.value().get(scheme.contrast_level);
-
- if (RatioOfTones(bg_tone, answer) >= desired_ratio) {
- // Don't "improve" what's good enough.
- } else {
- // Rough improvement.
- answer = ForegroundTone(bg_tone, desired_ratio);
- }
-
- if (decreasingContrast) {
- answer = ForegroundTone(bg_tone, desired_ratio);
- }
-
- if (is_background_ && 50 <= answer && answer < 60) {
- // Must adjust
- if (RatioOfTones(49, bg_tone) >= desired_ratio) {
- answer = 49;
- } else {
- answer = 60;
- }
- }
-
- if (second_background_ != std::nullopt) {
- // Case 3: Adjust for dual backgrounds.
-
- double bg_tone_1 = background_.value()(scheme).GetTone(scheme);
- double bg_tone_2 = second_background_.value()(scheme).GetTone(scheme);
-
- double upper = std::max(bg_tone_1, bg_tone_2);
- double lower = std::min(bg_tone_1, bg_tone_2);
-
- if (RatioOfTones(upper, answer) >= desired_ratio &&
- RatioOfTones(lower, answer) >= desired_ratio) {
- return answer;
- }
-
- // The darkest light tone that satisfies the desired ratio,
- // or -1 if such ratio cannot be reached.
- double lightOption = Lighter(upper, desired_ratio);
-
- // The lightest dark tone that satisfies the desired ratio,
- // or -1 if such ratio cannot be reached.
- double darkOption = Darker(lower, desired_ratio);
-
- // Tones suitable for the foreground.
- std::vector availables;
- if (lightOption != -1) {
- availables.push_back(lightOption);
- }
- if (darkOption != -1) {
- availables.push_back(darkOption);
- }
-
- bool prefersLight = TonePrefersLightForeground(bg_tone_1) ||
- TonePrefersLightForeground(bg_tone_2);
- if (prefersLight) {
- return (lightOption < 0) ? 100 : lightOption;
- }
- if (availables.size() == 1) {
- return availables[0];
- }
- return (darkOption < 0) ? 0 : darkOption;
- }
-
- return answer;
- }
-}
-
-} // namespace material_color_utilities
diff --git a/cpp/dynamiccolor/dynamic_color.h b/cpp/dynamiccolor/dynamic_color.h
deleted file mode 100644
index 92ad227b..00000000
--- a/cpp/dynamiccolor/dynamic_color.h
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright 2023 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef CPP_DYNAMICCOLOR_DYNAMIC_COLOR_H_
-#define CPP_DYNAMICCOLOR_DYNAMIC_COLOR_H_
-
-#include
-#include
-#include
-
-#include "cpp/cam/hct.h"
-#include "cpp/dynamiccolor/contrast_curve.h"
-#include "cpp/dynamiccolor/dynamic_scheme.h"
-#include "cpp/utils/utils.h"
-
-namespace material_color_utilities {
-
-struct ToneDeltaPair;
-
-/**
- * Given a background tone, find a foreground tone, while ensuring they reach
- * a contrast ratio that is as close to [ratio] as possible.
- *
- * [bgTone] Tone in HCT. Range is 0 to 100, undefined behavior when it falls
- * outside that range.
- * [ratio] The contrast ratio desired between [bgTone] and the return value.
- */
-double ForegroundTone(double bg_tone, double ratio);
-
-/**
- * Adjust a tone such that white has 4.5 contrast, if the tone is
- * reasonably close to supporting it.
- */
-double EnableLightForeground(double tone);
-
-/**
- * Returns whether [tone] prefers a light foreground.
- *
- * People prefer white foregrounds on ~T60-70. Observed over time, and also
- * by Andrew Somers during research for APCA.
- *
- * T60 used as to create the smallest discontinuity possible when skipping
- * down to T49 in order to ensure light foregrounds.
- *
- * Since `tertiaryContainer` in dark monochrome scheme requires a tone of
- * 60, it should not be adjusted. Therefore, 60 is excluded here.
- */
-bool TonePrefersLightForeground(double tone);
-
-/**
- * Returns whether [tone] can reach a contrast ratio of 4.5 with a lighter
- * color.
- */
-bool ToneAllowsLightForeground(double tone);
-
-/**
- * @param name_ The name of the dynamic color.
- * @param palette_ Function that provides a TonalPalette given
- * DynamicScheme. A TonalPalette is defined by a hue and chroma, so this
- * replaces the need to specify hue/chroma. By providing a tonal palette, when
- * contrast adjustments are made, intended chroma can be preserved.
- * @param tone_ Function that provides a tone given DynamicScheme.
- * @param is_background_ Whether this dynamic color is a background, with
- * some other color as the foreground.
- * @param background_ The background of the dynamic color (as a function of a
- * `DynamicScheme`), if it exists.
- * @param second_background_ A second background of the dynamic color (as a
- * function of a `DynamicScheme`), if it
- * exists.
- * @param contrast_curve_ A `ContrastCurve` object specifying how its contrast
- * against its background should behave in various contrast levels options.
- * @param tone_delta_pair_ A `ToneDeltaPair` object specifying a tone delta
- * constraint between two colors. One of them must be the color being
- * constructed.
- */
-struct DynamicColor {
- std::string name_;
- std::function palette_;
- std::function tone_;
- bool is_background_;
-
- std::optional> background_;
- std::optional>
- second_background_;
- std::optional contrast_curve_;
- std::optional>
- tone_delta_pair_;
-
- /** A convenience constructor, only requiring name, palette, and tone. */
- static DynamicColor FromPalette(
- std::string name,
- std::function palette,
- std::function tone);
-
- Argb GetArgb(const DynamicScheme& scheme);
-
- Hct GetHct(const DynamicScheme& scheme);
-
- double GetTone(const DynamicScheme& scheme);
-
- /** The default constructor. */
- DynamicColor(std::string name,
- std::function palette,
- std::function tone,
- bool is_background,
-
- std::optional>
- background,
- std::optional>
- second_background,
- std::optional contrast_curve,
- std::optional>
- tone_delta_pair);
-};
-
-} // namespace material_color_utilities
-
-#endif // CPP_DYNAMICCOLOR_DYNAMIC_COLOR_H_
diff --git a/cpp/dynamiccolor/dynamic_scheme.cc b/cpp/dynamiccolor/dynamic_scheme.cc
deleted file mode 100644
index 170e99c5..00000000
--- a/cpp/dynamiccolor/dynamic_scheme.cc
+++ /dev/null
@@ -1,286 +0,0 @@
-/*
- * Copyright 2023 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "cpp/dynamiccolor/dynamic_scheme.h"
-
-#include
-#include
-
-#include "cpp/cam/hct.h"
-#include "cpp/dynamiccolor/material_dynamic_colors.h"
-#include "cpp/dynamiccolor/variant.h"
-#include "cpp/palettes/tones.h"
-#include "cpp/utils/utils.h"
-
-namespace material_color_utilities {
-
-DynamicScheme::DynamicScheme(Hct source_color_hct, Variant variant,
- double contrast_level, bool is_dark,
- TonalPalette primary_palette,
- TonalPalette secondary_palette,
- TonalPalette tertiary_palette,
- TonalPalette neutral_palette,
- TonalPalette neutral_variant_palette,
- std::optional error_palette)
- : source_color_hct(source_color_hct),
- variant(variant),
- is_dark(is_dark),
- contrast_level(contrast_level),
- primary_palette(primary_palette),
- secondary_palette(secondary_palette),
- tertiary_palette(tertiary_palette),
- neutral_palette(neutral_palette),
- neutral_variant_palette(neutral_variant_palette),
- error_palette(error_palette.value_or(TonalPalette(25.0, 84.0))) {}
-
-double DynamicScheme::GetRotatedHue(Hct source_color, std::vector hues,
- std::vector rotations) {
- double source_hue = source_color.get_hue();
-
- if (rotations.size() == 1) {
- return SanitizeDegreesDouble(source_color.get_hue() + rotations[0]);
- }
- int size = hues.size();
- for (int i = 0; i <= (size - 2); ++i) {
- double this_hue = hues[i];
- double next_hue = hues[i + 1];
- if (this_hue < source_hue && source_hue < next_hue) {
- return SanitizeDegreesDouble(source_hue + rotations[i]);
- }
- }
-
- return source_hue;
-}
-
-Argb DynamicScheme::SourceColorArgb() const { return source_color_hct.ToInt(); }
-
-Argb DynamicScheme::GetPrimaryPaletteKeyColor() const {
- return MaterialDynamicColors::PrimaryPaletteKeyColor().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetSecondaryPaletteKeyColor() const {
- return MaterialDynamicColors::SecondaryPaletteKeyColor().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetTertiaryPaletteKeyColor() const {
- return MaterialDynamicColors::TertiaryPaletteKeyColor().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetNeutralPaletteKeyColor() const {
- return MaterialDynamicColors::NeutralPaletteKeyColor().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetNeutralVariantPaletteKeyColor() const {
- return MaterialDynamicColors::NeutralVariantPaletteKeyColor().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetBackground() const {
- return MaterialDynamicColors::Background().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetOnBackground() const {
- return MaterialDynamicColors::OnBackground().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetSurface() const {
- return MaterialDynamicColors::Surface().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetSurfaceDim() const {
- return MaterialDynamicColors::SurfaceDim().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetSurfaceBright() const {
- return MaterialDynamicColors::SurfaceBright().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetSurfaceContainerLowest() const {
- return MaterialDynamicColors::SurfaceContainerLowest().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetSurfaceContainerLow() const {
- return MaterialDynamicColors::SurfaceContainerLow().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetSurfaceContainer() const {
- return MaterialDynamicColors::SurfaceContainer().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetSurfaceContainerHigh() const {
- return MaterialDynamicColors::SurfaceContainerHigh().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetSurfaceContainerHighest() const {
- return MaterialDynamicColors::SurfaceContainerHighest().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetOnSurface() const {
- return MaterialDynamicColors::OnSurface().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetSurfaceVariant() const {
- return MaterialDynamicColors::SurfaceVariant().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetOnSurfaceVariant() const {
- return MaterialDynamicColors::OnSurfaceVariant().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetInverseSurface() const {
- return MaterialDynamicColors::InverseSurface().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetInverseOnSurface() const {
- return MaterialDynamicColors::InverseOnSurface().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetOutline() const {
- return MaterialDynamicColors::Outline().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetOutlineVariant() const {
- return MaterialDynamicColors::OutlineVariant().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetShadow() const {
- return MaterialDynamicColors::Shadow().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetScrim() const {
- return MaterialDynamicColors::Scrim().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetSurfaceTint() const {
- return MaterialDynamicColors::SurfaceTint().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetPrimary() const {
- return MaterialDynamicColors::Primary().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetOnPrimary() const {
- return MaterialDynamicColors::OnPrimary().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetPrimaryContainer() const {
- return MaterialDynamicColors::PrimaryContainer().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetOnPrimaryContainer() const {
- return MaterialDynamicColors::OnPrimaryContainer().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetInversePrimary() const {
- return MaterialDynamicColors::InversePrimary().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetSecondary() const {
- return MaterialDynamicColors::Secondary().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetOnSecondary() const {
- return MaterialDynamicColors::OnSecondary().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetSecondaryContainer() const {
- return MaterialDynamicColors::SecondaryContainer().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetOnSecondaryContainer() const {
- return MaterialDynamicColors::OnSecondaryContainer().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetTertiary() const {
- return MaterialDynamicColors::Tertiary().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetOnTertiary() const {
- return MaterialDynamicColors::OnTertiary().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetTertiaryContainer() const {
- return MaterialDynamicColors::TertiaryContainer().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetOnTertiaryContainer() const {
- return MaterialDynamicColors::OnTertiaryContainer().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetError() const {
- return MaterialDynamicColors::Error().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetOnError() const {
- return MaterialDynamicColors::OnError().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetErrorContainer() const {
- return MaterialDynamicColors::ErrorContainer().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetOnErrorContainer() const {
- return MaterialDynamicColors::OnErrorContainer().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetPrimaryFixed() const {
- return MaterialDynamicColors::PrimaryFixed().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetPrimaryFixedDim() const {
- return MaterialDynamicColors::PrimaryFixedDim().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetOnPrimaryFixed() const {
- return MaterialDynamicColors::OnPrimaryFixed().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetOnPrimaryFixedVariant() const {
- return MaterialDynamicColors::OnPrimaryFixedVariant().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetSecondaryFixed() const {
- return MaterialDynamicColors::SecondaryFixed().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetSecondaryFixedDim() const {
- return MaterialDynamicColors::SecondaryFixedDim().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetOnSecondaryFixed() const {
- return MaterialDynamicColors::OnSecondaryFixed().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetOnSecondaryFixedVariant() const {
- return MaterialDynamicColors::OnSecondaryFixedVariant().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetTertiaryFixed() const {
- return MaterialDynamicColors::TertiaryFixed().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetTertiaryFixedDim() const {
- return MaterialDynamicColors::TertiaryFixedDim().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetOnTertiaryFixed() const {
- return MaterialDynamicColors::OnTertiaryFixed().GetArgb(*this);
-}
-
-Argb DynamicScheme::GetOnTertiaryFixedVariant() const {
- return MaterialDynamicColors::OnTertiaryFixedVariant().GetArgb(*this);
-}
-
-} // namespace material_color_utilities
diff --git a/cpp/dynamiccolor/dynamic_scheme.h b/cpp/dynamiccolor/dynamic_scheme.h
deleted file mode 100644
index 473287fd..00000000
--- a/cpp/dynamiccolor/dynamic_scheme.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright 2023 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef CPP_DYNAMICCOLOR_DYNAMIC_SCHEME_H_
-#define CPP_DYNAMICCOLOR_DYNAMIC_SCHEME_H_
-
-#include
-#include
-
-#include "cpp/cam/hct.h"
-#include "cpp/dynamiccolor/variant.h"
-#include "cpp/palettes/tones.h"
-#include "cpp/utils/utils.h"
-
-namespace material_color_utilities {
-
-struct DynamicScheme {
- Hct source_color_hct;
- Variant variant;
- bool is_dark;
- double contrast_level;
-
- TonalPalette primary_palette;
- TonalPalette secondary_palette;
- TonalPalette tertiary_palette;
- TonalPalette neutral_palette;
- TonalPalette neutral_variant_palette;
- TonalPalette error_palette;
-
- DynamicScheme(Hct source_color_hct, Variant variant, double contrast_level,
- bool is_dark, TonalPalette primary_palette,
- TonalPalette secondary_palette, TonalPalette tertiary_palette,
- TonalPalette neutral_palette,
- TonalPalette neutral_variant_palette,
- std::optional error_palette = std::nullopt);
-
- static double GetRotatedHue(Hct source_color, std::vector hues,
- std::vector rotations);
-
- Argb SourceColorArgb() const;
-
- Argb GetPrimaryPaletteKeyColor() const;
- Argb GetSecondaryPaletteKeyColor() const;
- Argb GetTertiaryPaletteKeyColor() const;
- Argb GetNeutralPaletteKeyColor() const;
- Argb GetNeutralVariantPaletteKeyColor() const;
- Argb GetBackground() const;
- Argb GetOnBackground() const;
- Argb GetSurface() const;
- Argb GetSurfaceDim() const;
- Argb GetSurfaceBright() const;
- Argb GetSurfaceContainerLowest() const;
- Argb GetSurfaceContainerLow() const;
- Argb GetSurfaceContainer() const;
- Argb GetSurfaceContainerHigh() const;
- Argb GetSurfaceContainerHighest() const;
- Argb GetOnSurface() const;
- Argb GetSurfaceVariant() const;
- Argb GetOnSurfaceVariant() const;
- Argb GetInverseSurface() const;
- Argb GetInverseOnSurface() const;
- Argb GetOutline() const;
- Argb GetOutlineVariant() const;
- Argb GetShadow() const;
- Argb GetScrim() const;
- Argb GetSurfaceTint() const;
- Argb GetPrimary() const;
- Argb GetOnPrimary() const;
- Argb GetPrimaryContainer() const;
- Argb GetOnPrimaryContainer() const;
- Argb GetInversePrimary() const;
- Argb GetSecondary() const;
- Argb GetOnSecondary() const;
- Argb GetSecondaryContainer() const;
- Argb GetOnSecondaryContainer() const;
- Argb GetTertiary() const;
- Argb GetOnTertiary() const;
- Argb GetTertiaryContainer() const;
- Argb GetOnTertiaryContainer() const;
- Argb GetError() const;
- Argb GetOnError() const;
- Argb GetErrorContainer() const;
- Argb GetOnErrorContainer() const;
- Argb GetPrimaryFixed() const;
- Argb GetPrimaryFixedDim() const;
- Argb GetOnPrimaryFixed() const;
- Argb GetOnPrimaryFixedVariant() const;
- Argb GetSecondaryFixed() const;
- Argb GetSecondaryFixedDim() const;
- Argb GetOnSecondaryFixed() const;
- Argb GetOnSecondaryFixedVariant() const;
- Argb GetTertiaryFixed() const;
- Argb GetTertiaryFixedDim() const;
- Argb GetOnTertiaryFixed() const;
- Argb GetOnTertiaryFixedVariant() const;
-};
-
-} // namespace material_color_utilities
-
-#endif // CPP_DYNAMICCOLOR_DYNAMIC_SCHEME_H_
diff --git a/cpp/dynamiccolor/material_dynamic_colors.cc b/cpp/dynamiccolor/material_dynamic_colors.cc
deleted file mode 100644
index 26ddb766..00000000
--- a/cpp/dynamiccolor/material_dynamic_colors.cc
+++ /dev/null
@@ -1,1153 +0,0 @@
-/*
- * Copyright 2023 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "cpp/dynamiccolor/material_dynamic_colors.h"
-
-#include
-
-#include "cpp/cam/cam.h"
-#include "cpp/cam/hct.h"
-#include "cpp/dislike/dislike.h"
-#include "cpp/dynamiccolor/contrast_curve.h"
-#include "cpp/dynamiccolor/dynamic_color.h"
-#include "cpp/dynamiccolor/dynamic_scheme.h"
-#include "cpp/dynamiccolor/tone_delta_pair.h"
-#include "cpp/dynamiccolor/variant.h"
-#include "cpp/utils/utils.h"
-
-namespace material_color_utilities {
-
-using std::nullopt;
-
-bool IsFidelity(const DynamicScheme& scheme) {
- return scheme.variant == Variant::kFidelity ||
- scheme.variant == Variant::kContent;
-}
-
-bool IsMonochrome(const DynamicScheme& scheme) {
- return scheme.variant == Variant::kMonochrome;
-}
-
-Vec3 XyzInViewingConditions(Cam cam, ViewingConditions viewing_conditions) {
- double alpha = (cam.chroma == 0.0 || cam.j == 0.0)
- ? 0.0
- : cam.chroma / sqrt(cam.j / 100.0);
-
- double t = pow(
- alpha / pow(1.64 - pow(0.29,
- viewing_conditions.background_y_to_white_point_y),
- 0.73),
- 1.0 / 0.9);
- double h_rad = cam.hue * M_PI / 180.0;
-
- double e_hue = 0.25 * (cos(h_rad + 2.0) + 3.8);
- double ac =
- viewing_conditions.aw *
- pow(cam.j / 100.0, 1.0 / viewing_conditions.c / viewing_conditions.z);
- double p1 = e_hue * (50000.0 / 13.0) * viewing_conditions.n_c *
- viewing_conditions.ncb;
-
- double p2 = (ac / viewing_conditions.nbb);
-
- double h_sin = sin(h_rad);
- double h_cos = cos(h_rad);
-
- double gamma = 23.0 * (p2 + 0.305) * t /
- (23.0 * p1 + 11 * t * h_cos + 108.0 * t * h_sin);
- double a = gamma * h_cos;
- double b = gamma * h_sin;
- double r_a = (460.0 * p2 + 451.0 * a + 288.0 * b) / 1403.0;
- double g_a = (460.0 * p2 - 891.0 * a - 261.0 * b) / 1403.0;
- double b_a = (460.0 * p2 - 220.0 * a - 6300.0 * b) / 1403.0;
-
- double r_c_base = fmax(0, (27.13 * fabs(r_a)) / (400.0 - fabs(r_a)));
- double r_c =
- Signum(r_a) * (100.0 / viewing_conditions.fl) * pow(r_c_base, 1.0 / 0.42);
- double g_c_base = fmax(0, (27.13 * fabs(g_a)) / (400.0 - fabs(g_a)));
- double g_c =
- Signum(g_a) * (100.0 / viewing_conditions.fl) * pow(g_c_base, 1.0 / 0.42);
- double b_c_base = fmax(0, (27.13 * fabs(b_a)) / (400.0 - fabs(b_a)));
- double b_c =
- Signum(b_a) * (100.0 / viewing_conditions.fl) * pow(b_c_base, 1.0 / 0.42);
- double r_f = r_c / viewing_conditions.rgb_d[0];
- double g_f = g_c / viewing_conditions.rgb_d[1];
- double b_f = b_c / viewing_conditions.rgb_d[2];
-
- double x = 1.86206786 * r_f - 1.01125463 * g_f + 0.14918677 * b_f;
- double y = 0.38752654 * r_f + 0.62144744 * g_f - 0.00897398 * b_f;
- double z = -0.01584150 * r_f - 0.03412294 * g_f + 1.04996444 * b_f;
-
- return {x, y, z};
-}
-
-Hct InViewingConditions(Hct hct, ViewingConditions vc) {
- // 1. Use CAM16 to find XYZ coordinates of color in specified VC.
- Cam cam16 = CamFromInt(hct.ToInt());
- Vec3 viewed_in_vc = XyzInViewingConditions(cam16, vc);
-
- // 2. Create CAM16 of those XYZ coordinates in default VC.
- Cam recast_in_vc =
- CamFromXyzAndViewingConditions(viewed_in_vc.a, viewed_in_vc.b,
- viewed_in_vc.c, kDefaultViewingConditions);
-
- // 3. Create HCT from:
- // - CAM16 using default VC with XYZ coordinates in specified VC.
- // - L* converted from Y in XYZ coordinates in specified VC.
- Hct recast_hct =
- Hct(recast_in_vc.hue, recast_in_vc.chroma, LstarFromY(viewed_in_vc.b));
- return recast_hct;
-}
-
-double FindDesiredChromaByTone(double hue, double chroma, double tone,
- bool by_decreasing_tone) {
- double answer = tone;
-
- Hct closest_to_chroma = Hct(hue, chroma, tone);
- if (closest_to_chroma.get_chroma() < chroma) {
- double chroma_peak = closest_to_chroma.get_chroma();
- while (closest_to_chroma.get_chroma() < chroma) {
- answer += by_decreasing_tone ? -1.0 : 1.0;
- Hct potential_solution = Hct(hue, chroma, answer);
- if (chroma_peak > potential_solution.get_chroma()) {
- break;
- }
- if (abs(potential_solution.get_chroma() - chroma) < 0.4) {
- break;
- }
-
- double potential_delta = abs(potential_solution.get_chroma() - chroma);
- double current_delta = abs(closest_to_chroma.get_chroma() - chroma);
- if (potential_delta < current_delta) {
- closest_to_chroma = potential_solution;
- }
- chroma_peak = fmax(chroma_peak, potential_solution.get_chroma());
- }
- }
-
- return answer;
-}
-
-constexpr double kContentAccentToneDelta = 15.0;
-DynamicColor highestSurface(const DynamicScheme& s) {
- return s.is_dark ? MaterialDynamicColors::SurfaceBright()
- : MaterialDynamicColors::SurfaceDim();
-}
-
-// Compatibility Keys Colors for Android
-DynamicColor MaterialDynamicColors::PrimaryPaletteKeyColor() {
- return DynamicColor::FromPalette(
- "primary_palette_key_color",
- [](const DynamicScheme& s) -> TonalPalette { return s.primary_palette; },
- [](const DynamicScheme& s) -> double {
- return s.primary_palette.get_key_color().get_tone();
- });
-}
-
-DynamicColor MaterialDynamicColors::SecondaryPaletteKeyColor() {
- return DynamicColor::FromPalette(
- "secondary_palette_key_color",
- [](const DynamicScheme& s) -> TonalPalette {
- return s.secondary_palette;
- },
- [](const DynamicScheme& s) -> double {
- return s.secondary_palette.get_key_color().get_tone();
- });
-}
-
-DynamicColor MaterialDynamicColors::TertiaryPaletteKeyColor() {
- return DynamicColor::FromPalette(
- "tertiary_palette_key_color",
- [](const DynamicScheme& s) -> TonalPalette { return s.tertiary_palette; },
- [](const DynamicScheme& s) -> double {
- return s.tertiary_palette.get_key_color().get_tone();
- });
-}
-
-DynamicColor MaterialDynamicColors::NeutralPaletteKeyColor() {
- return DynamicColor::FromPalette(
- "neutral_palette_key_color",
- [](const DynamicScheme& s) -> TonalPalette { return s.neutral_palette; },
- [](const DynamicScheme& s) -> double {
- return s.neutral_palette.get_key_color().get_tone();
- });
-}
-
-DynamicColor MaterialDynamicColors::NeutralVariantPaletteKeyColor() {
- return DynamicColor::FromPalette(
- "neutral_variant_palette_key_color",
- [](const DynamicScheme& s) -> TonalPalette {
- return s.neutral_variant_palette;
- },
- [](const DynamicScheme& s) -> double {
- return s.neutral_variant_palette.get_key_color().get_tone();
- });
-}
-
-DynamicColor MaterialDynamicColors::Background() {
- return DynamicColor(
- /* name= */ "background",
- /* palette= */
- [](const DynamicScheme& s) -> TonalPalette { return s.neutral_palette; },
- /* tone= */
- [](const DynamicScheme& s) -> double { return s.is_dark ? 6.0 : 98.0; },
- /* isBackground= */ true,
- /* background= */ nullopt,
- /* secondBackground= */ nullopt,
- /* contrastCurve= */ nullopt,
- /* toneDeltaPair= */ nullopt);
-}
-
-DynamicColor MaterialDynamicColors::OnBackground() {
- return DynamicColor(
- /* name= */ "on_background",
- /* palette= */
- [](const DynamicScheme& s) -> TonalPalette { return s.neutral_palette; },
- /* tone= */
- [](const DynamicScheme& s) -> double { return s.is_dark ? 90.0 : 10.0; },
- /* isBackground= */ false,
- /* background= */
- [](const DynamicScheme& s) -> DynamicColor { return Background(); },
- /* secondBackground= */ nullopt,
- /* contrastCurve= */ ContrastCurve(3.0, 3.0, 4.5, 7.0),
- /* toneDeltaPair= */ nullopt);
-}
-
-DynamicColor MaterialDynamicColors::Surface() {
- return DynamicColor(
- /* name= */ "surface",
- /* palette= */
- [](const DynamicScheme& s) -> TonalPalette { return s.neutral_palette; },
- /* tone= */
- [](const DynamicScheme& s) -> double { return s.is_dark ? 6.0 : 98.0; },
- /* isBackground= */ true,
- /* background= */ nullopt,
- /* secondBackground= */ nullopt,
- /* contrastCurve= */ nullopt,
- /* toneDeltaPair= */ nullopt);
-}
-
-DynamicColor MaterialDynamicColors::SurfaceDim() {
- return DynamicColor(
- /* name= */ "surface_dim",
- /* palette= */
- [](const DynamicScheme& s) -> TonalPalette { return s.neutral_palette; },
- /* tone= */
- [](const DynamicScheme& s) -> double {
- return s.is_dark ? 6.0
- : ContrastCurve(87.0, 87.0, 80.0, 75.0)
- .get(s.contrast_level);
- },
- /* isBackground= */ true,
- /* background= */ nullopt,
- /* secondBackground= */ nullopt,
- /* contrastCurve= */ nullopt,
- /* toneDeltaPair= */ nullopt);
-}
-
-DynamicColor MaterialDynamicColors::SurfaceBright() {
- return DynamicColor(
- /* name= */ "surface_bright",
- /* palette= */
- [](const DynamicScheme& s) -> TonalPalette { return s.neutral_palette; },
- /* tone= */
- [](const DynamicScheme& s) -> double {
- return s.is_dark
- ? ContrastCurve(24.0, 24.0, 29.0, 34.0).get(s.contrast_level)
- : 98.0;
- },
- /* isBackground= */ true,
- /* background= */ nullopt,
- /* secondBackground= */ nullopt,
- /* contrastCurve= */ nullopt,
- /* toneDeltaPair= */ nullopt);
-}
-
-DynamicColor MaterialDynamicColors::SurfaceContainerLowest() {
- return DynamicColor(
- /* name= */ "surface_container_lowest",
- /* palette= */
- [](const DynamicScheme& s) -> TonalPalette { return s.neutral_palette; },
- /* tone= */
- [](const DynamicScheme& s) -> double {
- return s.is_dark
- ? ContrastCurve(4.0, 4.0, 2.0, 0.0).get(s.contrast_level)
- : 100.0;
- },
- /* isBackground= */ true,
- /* background= */ nullopt,
- /* secondBackground= */ nullopt,
- /* contrastCurve= */ nullopt,
- /* toneDeltaPair= */ nullopt);
-}
-
-DynamicColor MaterialDynamicColors::SurfaceContainerLow() {
- return DynamicColor(
- /* name= */ "surface_container_low",
- /* palette= */
- [](const DynamicScheme& s) -> TonalPalette { return s.neutral_palette; },
- /* tone= */
- [](const DynamicScheme& s) -> double {
- return s.is_dark
- ? ContrastCurve(10.0, 10.0, 11.0, 12.0).get(s.contrast_level)
- : ContrastCurve(96.0, 96.0, 96.0, 95.0)
- .get(s.contrast_level);
- },
- /* isBackground= */ true,
- /* background= */ nullopt,
- /* secondBackground= */ nullopt,
- /* contrastCurve= */ nullopt,
- /* toneDeltaPair= */ nullopt);
-}
-
-DynamicColor MaterialDynamicColors::SurfaceContainer() {
- return DynamicColor(
- /* name= */ "surface_container",
- /* palette= */
- [](const DynamicScheme& s) -> TonalPalette { return s.neutral_palette; },
- /* tone= */
- [](const DynamicScheme& s) -> double {
- return s.is_dark
- ? ContrastCurve(12.0, 12.0, 16.0, 20.0).get(s.contrast_level)
- : ContrastCurve(94.0, 94.0, 92.0, 90.0)
- .get(s.contrast_level);
- },
- /* isBackground= */ true,
- /* background= */ nullopt,
- /* secondBackground= */ nullopt,
- /* contrastCurve= */ nullopt,
- /* toneDeltaPair= */ nullopt);
-}
-
-DynamicColor MaterialDynamicColors::SurfaceContainerHigh() {
- return DynamicColor(
- /* name= */ "surface_container_high",
- /* palette= */
- [](const DynamicScheme& s) -> TonalPalette { return s.neutral_palette; },
- /* tone= */
- [](const DynamicScheme& s) -> double {
- return s.is_dark
- ? ContrastCurve(17.0, 17.0, 21.0, 25.0).get(s.contrast_level)
- : ContrastCurve(92.0, 92.0, 88.0, 85.0)
- .get(s.contrast_level);
- },
- /* isBackground= */ true,
- /* background= */ nullopt,
- /* secondBackground= */ nullopt,
- /* contrastCurve= */ nullopt,
- /* toneDeltaPair= */ nullopt);
-}
-
-DynamicColor MaterialDynamicColors::SurfaceContainerHighest() {
- return DynamicColor(
- /* name= */ "surface_container_highest",
- /* palette= */
- [](const DynamicScheme& s) -> TonalPalette { return s.neutral_palette; },
- /* tone= */
- [](const DynamicScheme& s) -> double {
- return s.is_dark
- ? ContrastCurve(22.0, 22.0, 26.0, 30.0).get(s.contrast_level)
- : ContrastCurve(90.0, 90.0, 84.0, 80.0)
- .get(s.contrast_level);
- },
- /* isBackground= */ true,
- /* background= */ nullopt,
- /* secondBackground= */ nullopt,
- /* contrastCurve= */ nullopt,
- /* toneDeltaPair= */ nullopt);
-}
-
-DynamicColor MaterialDynamicColors::OnSurface() {
- return DynamicColor(
- /* name= */ "on_surface",
- /* palette= */
- [](const DynamicScheme& s) -> TonalPalette { return s.neutral_palette; },
- /* tone= */
- [](const DynamicScheme& s) -> double { return s.is_dark ? 90.0 : 10.0; },
- /* isBackground= */ false,
- /* background= */
- [](const DynamicScheme& s) -> DynamicColor { return highestSurface(s); },
- /* secondBackground= */ nullopt,
- /* contrastCurve= */ ContrastCurve(4.5, 7.0, 11.0, 21.0),
- /* toneDeltaPair= */ nullopt);
-}
-
-DynamicColor MaterialDynamicColors::SurfaceVariant() {
- return DynamicColor(
- /* name= */ "surface_variant",
- /* palette= */
- [](const DynamicScheme& s) -> TonalPalette {
- return s.neutral_variant_palette;
- },
- /* tone= */
- [](const DynamicScheme& s) -> double { return s.is_dark ? 30.0 : 90.0; },
- /* isBackground= */ true,
- /* background= */ nullopt,
- /* secondBackground= */ nullopt,
- /* contrastCurve= */ nullopt,
- /* toneDeltaPair= */ nullopt);
-}
-
-DynamicColor MaterialDynamicColors::OnSurfaceVariant() {
- return DynamicColor(
- /* name= */ "on_surface_variant",
- /* palette= */
- [](const DynamicScheme& s) -> TonalPalette {
- return s.neutral_variant_palette;
- },
- /* tone= */
- [](const DynamicScheme& s) -> double { return s.is_dark ? 80.0 : 30.0; },
- /* isBackground= */ false,
- /* background= */
- [](const DynamicScheme& s) -> DynamicColor { return highestSurface(s); },
- /* secondBackground= */ nullopt,
- /* contrastCurve= */ ContrastCurve(3.0, 4.5, 7.0, 11.0),
- /* toneDeltaPair= */ nullopt);
-}
-
-DynamicColor MaterialDynamicColors::InverseSurface() {
- return DynamicColor(
- /* name= */ "inverse_surface",
- /* palette= */
- [](const DynamicScheme& s) -> TonalPalette { return s.neutral_palette; },
- /* tone= */
- [](const DynamicScheme& s) -> double { return s.is_dark ? 90.0 : 20.0; },
- /* isBackground= */ false,
- /* background= */ nullopt,
- /* secondBackground= */ nullopt,
- /* contrastCurve= */ nullopt,
- /* toneDeltaPair= */ nullopt);
-}
-
-DynamicColor MaterialDynamicColors::InverseOnSurface() {
- return DynamicColor(
- /* name= */ "inverse_on_surface",
- /* palette= */
- [](const DynamicScheme& s) -> TonalPalette { return s.neutral_palette; },
- /* tone= */
- [](const DynamicScheme& s) -> double { return s.is_dark ? 20.0 : 95.0; },
- /* isBackground= */ false,
- /* background= */
- [](const DynamicScheme& s) -> DynamicColor { return InverseSurface(); },
- /* secondBackground= */ nullopt,
- /* contrastCurve= */ ContrastCurve(4.5, 7.0, 11.0, 21.0),
- /* toneDeltaPair= */ nullopt);
-}
-
-DynamicColor MaterialDynamicColors::Outline() {
- return DynamicColor(
- /* name= */ "outline",
- /* palette= */
- [](const DynamicScheme& s) -> TonalPalette {
- return s.neutral_variant_palette;
- },
- /* tone= */
- [](const DynamicScheme& s) -> double { return s.is_dark ? 60.0 : 50.0; },
- /* isBackground= */ false,
- /* background= */
- [](const DynamicScheme& s) -> DynamicColor { return highestSurface(s); },
- /* secondBackground= */ nullopt,
- /* contrastCurve= */ ContrastCurve(1.5, 3.0, 4.5, 7.0),
- /* toneDeltaPair= */ nullopt);
-}
-
-DynamicColor MaterialDynamicColors::OutlineVariant() {
- return DynamicColor(
- /* name= */ "outline_variant",
- /* palette= */
- [](const DynamicScheme& s) -> TonalPalette {
- return s.neutral_variant_palette;
- },
- /* tone= */
- [](const DynamicScheme& s) -> double { return s.is_dark ? 30.0 : 80.0; },
- /* isBackground= */ false,
- /* background= */
- [](const DynamicScheme& s) -> DynamicColor { return highestSurface(s); },
- /* secondBackground= */ nullopt,
- /* contrastCurve= */ ContrastCurve(1.0, 1.0, 3.0, 4.5),
- /* toneDeltaPair= */ nullopt);
-}
-
-DynamicColor MaterialDynamicColors::Shadow() {
- return DynamicColor(
- /* name= */ "shadow",
- /* palette= */
- [](const DynamicScheme& s) -> TonalPalette { return s.neutral_palette; },
- /* tone= */ [](const DynamicScheme& s) -> double { return 0.0; },
- /* isBackground= */ false,
- /* background= */ nullopt,
- /* secondBackground= */ nullopt,
- /* contrastCurve= */ nullopt,
- /* toneDeltaPair= */ nullopt);
-}
-
-DynamicColor MaterialDynamicColors::Scrim() {
- return DynamicColor(
- /* name= */ "scrim",
- /* palette= */
- [](const DynamicScheme& s) -> TonalPalette { return s.neutral_palette; },
- /* tone= */ [](const DynamicScheme& s) -> double { return 0.0; },
- /* isBackground= */ false,
- /* background= */ nullopt,
- /* secondBackground= */ nullopt,
- /* contrastCurve= */ nullopt,
- /* toneDeltaPair= */ nullopt);
-}
-
-DynamicColor MaterialDynamicColors::SurfaceTint() {
- return DynamicColor(
- /* name= */ "surface_tint",
- /* palette= */
- [](const DynamicScheme& s) -> TonalPalette { return s.primary_palette; },
- /* tone= */
- [](const DynamicScheme& s) -> double { return s.is_dark ? 80.0 : 40.0; },
- /* isBackground= */ true,
- /* background= */ nullopt,
- /* secondBackground= */ nullopt,
- /* contrastCurve= */ nullopt,
- /* toneDeltaPair= */ nullopt);
-}
-
-DynamicColor MaterialDynamicColors::Primary() {
- return DynamicColor(
- /* name= */ "primary",
- /* palette= */
- [](const DynamicScheme& s) -> TonalPalette { return s.primary_palette; },
- /* tone= */
- [](const DynamicScheme& s) -> double {
- if (IsMonochrome(s)) {
- return s.is_dark ? 100.0 : 0.0;
- }
- return s.is_dark ? 80.0 : 40.0;
- },
- /* isBackground= */ true,
- /* background= */
- [](const DynamicScheme& s) -> DynamicColor { return highestSurface(s); },
- /* secondBackground= */ nullopt,
- /* contrastCurve= */ ContrastCurve(3.0, 4.5, 7.0, 7.0),
- /* toneDeltaPair= */
- [](const DynamicScheme& s) -> ToneDeltaPair {
- return ToneDeltaPair(PrimaryContainer(), Primary(), 10.0,
- TonePolarity::kNearer, false);
- });
-}
-
-DynamicColor MaterialDynamicColors::OnPrimary() {
- return DynamicColor(
- /* name= */ "on_primary",
- /* palette= */
- [](const DynamicScheme& s) -> TonalPalette { return s.primary_palette; },
- /* tone= */
- [](const DynamicScheme& s) -> double {
- if (IsMonochrome(s)) {
- return s.is_dark ? 10.0 : 90.0;
- }
- return s.is_dark ? 20.0 : 100.0;
- },
- /* isBackground= */ false,
- /* background= */
- [](const DynamicScheme& s) -> DynamicColor { return Primary(); },
- /* secondBackground= */ nullopt,
- /* contrastCurve= */ ContrastCurve(4.5, 7.0, 11.0, 21.0),
- /* toneDeltaPair= */ nullopt);
-}
-
-DynamicColor MaterialDynamicColors::PrimaryContainer() {
- return DynamicColor(
- /* name= */ "primary_container",
- /* palette= */
- [](const DynamicScheme& s) -> TonalPalette { return s.primary_palette; },
- /* tone= */
- [](const DynamicScheme& s) -> double {
- if (IsFidelity(s)) {
- return s.source_color_hct.get_tone();
- }
- if (IsMonochrome(s)) {
- return s.is_dark ? 85.0 : 25.0;
- }
- return s.is_dark ? 30.0 : 90.0;
- },
- /* isBackground= */ true,
- /* background= */
- [](const DynamicScheme& s) -> DynamicColor { return highestSurface(s); },
- /* secondBackground= */ nullopt,
- /* contrastCurve= */ ContrastCurve(1.0, 1.0, 3.0, 4.5),
- /* toneDeltaPair= */
- [](const DynamicScheme& s) -> ToneDeltaPair {
- return ToneDeltaPair(PrimaryContainer(), Primary(), 10.0,
- TonePolarity::kNearer, false);
- });
-}
-
-DynamicColor MaterialDynamicColors::OnPrimaryContainer() {
- return DynamicColor(
- /* name= */
- "on_primary_container",
- /* palette= */
- [](const DynamicScheme& s) -> TonalPalette { return s.primary_palette; },
- /* tone= */
- [](const DynamicScheme& s) -> double {
- if (IsFidelity(s)) {
- return ForegroundTone(PrimaryContainer().tone_(s), 4.5);
- }
- if (IsMonochrome(s)) {
- return s.is_dark ? 0.0 : 100.0;
- }
- return s.is_dark ? 90.0 : 30.0;
- },
- /* isBackground= */ false,
- /* background= */
- [](const DynamicScheme& s) -> DynamicColor { return PrimaryContainer(); },
- /* secondBackground= */ nullopt,
- /* contrastCurve= */ ContrastCurve(3.0, 4.5, 7.0, 11.0),
- /* toneDeltaPair= */ nullopt);
-}
-
-DynamicColor MaterialDynamicColors::InversePrimary() {
- return DynamicColor(
- /* name= */ "inverse_primary",
- /* palette= */
- [](const DynamicScheme& s) -> TonalPalette { return s.primary_palette; },
- /* tone= */
- [](const DynamicScheme& s) -> double { return s.is_dark ? 40.0 : 80.0; },
- /* isBackground= */ false,
- /* background= */
- [](const DynamicScheme& s) -> DynamicColor { return InverseSurface(); },
- /* secondBackground= */ nullopt,
- /* contrastCurve= */ ContrastCurve(3.0, 4.5, 7.0, 7.0),
- /* toneDeltaPair= */ nullopt);
-}
-
-DynamicColor MaterialDynamicColors::Secondary() {
- return DynamicColor(
- /* name= */ "secondary",
- /* palette= */
- [](const DynamicScheme& s) -> TonalPalette {
- return s.secondary_palette;
- },
- /* tone= */
- [](const DynamicScheme& s) -> double { return s.is_dark ? 80.0 : 40.0; },
- /* isBackground= */ true,
- /* background= */
- [](const DynamicScheme& s) -> DynamicColor { return highestSurface(s); },
- /* secondBackground= */ nullopt,
- /* contrastCurve= */ ContrastCurve(3.0, 4.5, 7.0, 7.0),
- /* toneDeltaPair= */
- [](const DynamicScheme& s) -> ToneDeltaPair {
- return ToneDeltaPair(SecondaryContainer(), Secondary(), 10.0,
- TonePolarity::kNearer, false);
- });
-}
-
-DynamicColor MaterialDynamicColors::OnSecondary() {
- return DynamicColor(
- /* name= */ "on_secondary",
- /* palette= */
- [](const DynamicScheme& s) -> TonalPalette {
- return s.secondary_palette;
- },
- /* tone= */
- [](const DynamicScheme& s) -> double {
- if (IsMonochrome(s)) {
- return s.is_dark ? 10.0 : 100.0;
- } else {
- return s.is_dark ? 20.0 : 100.0;
- }
- },
- /* isBackground= */ false,
- /* background= */
- [](const DynamicScheme& s) -> DynamicColor { return Secondary(); },
- /* secondBackground= */ nullopt,
- /* contrastCurve= */ ContrastCurve(4.5, 7.0, 11.0, 21.0),
- /* toneDeltaPair= */ nullopt);
-}
-
-DynamicColor MaterialDynamicColors::SecondaryContainer() {
- return DynamicColor(
- /* name= */ "secondary_container",
- /* palette= */
- [](const DynamicScheme& s) -> TonalPalette {
- return s.secondary_palette;
- },
- /* tone= */
- [](const DynamicScheme& s) -> double {
- double initialTone = s.is_dark ? 30.0 : 90.0;
- if (IsMonochrome(s)) {
- return s.is_dark ? 30.0 : 85.0;
- }
- if (!IsFidelity(s)) {
- return initialTone;
- }
- return FindDesiredChromaByTone(s.secondary_palette.get_hue(),
- s.secondary_palette.get_chroma(),
- initialTone, s.is_dark ? false : true);
- },
- /* isBackground= */ true,
- /* background= */
- [](const DynamicScheme& s) -> DynamicColor { return highestSurface(s); },
- /* secondBackground= */ nullopt,
- /* contrastCurve= */ ContrastCurve(1.0, 1.0, 3.0, 4.5),
- /* toneDeltaPair= */
- [](const DynamicScheme& s) -> ToneDeltaPair {
- return ToneDeltaPair(SecondaryContainer(), Secondary(), 10.0,
- TonePolarity::kNearer, false);
- });
-}
-
-DynamicColor MaterialDynamicColors::OnSecondaryContainer() {
- return DynamicColor(
- /* name= */
- "on_secondary_container",
- /* palette= */
- [](const DynamicScheme& s) -> TonalPalette {
- return s.secondary_palette;
- },
- /* tone= */
- [](const DynamicScheme& s) -> double {
- if (IsMonochrome(s)) {
- return s.is_dark ? 90.0 : 10.0;
- }
- if (!IsFidelity(s)) {
- return s.is_dark ? 90.0 : 30.0;
- }
- return ForegroundTone(SecondaryContainer().tone_(s), 4.5);
- },
- /* isBackground= */ false,
- /* background= */
- [](const DynamicScheme& s) -> DynamicColor {
- return SecondaryContainer();
- },
- /* secondBackground= */ nullopt,
- /* contrastCurve= */ ContrastCurve(3.0, 4.5, 7.0, 11.0),
- /* toneDeltaPair= */ nullopt);
-}
-
-DynamicColor MaterialDynamicColors::Tertiary() {
- return DynamicColor(
- /* name= */ "tertiary",
- /* palette= */
- [](const DynamicScheme& s) -> TonalPalette { return s.tertiary_palette; },
- /* tone= */
- [](const DynamicScheme& s) -> double {
- if (IsMonochrome(s)) {
- return s.is_dark ? 90.0 : 25.0;
- }
- return s.is_dark ? 80.0 : 40.0;
- },
- /* isBackground= */ true,
- /* background= */
- [](const DynamicScheme& s) -> DynamicColor { return highestSurface(s); },
- /* secondBackground= */ nullopt,
- /* contrastCurve= */ ContrastCurve(3.0, 4.5, 7.0, 7.0),
- /* toneDeltaPair= */
- [](const DynamicScheme& s) -> ToneDeltaPair {
- return ToneDeltaPair(TertiaryContainer(), Tertiary(), 10.0,
- TonePolarity::kNearer, false);
- });
-}
-
-DynamicColor MaterialDynamicColors::OnTertiary() {
- return DynamicColor(
- /* name= */ "on_tertiary",
- /* palette= */
- [](const DynamicScheme& s) -> TonalPalette { return s.tertiary_palette; },
- /* tone= */
- [](const DynamicScheme& s) -> double {
- if (IsMonochrome(s)) {
- return s.is_dark ? 10.0 : 90.0;
- }
- return s.is_dark ? 20.0 : 100.0;
- },
- /* isBackground= */ false,
- /* background= */
- [](const DynamicScheme& s) -> DynamicColor { return Tertiary(); },
- /* secondBackground= */ nullopt,
- /* contrastCurve= */ ContrastCurve(4.5, 7.0, 11.0, 21.0),
- /* toneDeltaPair= */ nullopt);
-}
-
-DynamicColor MaterialDynamicColors::TertiaryContainer() {
- return DynamicColor(
- /* name= */ "tertiary_container",
- /* palette= */
- [](const DynamicScheme& s) -> TonalPalette { return s.tertiary_palette; },
- /* tone= */
- [](const DynamicScheme& s) -> double {
- if (IsMonochrome(s)) {
- return s.is_dark ? 60.0 : 49.0;
- }
- if (!IsFidelity(s)) {
- return s.is_dark ? 30.0 : 90.0;
- }
- Hct proposedHct =
- Hct(s.tertiary_palette.get(s.source_color_hct.get_tone()));
- return FixIfDisliked(proposedHct).get_tone();
- },
- /* isBackground= */ true,
- /* background= */
- [](const DynamicScheme& s) -> DynamicColor { return highestSurface(s); },
- /* secondBackground= */ nullopt,
- /* contrastCurve= */ ContrastCurve(1.0, 1.0, 3.0, 4.5),
- /* toneDeltaPair= */
- [](const DynamicScheme& s) -> ToneDeltaPair {
- return ToneDeltaPair(TertiaryContainer(), Tertiary(), 10.0,
- TonePolarity::kNearer, false);
- });
-}
-
-DynamicColor MaterialDynamicColors::OnTertiaryContainer() {
- return DynamicColor(
- /* name= */
- "on_tertiary_container",
- /* palette= */
- [](const DynamicScheme& s) -> TonalPalette { return s.tertiary_palette; },
- /* tone= */
- [](const DynamicScheme& s) -> double {
- if (IsMonochrome(s)) {
- return s.is_dark ? 0.0 : 100.0;
- }
- if (!IsFidelity(s)) {
- return s.is_dark ? 90.0 : 30.0;
- }
- return ForegroundTone(TertiaryContainer().tone_(s), 4.5);
- },
- /* isBackground= */ false,
- /* background= */
- [](const DynamicScheme& s) -> DynamicColor {
- return TertiaryContainer();
- },
- /* secondBackground= */ nullopt,
- /* contrastCurve= */ ContrastCurve(3.0, 4.5, 7.0, 11.0),
- /* toneDeltaPair= */ nullopt);
-}
-
-DynamicColor MaterialDynamicColors::Error() {
- return DynamicColor(
- /* name= */ "error",
- /* palette= */
- [](const DynamicScheme& s) -> TonalPalette { return s.error_palette; },
- /* tone= */
- [](const DynamicScheme& s) -> double { return s.is_dark ? 80.0 : 40.0; },
- /* isBackground= */ true,
- /* background= */
- [](const DynamicScheme& s) -> DynamicColor { return highestSurface(s); },
- /* secondBackground= */ nullopt,
- /* contrastCurve= */ ContrastCurve(3.0, 4.5, 7.0, 7.0),
- /* toneDeltaPair= */
- [](const DynamicScheme& s) -> ToneDeltaPair {
- return ToneDeltaPair(ErrorContainer(), Error(), 10.0,
- TonePolarity::kNearer, false);
- });
-}
-
-DynamicColor MaterialDynamicColors::OnError() {
- return DynamicColor(
- /* name= */ "on_error",
- /* palette= */
- [](const DynamicScheme& s) -> TonalPalette { return s.error_palette; },
- /* tone= */
- [](const DynamicScheme& s) -> double { return s.is_dark ? 20.0 : 100.0; },
- /* isBackground= */ false,
- /* background= */
- [](const DynamicScheme& s) -> DynamicColor { return Error(); },
- /* secondBackground= */ nullopt,
- /* contrastCurve= */ ContrastCurve(4.5, 7.0, 11.0, 21.0),
- /* toneDeltaPair= */ nullopt);
-}
-
-DynamicColor MaterialDynamicColors::ErrorContainer() {
- return DynamicColor(
- /* name= */ "error_container",
- /* palette= */
- [](const DynamicScheme& s) -> TonalPalette { return s.error_palette; },
- /* tone= */
- [](const DynamicScheme& s) -> double { return s.is_dark ? 30.0 : 90.0; },
- /* isBackground= */ true,
- /* background= */
- [](const DynamicScheme& s) -> DynamicColor { return highestSurface(s); },
- /* secondBackground= */ nullopt,
- /* contrastCurve= */ ContrastCurve(1.0, 1.0, 3.0, 4.5),
- /* toneDeltaPair= */
- [](const DynamicScheme& s) -> ToneDeltaPair {
- return ToneDeltaPair(ErrorContainer(), Error(), 10.0,
- TonePolarity::kNearer, false);
- });
-}
-
-DynamicColor MaterialDynamicColors::OnErrorContainer() {
- return DynamicColor(
- /* name= */
- "on_error_container",
- /* palette= */
- [](const DynamicScheme& s) -> TonalPalette { return s.error_palette; },
- /* tone= */
- [](const DynamicScheme& s) -> double {
- if (IsMonochrome(s)) {
- return s.is_dark ? 90.0 : 10.0;
- }
- return s.is_dark ? 90.0 : 30.0;
- },
- /* isBackground= */ false,
- /* background= */
- [](const DynamicScheme& s) -> DynamicColor { return ErrorContainer(); },
- /* secondBackground= */ nullopt,
- /* contrastCurve= */ ContrastCurve(3.0, 4.5, 7.0, 11.0),
- /* toneDeltaPair= */ nullopt);
-}
-
-DynamicColor MaterialDynamicColors::PrimaryFixed() {
- return DynamicColor(
- /* name= */ "primary_fixed",
- /* palette= */
- [](const DynamicScheme& s) -> TonalPalette { return s.primary_palette; },
- /* tone= */
- [](const DynamicScheme& s) -> double {
- return IsMonochrome(s) ? 40.0 : 90.0;
- },
- /* isBackground= */ true,
- /* background= */
- [](const DynamicScheme& s) -> DynamicColor { return highestSurface(s); },
- /* secondBackground= */ nullopt,
- /* contrastCurve= */ ContrastCurve(1.0, 1.0, 3.0, 4.5),
- /* toneDeltaPair= */
- [](const DynamicScheme& s) -> ToneDeltaPair {
- return ToneDeltaPair(PrimaryFixed(), PrimaryFixedDim(), 10.0,
- TonePolarity::kLighter, true);
- });
-}
-
-DynamicColor MaterialDynamicColors::PrimaryFixedDim() {
- return DynamicColor(
- /* name= */ "primary_fixed_dim",
- /* palette= */
- [](const DynamicScheme& s) -> TonalPalette { return s.primary_palette; },
- /* tone= */
- [](const DynamicScheme& s) -> double {
- return IsMonochrome(s) ? 30.0 : 80.0;
- },
- /* isBackground= */ true,
- /* background= */
- [](const DynamicScheme& s) -> DynamicColor { return highestSurface(s); },
- /* secondBackground= */ nullopt,
- /* contrastCurve= */ ContrastCurve(1.0, 1.0, 3.0, 4.5),
- /* toneDeltaPair= */
- [](const DynamicScheme& s) -> ToneDeltaPair {
- return ToneDeltaPair(PrimaryFixed(), PrimaryFixedDim(), 10.0,
- TonePolarity::kLighter, true);
- });
-}
-
-DynamicColor MaterialDynamicColors::OnPrimaryFixed() {
- return DynamicColor(
- /* name= */ "on_primary_fixed",
- /* palette= */
- [](const DynamicScheme& s) -> TonalPalette { return s.primary_palette; },
- /* tone= */
- [](const DynamicScheme& s) -> double {
- return IsMonochrome(s) ? 100.0 : 10.0;
- },
- /* isBackground= */ false,
- /* background= */
- [](const DynamicScheme& s) -> DynamicColor { return PrimaryFixedDim(); },
- /* secondBackground= */
- [](const DynamicScheme& s) -> DynamicColor { return PrimaryFixed(); },
- /* contrastCurve= */ ContrastCurve(4.5, 7.0, 11.0, 21.0),
- /* toneDeltaPair= */ nullopt);
-}
-
-DynamicColor MaterialDynamicColors::OnPrimaryFixedVariant() {
- return DynamicColor(
- /* name= */ "on_primary_fixed_variant",
- /* palette= */
- [](const DynamicScheme& s) -> TonalPalette { return s.primary_palette; },
- /* tone= */
- [](const DynamicScheme& s) -> double {
- return IsMonochrome(s) ? 90.0 : 30.0;
- },
- /* isBackground= */ false,
- /* background= */
- [](const DynamicScheme& s) -> DynamicColor { return PrimaryFixedDim(); },
- /* secondBackground= */
- [](const DynamicScheme& s) -> DynamicColor { return PrimaryFixed(); },
- /* contrastCurve= */ ContrastCurve(3.0, 4.5, 7.0, 11.0),
- /* toneDeltaPair= */ nullopt);
-}
-
-DynamicColor MaterialDynamicColors::SecondaryFixed() {
- return DynamicColor(
- /* name= */ "secondary_fixed",
- /* palette= */
- [](const DynamicScheme& s) -> TonalPalette {
- return s.secondary_palette;
- },
- /* tone= */
- [](const DynamicScheme& s) -> double {
- return IsMonochrome(s) ? 80.0 : 90.0;
- },
- /* isBackground= */ true,
- /* background= */
- [](const DynamicScheme& s) -> DynamicColor { return highestSurface(s); },
- /* secondBackground= */ nullopt,
- /* contrastCurve= */ ContrastCurve(1.0, 1.0, 3.0, 4.5),
- /* toneDeltaPair= */
- [](const DynamicScheme& s) -> ToneDeltaPair {
- return ToneDeltaPair(SecondaryFixed(), SecondaryFixedDim(), 10.0,
- TonePolarity::kLighter, true);
- });
-}
-
-DynamicColor MaterialDynamicColors::SecondaryFixedDim() {
- return DynamicColor(
- /* name= */ "secondary_fixed_dim",
- /* palette= */
- [](const DynamicScheme& s) -> TonalPalette {
- return s.secondary_palette;
- },
- /* tone= */
- [](const DynamicScheme& s) -> double {
- return IsMonochrome(s) ? 70.0 : 80.0;
- },
- /* isBackground= */ true,
- /* background= */
- [](const DynamicScheme& s) -> DynamicColor { return highestSurface(s); },
- /* secondBackground= */ nullopt,
- /* contrastCurve= */ ContrastCurve(1.0, 1.0, 3.0, 4.5),
- /* toneDeltaPair= */
- [](const DynamicScheme& s) -> ToneDeltaPair {
- return ToneDeltaPair(SecondaryFixed(), SecondaryFixedDim(), 10.0,
- TonePolarity::kLighter, true);
- });
-}
-
-DynamicColor MaterialDynamicColors::OnSecondaryFixed() {
- return DynamicColor(
- /* name= */ "on_secondary_fixed",
- /* palette= */
- [](const DynamicScheme& s) -> TonalPalette {
- return s.secondary_palette;
- },
- /* tone= */ [](const DynamicScheme& s) -> double { return 10.0; },
- /* isBackground= */ false,
- /* background= */
- [](const DynamicScheme& s) -> DynamicColor {
- return SecondaryFixedDim();
- },
- /* secondBackground= */
- [](const DynamicScheme& s) -> DynamicColor { return SecondaryFixed(); },
- /* contrastCurve= */ ContrastCurve(4.5, 7.0, 11.0, 21.0),
- /* toneDeltaPair= */ nullopt);
-}
-
-DynamicColor MaterialDynamicColors::OnSecondaryFixedVariant() {
- return DynamicColor(
- /* name= */ "on_secondary_fixed_variant",
- /* palette= */
- [](const DynamicScheme& s) -> TonalPalette {
- return s.secondary_palette;
- },
- /* tone= */
- [](const DynamicScheme& s) -> double {
- return IsMonochrome(s) ? 25.0 : 30.0;
- },
- /* isBackground= */ false,
- /* background= */
- [](const DynamicScheme& s) -> DynamicColor {
- return SecondaryFixedDim();
- },
- /* secondBackground= */
- [](const DynamicScheme& s) -> DynamicColor { return SecondaryFixed(); },
- /* contrastCurve= */ ContrastCurve(3.0, 4.5, 7.0, 11.0),
- /* toneDeltaPair= */ nullopt);
-}
-
-DynamicColor MaterialDynamicColors::TertiaryFixed() {
- return DynamicColor(
- /* name= */ "tertiary_fixed",
- /* palette= */
- [](const DynamicScheme& s) -> TonalPalette { return s.tertiary_palette; },
- /* tone= */
- [](const DynamicScheme& s) -> double {
- return IsMonochrome(s) ? 40.0 : 90.0;
- },
- /* isBackground= */ true,
- /* background= */
- [](const DynamicScheme& s) -> DynamicColor { return highestSurface(s); },
- /* secondBackground= */ nullopt,
- /* contrastCurve= */ ContrastCurve(1.0, 1.0, 3.0, 4.5),
- /* toneDeltaPair= */
- [](const DynamicScheme& s) -> ToneDeltaPair {
- return ToneDeltaPair(TertiaryFixed(), TertiaryFixedDim(), 10.0,
- TonePolarity::kLighter, true);
- });
-}
-
-DynamicColor MaterialDynamicColors::TertiaryFixedDim() {
- return DynamicColor(
- /* name= */ "tertiary_fixed_dim",
- /* palette= */
- [](const DynamicScheme& s) -> TonalPalette { return s.tertiary_palette; },
- /* tone= */
- [](const DynamicScheme& s) -> double {
- return IsMonochrome(s) ? 30.0 : 80.0;
- },
- /* isBackground= */ true,
- /* background= */
- [](const DynamicScheme& s) -> DynamicColor { return highestSurface(s); },
- /* secondBackground= */ nullopt,
- /* contrastCurve= */ ContrastCurve(1.0, 1.0, 3.0, 4.5),
- /* toneDeltaPair= */
- [](const DynamicScheme& s) -> ToneDeltaPair {
- return ToneDeltaPair(TertiaryFixed(), TertiaryFixedDim(), 10.0,
- TonePolarity::kLighter, true);
- });
-}
-
-DynamicColor MaterialDynamicColors::OnTertiaryFixed() {
- return DynamicColor(
- /* name= */ "on_tertiary_fixed",
- /* palette= */
- [](const DynamicScheme& s) -> TonalPalette { return s.tertiary_palette; },
- /* tone= */
- [](const DynamicScheme& s) -> double {
- return IsMonochrome(s) ? 100.0 : 10.0;
- },
- /* isBackground= */ false,
- /* background= */
- [](const DynamicScheme& s) -> DynamicColor { return TertiaryFixedDim(); },
- /* secondBackground= */
- [](const DynamicScheme& s) -> DynamicColor { return TertiaryFixed(); },
- /* contrastCurve= */ ContrastCurve(4.5, 7.0, 11.0, 21.0),
- /* toneDeltaPair= */ nullopt);
-}
-
-DynamicColor MaterialDynamicColors::OnTertiaryFixedVariant() {
- return DynamicColor(
- /* name= */ "on_tertiary_fixed_variant",
- /* palette= */
- [](const DynamicScheme& s) -> TonalPalette { return s.tertiary_palette; },
- /* tone= */
- [](const DynamicScheme& s) -> double {
- return IsMonochrome(s) ? 90.0 : 30.0;
- },
- /* isBackground= */ false,
- /* background= */
- [](const DynamicScheme& s) -> DynamicColor { return TertiaryFixedDim(); },
- /* secondBackground= */
- [](const DynamicScheme& s) -> DynamicColor { return TertiaryFixed(); },
- /* contrastCurve= */ ContrastCurve(3.0, 4.5, 7.0, 11.0),
- /* toneDeltaPair= */ nullopt);
-}
-
-} // namespace material_color_utilities
diff --git a/cpp/dynamiccolor/material_dynamic_colors.h b/cpp/dynamiccolor/material_dynamic_colors.h
deleted file mode 100644
index 35a0af5b..00000000
--- a/cpp/dynamiccolor/material_dynamic_colors.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright 2023 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef CPP_DYNAMICCOLOR_MATERIAL_DYNAMIC_COLORS_H_
-#define CPP_DYNAMICCOLOR_MATERIAL_DYNAMIC_COLORS_H_
-
-#include "cpp/dynamiccolor/dynamic_color.h"
-
-namespace material_color_utilities {
-
-class MaterialDynamicColors {
- public:
- static DynamicColor PrimaryPaletteKeyColor();
- static DynamicColor SecondaryPaletteKeyColor();
- static DynamicColor TertiaryPaletteKeyColor();
- static DynamicColor NeutralPaletteKeyColor();
- static DynamicColor NeutralVariantPaletteKeyColor();
- static DynamicColor Background();
- static DynamicColor OnBackground();
- static DynamicColor Surface();
- static DynamicColor SurfaceDim();
- static DynamicColor SurfaceBright();
- static DynamicColor SurfaceContainerLowest();
- static DynamicColor SurfaceContainerLow();
- static DynamicColor SurfaceContainer();
- static DynamicColor SurfaceContainerHigh();
- static DynamicColor SurfaceContainerHighest();
- static DynamicColor OnSurface();
- static DynamicColor SurfaceVariant();
- static DynamicColor OnSurfaceVariant();
- static DynamicColor InverseSurface();
- static DynamicColor InverseOnSurface();
- static DynamicColor Outline();
- static DynamicColor OutlineVariant();
- static DynamicColor Shadow();
- static DynamicColor Scrim();
- static DynamicColor SurfaceTint();
- static DynamicColor Primary();
- static DynamicColor OnPrimary();
- static DynamicColor PrimaryContainer();
- static DynamicColor OnPrimaryContainer();
- static DynamicColor InversePrimary();
- static DynamicColor Secondary();
- static DynamicColor OnSecondary();
- static DynamicColor SecondaryContainer();
- static DynamicColor OnSecondaryContainer();
- static DynamicColor Tertiary();
- static DynamicColor OnTertiary();
- static DynamicColor TertiaryContainer();
- static DynamicColor OnTertiaryContainer();
- static DynamicColor Error();
- static DynamicColor OnError();
- static DynamicColor ErrorContainer();
- static DynamicColor OnErrorContainer();
- static DynamicColor PrimaryFixed();
- static DynamicColor PrimaryFixedDim();
- static DynamicColor OnPrimaryFixed();
- static DynamicColor OnPrimaryFixedVariant();
- static DynamicColor SecondaryFixed();
- static DynamicColor SecondaryFixedDim();
- static DynamicColor OnSecondaryFixed();
- static DynamicColor OnSecondaryFixedVariant();
- static DynamicColor TertiaryFixed();
- static DynamicColor TertiaryFixedDim();
- static DynamicColor OnTertiaryFixed();
- static DynamicColor OnTertiaryFixedVariant();
-};
-
-} // namespace material_color_utilities
-
-#endif // CPP_DYNAMICCOLOR_MATERIAL_DYNAMIC_COLORS_H_
diff --git a/cpp/dynamiccolor/tone_delta_pair.h b/cpp/dynamiccolor/tone_delta_pair.h
deleted file mode 100644
index 1e44950c..00000000
--- a/cpp/dynamiccolor/tone_delta_pair.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright 2023 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef CPP_DYNAMICCOLOR_TONE_DELTA_PAIR_H_
-#define CPP_DYNAMICCOLOR_TONE_DELTA_PAIR_H_
-
-#include "cpp/dynamiccolor/dynamic_color.h"
-
-namespace material_color_utilities {
-
-/**
- * Describes the different in tone between colors.
- */
-enum class TonePolarity { kDarker, kLighter, kNearer, kFarther };
-
-/**
- * Documents a constraint between two DynamicColors, in which their tones must
- * have a certain distance from each other.
- *
- * Prefer a DynamicColor with a background, this is for special cases when
- * designers want tonal distance, literally contrast, between two colors that
- * don't have a background / foreground relationship or a contrast guarantee.
- */
-struct ToneDeltaPair {
- DynamicColor role_a_;
- DynamicColor role_b_;
- double delta_;
- TonePolarity polarity_;
- bool stay_together_;
-
- /**
- * Documents a constraint in tone distance between two DynamicColors.
- *
- * The polarity is an adjective that describes "A", compared to "B".
- *
- * For instance, ToneDeltaPair(A, B, 15, 'darker', stayTogether) states that
- * A's tone should be at least 15 darker than B's.
- *
- * 'nearer' and 'farther' describes closeness to the surface roles. For
- * instance, ToneDeltaPair(A, B, 10, 'nearer', stayTogether) states that A
- * should be 10 lighter than B in light mode, and 10 darker than B in dark
- * mode.
- *
- * @param roleA The first role in a pair.
- * @param roleB The second role in a pair.
- * @param delta Required difference between tones. Absolute value, negative
- * values have undefined behavior.
- * @param polarity The relative relation between tones of roleA and roleB,
- * as described above.
- * @param stayTogether Whether these two roles should stay on the same side of
- * the "awkward zone" (T50-59). This is necessary for certain cases where
- * one role has two backgrounds.
- */
- ToneDeltaPair(DynamicColor role_a, DynamicColor role_b, double delta,
- TonePolarity polarity, bool stay_together)
- : role_a_(role_a),
- role_b_(role_b),
- delta_(delta),
- polarity_(polarity),
- stay_together_(stay_together) {}
-};
-
-} // namespace material_color_utilities
-
-#endif // CPP_DYNAMICCOLOR_TONE_DELTA_PAIR_H_
diff --git a/cpp/dynamiccolor/variant.h b/cpp/dynamiccolor/variant.h
deleted file mode 100644
index 2dc3dd46..00000000
--- a/cpp/dynamiccolor/variant.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2023 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef CPP_DYNAMICCOLOR_VARIANT_H_
-#define CPP_DYNAMICCOLOR_VARIANT_H_
-
-namespace material_color_utilities {
-
-enum class Variant {
- kMonochrome,
- kNeutral,
- kTonalSpot,
- kVibrant,
- kExpressive,
- kFidelity,
- kContent,
- kRainbow,
- kFruitSalad,
-};
-
-} // namespace material_color_utilities
-
-#endif // CPP_DYNAMICCOLOR_VARIANT_H_
diff --git a/cpp/palettes/core.h b/cpp/palettes/core.h
deleted file mode 100644
index 66fb0303..00000000
--- a/cpp/palettes/core.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2022 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef CPP_PALETTES_CORE_H_
-#define CPP_PALETTES_CORE_H_
-
-#include "cpp/palettes/tones.h"
-
-namespace material_color_utilities {
-
-/**
- * Comprises foundational palettes to build a color scheme. Generated from a
- * source color, these palettes will then be part of a [DynamicScheme] together
- * with appearance preferences.
-*/
-typedef struct {
- TonalPalette primary;
- TonalPalette secondary;
- TonalPalette tertiary;
- TonalPalette neutral;
- TonalPalette neutral_variant;
-} CorePalettes;
-
-} // namespace material_color_utilities
-
-#endif // CPP_PALETTES_CORE_H_
diff --git a/cpp/palettes/tones.cc b/cpp/palettes/tones.cc
deleted file mode 100644
index cc5d1b93..00000000
--- a/cpp/palettes/tones.cc
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright 2022 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "cpp/palettes/tones.h"
-
-#include
-
-#include "cpp/cam/cam.h"
-#include "cpp/cam/hct.h"
-
-namespace material_color_utilities {
-
-TonalPalette::TonalPalette(Argb argb) : key_color_(0.0, 0.0, 0.0) {
- Cam cam = CamFromInt(argb);
- hue_ = cam.hue;
- chroma_ = cam.chroma;
- key_color_ = KeyColor(cam.hue, cam.chroma).create();
-}
-
-TonalPalette::TonalPalette(Hct hct)
- : key_color_(hct.get_hue(), hct.get_chroma(), hct.get_tone()) {
- hue_ = hct.get_hue();
- chroma_ = hct.get_chroma();
-}
-
-TonalPalette::TonalPalette(double hue, double chroma)
- : key_color_(hue, chroma, 0.0) {
- hue_ = hue;
- chroma_ = chroma;
- key_color_ = KeyColor(hue, chroma).create();
-}
-
-TonalPalette::TonalPalette(double hue, double chroma, Hct key_color)
- : key_color_(key_color.get_hue(), key_color.get_chroma(),
- key_color.get_tone()) {
- hue_ = hue;
- chroma_ = chroma;
-}
-
-Argb TonalPalette::get(double tone) const {
- return IntFromHcl(hue_, chroma_, tone);
-}
-
-KeyColor::KeyColor(double hue, double requested_chroma)
- : hue_(hue), requested_chroma_(requested_chroma) {}
-
-Hct KeyColor::create() {
- // Pivot around T50 because T50 has the most chroma available, on
- // average. Thus it is most likely to have a direct answer.
- const int pivot_tone = 50;
- const int tone_step_size = 1;
- // Epsilon to accept values slightly higher than the requested chroma.
- const double epsilon = 0.01;
-
- // Binary search to find the tone that can provide a chroma that is closest
- // to the requested chroma.
- int lower_tone = 0;
- int upper_tone = 100;
- while (lower_tone < upper_tone) {
- const int mid_tone = (lower_tone + upper_tone) / 2;
- bool is_ascending =
- max_chroma(mid_tone) < max_chroma(mid_tone + tone_step_size);
- bool sufficient_chroma =
- max_chroma(mid_tone) >= requested_chroma_ - epsilon;
-
- if (sufficient_chroma) {
- // Either range [lower_tone, mid_tone] or [mid_tone, upper_tone] has
- // the answer, so search in the range that is closer the pivot tone.
- if (abs(lower_tone - pivot_tone) < abs(upper_tone - pivot_tone)) {
- upper_tone = mid_tone;
- } else {
- if (lower_tone == mid_tone) {
- return Hct(hue_, requested_chroma_, lower_tone);
- }
- lower_tone = mid_tone;
- }
- } else {
- // As there's no sufficient chroma in the mid_tone, follow the direction
- // to the chroma peak.
- if (is_ascending) {
- lower_tone = mid_tone + tone_step_size;
- } else {
- // Keep mid_tone for potential chroma peak.
- upper_tone = mid_tone;
- }
- }
- }
-
- return Hct(hue_, requested_chroma_, lower_tone);
-}
-
-double KeyColor::max_chroma(double tone) {
- auto it = chroma_cache_.find(tone);
- if (it != chroma_cache_.end()) {
- return it->second;
- }
-
- double chroma = Hct(hue_, max_chroma_value_, tone).get_chroma();
- chroma_cache_[tone] = chroma;
- return chroma;
-};
-
-} // namespace material_color_utilities
diff --git a/cpp/palettes/tones.h b/cpp/palettes/tones.h
deleted file mode 100644
index 2c4e64d1..00000000
--- a/cpp/palettes/tones.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright 2022 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef CPP_PALETTES_TONES_H_
-#define CPP_PALETTES_TONES_H_
-
-#include
-
-#include "cpp/cam/hct.h"
-#include "cpp/utils/utils.h"
-
-namespace material_color_utilities {
-
-class TonalPalette {
- public:
- explicit TonalPalette(Argb argb);
- TonalPalette(Hct hct);
- TonalPalette(double hue, double chroma);
- TonalPalette(double hue, double chroma, Hct key_color);
-
- /**
- * Returns the color for a given tone in this palette.
- *
- * @param tone 0.0 <= tone <= 100.0
- * @return a color as an integer, in ARGB format.
- */
- Argb get(double tone) const;
-
- double get_hue() const { return hue_; }
- double get_chroma() const { return chroma_; }
- Hct get_key_color() const { return key_color_; }
-
- private:
- double hue_;
- double chroma_;
- Hct key_color_;
-};
-
-/**
- * Key color is a color that represents the hue and chroma of a tonal palette
- */
-class KeyColor {
- public:
- KeyColor(double hue, double requested_chroma);
- /**
- * Creates a key color from a [hue] and a [chroma].
- * The key color is the first tone, starting from T50, matching the given hue
- * and chroma.
- *
- * @return Key color in Hct.
- */
- Hct create();
-
- private:
- const double max_chroma_value_ = 200.0;
- double hue_;
- double requested_chroma_;
- // Cache that maps tone to max chroma to avoid duplicated HCT calculation.
- std::unordered_map chroma_cache_;
-
- double max_chroma(double tone);
-};
-
-} // namespace material_color_utilities
-#endif // CPP_PALETTES_TONES_H_
diff --git a/cpp/palettes/tones_test.cc b/cpp/palettes/tones_test.cc
deleted file mode 100644
index 8da3d11f..00000000
--- a/cpp/palettes/tones_test.cc
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright 2022 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "cpp/palettes/tones.h"
-
-#include "testing/base/public/gunit.h"
-#include "cpp/cam/hct.h"
-#include "cpp/utils/utils.h"
-
-namespace material_color_utilities {
-
-namespace {
-
-TEST(TonesTest, Blue) {
- Argb color = 0xff0000ff;
- TonalPalette tonal_palette = TonalPalette(color);
- EXPECT_EQ(HexFromArgb(tonal_palette.get(100)), "ffffffff");
- EXPECT_EQ(HexFromArgb(tonal_palette.get(95)), "fff1efff");
- EXPECT_EQ(HexFromArgb(tonal_palette.get(90)), "ffe0e0ff");
- EXPECT_EQ(HexFromArgb(tonal_palette.get(80)), "ffbec2ff");
- EXPECT_EQ(HexFromArgb(tonal_palette.get(70)), "ff9da3ff");
- EXPECT_EQ(HexFromArgb(tonal_palette.get(60)), "ff7c84ff");
- EXPECT_EQ(HexFromArgb(tonal_palette.get(50)), "ff5a64ff");
- EXPECT_EQ(HexFromArgb(tonal_palette.get(40)), "ff343dff");
- EXPECT_EQ(HexFromArgb(tonal_palette.get(30)), "ff0000ef");
- EXPECT_EQ(HexFromArgb(tonal_palette.get(20)), "ff0001ac");
- EXPECT_EQ(HexFromArgb(tonal_palette.get(10)), "ff00006e");
- EXPECT_EQ(HexFromArgb(tonal_palette.get(0)), "ff000000");
-}
-
-TEST(KeyColorTests, ExactChromaAvailable) {
- // Requested chroma is exactly achievable at a certain tone.
- TonalPalette palette = TonalPalette(50.0, 60.0);
- Hct result = palette.get_key_color();
-
- EXPECT_NEAR(result.get_hue(), 50.0, 10.0);
- EXPECT_NEAR(result.get_chroma(), 60.0, 0.5);
- // Tone might vary, but should be within the range from 0 to 100.
- EXPECT_GT(result.get_tone(), 0);
- EXPECT_LT(result.get_tone(), 100);
-}
-
-TEST(KeyColorTests, UnusuallyHighChroma) {
- // Requested chroma is above what is achievable. For Hue 149, chroma peak
- // is 89.6 at Tone 87.9. The result key color's chroma should be close to the
- // chroma peak.
- TonalPalette palette = TonalPalette(149.0, 200.0);
- Hct result = palette.get_key_color();
-
- EXPECT_NEAR(result.get_hue(), 149.0, 10.0);
- EXPECT_GT(result.get_chroma(), 89.0);
- // Tone might vary, but should be within the range from 0 to 100.
- EXPECT_GT(result.get_tone(), 0);
- EXPECT_LT(result.get_tone(), 100);
-}
-
-TEST(KeyColorTests, UnusuallyLowChroma) {
- // By definition, the key color should be the first tone, starting from Tone
- // 50, matching the given hue and chroma. When requesting a very low chroma,
- // the result should be close to Tone 50, since most tones can produce a low
- // chroma.
- TonalPalette palette = TonalPalette(50.0, 3.0);
- Hct result = palette.get_key_color();
-
- // Higher error tolerance for hue when the requested chroma is unusually low.
- EXPECT_NEAR(result.get_hue(), 50.0, 10.0);
- EXPECT_NEAR(result.get_chroma(), 3.0, 0.5);
- EXPECT_NEAR(result.get_tone(), 50.0, 0.5);
-}
-
-} // namespace
-} // namespace material_color_utilities
diff --git a/cpp/quantize/celebi.cc b/cpp/quantize/celebi.cc
deleted file mode 100644
index 857979e9..00000000
--- a/cpp/quantize/celebi.cc
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright 2022 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "cpp/quantize/celebi.h"
-
-#include
-#include
-#include
-#include
-
-#include "cpp/quantize/wsmeans.h"
-#include "cpp/quantize/wu.h"
-#include "cpp/utils/utils.h"
-
-namespace material_color_utilities {
-
-QuantizerResult QuantizeCelebi(const std::vector& pixels,
- uint16_t max_colors) {
- if (max_colors == 0 || pixels.empty()) {
- return QuantizerResult();
- }
-
- if (max_colors > 256) {
- max_colors = 256;
- }
-
- int pixel_count = pixels.size();
-
- std::vector opaque_pixels;
- opaque_pixels.reserve(pixel_count);
- for (int i = 0; i < pixel_count; i++) {
- int pixel = pixels[i];
- if (!IsOpaque(pixel)) {
- continue;
- }
- opaque_pixels.push_back(pixel);
- }
-
- std::vector wu_result = QuantizeWu(opaque_pixels, max_colors);
-
- QuantizerResult result =
- QuantizeWsmeans(opaque_pixels, wu_result, max_colors);
-
- return result;
-}
-
-} // namespace material_color_utilities
diff --git a/cpp/quantize/celebi.h b/cpp/quantize/celebi.h
deleted file mode 100644
index f2f9d579..00000000
--- a/cpp/quantize/celebi.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2022 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef CPP_QUANTIZE_CELEBI_H_
-#define CPP_QUANTIZE_CELEBI_H_
-
-#include
-#include
-
-#include
-
-#include "cpp/quantize/wsmeans.h"
-#include "cpp/utils/utils.h"
-
-namespace material_color_utilities {
-
-QuantizerResult QuantizeCelebi(const std::vector& pixels,
- uint16_t max_colors);
-
-} // namespace material_color_utilities
-
-#endif // CPP_QUANTIZE_CELEBI_H_
diff --git a/cpp/quantize/celebi_test.cc b/cpp/quantize/celebi_test.cc
deleted file mode 100644
index 43177641..00000000
--- a/cpp/quantize/celebi_test.cc
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright 2022 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "cpp/quantize/celebi.h"
-
-#include
-#include
-
-#include "testing/base/public/gunit.h"
-
-namespace material_color_utilities {
-
-namespace {
-
-TEST(CelebiTest, FullImage) {
- std::vector pixels(12544);
- for (size_t i = 0; i < pixels.size(); i++) {
- // Creates 128 distinct colors
- pixels[i] = i % 8000;
- }
-
- int iterations = 1;
- uint16_t max_colors = 128;
- double sum = 0;
-
- for (int i = 0; i < iterations; i++) {
- clock_t begin = clock();
- QuantizeCelebi(pixels, max_colors);
- clock_t end = clock();
- double time_spent = static_cast(end - begin) / CLOCKS_PER_SEC;
- sum += time_spent;
- }
-}
-
-TEST(CelebiTest, OneRed) {
- std::vector pixels;
- pixels.push_back(0xffff0000);
- QuantizerResult result = QuantizeCelebi(pixels, 256);
- EXPECT_EQ(result.color_to_count.size(), 1u);
- EXPECT_EQ(result.color_to_count[0xffff0000], 1u);
-}
-
-TEST(CelebiTest, OneGreen) {
- std::vector pixels;
- pixels.push_back(0xff00ff00);
- QuantizerResult result = QuantizeCelebi(pixels, 256);
- EXPECT_EQ(result.color_to_count.size(), 1u);
- EXPECT_EQ(result.color_to_count[0xff00ff00], 1u);
-}
-
-TEST(CelebiTest, OneBlue) {
- std::vector pixels;
- pixels.push_back(0xff0000ff);
- QuantizerResult result = QuantizeCelebi(pixels, 256);
- EXPECT_EQ(result.color_to_count.size(), 1u);
- EXPECT_EQ(result.color_to_count[0xff0000ff], 1u);
-}
-
-TEST(CelebiTest, FiveBlue) {
- std::vector pixels;
- for (int i = 0; i < 5; i++) {
- pixels.push_back(0xff0000ff);
- }
- QuantizerResult result = QuantizeCelebi(pixels, 256);
- EXPECT_EQ(result.color_to_count.size(), 1u);
- EXPECT_EQ(result.color_to_count[0xff0000ff], 5u);
-}
-
-TEST(CelebiTest, OneRedOneGreenOneBlue) {
- std::vector pixels;
- pixels.push_back(0xffff0000);
- pixels.push_back(0xff00ff00);
- pixels.push_back(0xff0000ff);
- QuantizerResult result = QuantizeCelebi(pixels, 256);
- EXPECT_EQ(result.color_to_count.size(), 3u);
- EXPECT_EQ(result.color_to_count[0xffff0000], 1u);
- EXPECT_EQ(result.color_to_count[0xff00ff00], 1u);
- EXPECT_EQ(result.color_to_count[0xff0000ff], 1u);
-}
-
-TEST(CelebiTest, TwoRedThreeGreen) {
- std::vector pixels;
- pixels.push_back(0xffff0000);
- pixels.push_back(0xffff0000);
- pixels.push_back(0xff00ff00);
- pixels.push_back(0xff00ff00);
- pixels.push_back(0xff00ff00);
- QuantizerResult result = QuantizeCelebi(pixels, 256);
- EXPECT_EQ(result.color_to_count.size(), 2u);
- EXPECT_EQ(result.color_to_count[0xffff0000], 2u);
- EXPECT_EQ(result.color_to_count[0xff00ff00], 3u);
-}
-
-TEST(CelebiTest, NoColors) {
- std::vector pixels;
- pixels.push_back(0xFFFFFFFF);
- QuantizerResult result = QuantizeCelebi(pixels, 0);
- EXPECT_TRUE(result.color_to_count.empty());
- EXPECT_TRUE(result.input_pixel_to_cluster_pixel.empty());
-}
-
-TEST(CelebiTest, SingleTransparent) {
- std::vector pixels;
- pixels.push_back(0x20F93013);
- QuantizerResult result = QuantizeCelebi(pixels, 1);
- EXPECT_TRUE(result.color_to_count.empty());
- EXPECT_TRUE(result.input_pixel_to_cluster_pixel.empty());
-}
-
-TEST(CelebiTest, TooManyColors) {
- std::vector pixels;
- QuantizerResult result = QuantizeCelebi(pixels, 32767);
- EXPECT_TRUE(result.color_to_count.empty());
- EXPECT_TRUE(result.input_pixel_to_cluster_pixel.empty());
-}
-
-} // namespace
-} // namespace material_color_utilities
diff --git a/cpp/quantize/lab.cc b/cpp/quantize/lab.cc
deleted file mode 100644
index caa575b8..00000000
--- a/cpp/quantize/lab.cc
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright 2022 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "cpp/quantize/lab.h"
-
-#include
-
-#include "cpp/utils/utils.h"
-
-namespace material_color_utilities {
-
-Argb IntFromLab(const Lab lab) {
- double e = 216.0 / 24389.0;
- double kappa = 24389.0 / 27.0;
- double ke = 8.0;
-
- double fy = (lab.l + 16.0) / 116.0;
- double fx = (lab.a / 500.0) + fy;
- double fz = fy - (lab.b / 200.0);
- double fx3 = fx * fx * fx;
- double x_normalized = (fx3 > e) ? fx3 : (116.0 * fx - 16.0) / kappa;
- double y_normalized = (lab.l > ke) ? fy * fy * fy : (lab.l / kappa);
- double fz3 = fz * fz * fz;
- double z_normalized = (fz3 > e) ? fz3 : (116.0 * fz - 16.0) / kappa;
- double x = x_normalized * kWhitePointD65[0];
- double y = y_normalized * kWhitePointD65[1];
- double z = z_normalized * kWhitePointD65[2];
-
- // intFromXyz
- double rL = 3.2406 * x - 1.5372 * y - 0.4986 * z;
- double gL = -0.9689 * x + 1.8758 * y + 0.0415 * z;
- double bL = 0.0557 * x - 0.2040 * y + 1.0570 * z;
-
- int red = Delinearized(rL);
- int green = Delinearized(gL);
- int blue = Delinearized(bL);
-
- return ArgbFromRgb(red, green, blue);
-}
-
-Lab LabFromInt(const Argb argb) {
- int red = (argb & 0x00ff0000) >> 16;
- int green = (argb & 0x0000ff00) >> 8;
- int blue = (argb & 0x000000ff);
- double red_l = Linearized(red);
- double green_l = Linearized(green);
- double blue_l = Linearized(blue);
- double x = 0.41233895 * red_l + 0.35762064 * green_l + 0.18051042 * blue_l;
- double y = 0.2126 * red_l + 0.7152 * green_l + 0.0722 * blue_l;
- double z = 0.01932141 * red_l + 0.11916382 * green_l + 0.95034478 * blue_l;
- double y_normalized = y / kWhitePointD65[1];
- double e = 216.0 / 24389.0;
- double kappa = 24389.0 / 27.0;
- double fy;
- if (y_normalized > e) {
- fy = pow(y_normalized, 1.0 / 3.0);
- } else {
- fy = (kappa * y_normalized + 16) / 116;
- }
-
- double x_normalized = x / kWhitePointD65[0];
- double fx;
- if (x_normalized > e) {
- fx = pow(x_normalized, 1.0 / 3.0);
- } else {
- fx = (kappa * x_normalized + 16) / 116;
- }
-
- double z_normalized = z / kWhitePointD65[2];
- double fz;
- if (z_normalized > e) {
- fz = pow(z_normalized, 1.0 / 3.0);
- } else {
- fz = (kappa * z_normalized + 16) / 116;
- }
-
- double l = 116.0 * fy - 16;
- double a = 500.0 * (fx - fy);
- double b = 200.0 * (fy - fz);
- return {l, a, b};
-}
-
-} // namespace material_color_utilities
diff --git a/cpp/quantize/lab.h b/cpp/quantize/lab.h
deleted file mode 100644
index b983c73e..00000000
--- a/cpp/quantize/lab.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright 2022 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef CPP_QUANTIZE_LAB_H_
-#define CPP_QUANTIZE_LAB_H_
-
-#include
-#include
-#include
-#include
-#include