1 /* 2 * Copyright 2022 Google LLC 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.google.ux.material.libmonet.scheme; 18 19 import com.google.ux.material.libmonet.dynamiccolor.DynamicScheme; 20 import com.google.ux.material.libmonet.dynamiccolor.Variant; 21 import com.google.ux.material.libmonet.hct.Hct; 22 import com.google.ux.material.libmonet.palettes.TonalPalette; 23 import com.google.ux.material.libmonet.utils.MathUtils; 24 25 /** A playful theme - the source color's hue does not appear in the theme. */ 26 public class SchemeExpressive extends DynamicScheme { 27 // NOMUTANTS--arbitrary increments/decrements, correctly, still passes tests. 28 private static final double[] HUES = {0, 21, 51, 121, 151, 191, 271, 321, 360}; 29 private static final double[] SECONDARY_ROTATIONS = {45, 95, 45, 20, 45, 90, 45, 45, 45}; 30 private static final double[] TERTIARY_ROTATIONS = {120, 120, 20, 45, 20, 15, 20, 120, 120}; 31 SchemeExpressive(Hct sourceColorHct, boolean isDark, double contrastLevel)32 public SchemeExpressive(Hct sourceColorHct, boolean isDark, double contrastLevel) { 33 super( 34 sourceColorHct, 35 Variant.EXPRESSIVE, 36 isDark, 37 contrastLevel, 38 TonalPalette.fromHueAndChroma( 39 MathUtils.sanitizeDegreesDouble(sourceColorHct.getHue() + 240.0), 40.0), 40 TonalPalette.fromHueAndChroma( 41 DynamicScheme.getRotatedHue(sourceColorHct, HUES, SECONDARY_ROTATIONS), 24.0), 42 TonalPalette.fromHueAndChroma( 43 DynamicScheme.getRotatedHue(sourceColorHct, HUES, TERTIARY_ROTATIONS), 32.0), 44 TonalPalette.fromHueAndChroma( 45 MathUtils.sanitizeDegreesDouble(sourceColorHct.getHue() + 15.0), 8.0), 46 TonalPalette.fromHueAndChroma( 47 MathUtils.sanitizeDegreesDouble(sourceColorHct.getHue() + 15.0), 12.0)); 48 } 49 } 50