Example usage for com.google.common.primitives Floats max

List of usage examples for com.google.common.primitives Floats max

Introduction

In this page you can find the example usage for com.google.common.primitives Floats max.

Prototype

public static float max(float... array) 

Source Link

Document

Returns the greatest value present in array , using the same rules of comparison as Math#max(float,float) .

Usage

From source file:de.sanandrew.core.manpack.mod.client.gui.GuiColorPickerCtrl.java

@SuppressWarnings("FloatingPointEquality")
public void setHsbFromRgb(int rgb) {
    float[] splitColors = ArrayUtils.remove(SAPUtils.getRgbaFromColorInt(rgb).getColorFloatArray(), 3); // don't need the alpha value (3)

    float max = Floats.max(splitColors);
    float min = Floats.min(splitColors);

    if (max == min) {
        this.hue = 0;
    } else if (max == splitColors[0]) {
        this.hue = Math.round(60.0F * ((splitColors[1] - splitColors[2]) / (max - min)));
    } else if (max == splitColors[1]) {
        this.hue = Math.round(60.0F * (2.0F + (splitColors[2] - splitColors[0]) / (max - min)));
    } else if (max == splitColors[2]) {
        this.hue = Math.round(60.0F * (4.0F + (splitColors[0] - splitColors[1]) / (max - min)));
    }/*www  . j  a va2 s  .co m*/

    if (this.hue < 0) {
        this.hue += 360;
    }

    if (max <= 0.01F) {
        this.sat = 0;
    } else {
        this.sat = Math.round((max - min) / max * 100.0F);
    }

    this.bright = Math.round(max * 100.0F);

    this.calcResultColor();
}

From source file:hmi.math.Vecf.java

public static double max(float a[]) {
    return Floats.max(a);
}