Ejemplo n.º 1
0
  public static ArrayList<GCPoweredColor> convertShortenedColorStringToColorList(
      String shortenedColorString) {
    ArrayList<GCPoweredColor> colorList = new ArrayList<>();

    List<String> stringParts = getParts(shortenedColorString, 3);

    for (String colorAbbrev : stringParts) {
      try {
        String colorString = colorAbbrev.substring(0, 2);
        String powerString = colorAbbrev.substring(2, 3);
        GCColor color = GCColorUtil.getColorUsingAbbrev(colorString);
        GCPowerLevel powerLevel = GCPowerLevelUtil.getPowerLevelUsingAbbrev(powerString);
        colorList.add(new GCPoweredColor(color, powerLevel.getTitle()));
      } catch (Exception e) {
        return null;
      }
    }

    return colorList;
  }
Ejemplo n.º 2
0
  public static int[] convertRgbToPowerLevel(int[] originalRgb, GCPowerLevel powerLevel) {
    int[] newRgbValues = new int[3];

    float[] hsv = new float[3];
    Color.RGBToHSV(originalRgb[0], originalRgb[1], originalRgb[2], hsv);

    hsv[1] = hsv[1] * powerLevel.getValue();

    int outputColor = Color.HSVToColor(hsv);
    newRgbValues[0] = Color.red(outputColor);
    newRgbValues[1] = Color.green(outputColor);
    newRgbValues[2] = Color.blue(outputColor);

    return newRgbValues;
  }