• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2021 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.utils;
18 
19 /** Utility methods for string representations of colors. */
20 final class StringUtils {
StringUtils()21   private StringUtils() {}
22 
23   /**
24    * Hex string representing color, ex. #ff0000 for red.
25    *
26    * @param argb ARGB representation of a color.
27    */
hexFromArgb(int argb)28   public static String hexFromArgb(int argb) {
29     int red = ColorUtils.redFromArgb(argb);
30     int blue = ColorUtils.blueFromArgb(argb);
31     int green = ColorUtils.greenFromArgb(argb);
32     return String.format("#%02x%02x%02x", red, green, blue);
33   }
34 }
35