• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 package com.google.ux.material.libmonet.scheme;
17 
18 import com.google.ux.material.libmonet.dynamiccolor.DynamicScheme;
19 import com.google.ux.material.libmonet.dynamiccolor.Variant;
20 import com.google.ux.material.libmonet.hct.Hct;
21 import com.google.ux.material.libmonet.palettes.TonalPalette;
22 
23 /** A loud theme, colorfulness is maximum for Primary palette, increased for others. */
24 public class SchemeVibrant extends DynamicScheme {
25   private static final double[] HUES = {0, 41, 61, 101, 131, 181, 251, 301, 360};
26   private static final double[] SECONDARY_ROTATIONS = {18, 15, 10, 12, 15, 18, 15, 12, 12};
27   private static final double[] TERTIARY_ROTATIONS = {35, 30, 20, 25, 30, 35, 30, 25, 25};
28 
SchemeVibrant(Hct sourceColorHct, boolean isDark, double contrastLevel)29   public SchemeVibrant(Hct sourceColorHct, boolean isDark, double contrastLevel) {
30     super(
31         sourceColorHct,
32         Variant.VIBRANT,
33         isDark,
34         contrastLevel,
35         TonalPalette.fromHueAndChroma(sourceColorHct.getHue(), 200.0),
36         TonalPalette.fromHueAndChroma(
37             DynamicScheme.getRotatedHue(sourceColorHct, HUES, SECONDARY_ROTATIONS), 24.0),
38         TonalPalette.fromHueAndChroma(
39             DynamicScheme.getRotatedHue(sourceColorHct, HUES, TERTIARY_ROTATIONS), 32.0),
40         TonalPalette.fromHueAndChroma(sourceColorHct.getHue(), 10.0),
41         TonalPalette.fromHueAndChroma(sourceColorHct.getHue(), 12.0));
42   }
43 }
44