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

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

Introduction

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

Prototype

public static float min(float... array) 

Source Link

Document

Returns the least value present in array , using the same rules of comparison as Math#min(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)));
    }/*  w  ww .  j a v  a  2  s .  c o  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 min(float a[]) {
    return Floats.min(a);
}