Here you can find the source of RGBAequals(float[] rgba1, float[] rgba2, float eps)
Parameter | Description |
---|---|
rgba1 | first color |
rgba2 | second color |
public static boolean RGBAequals(float[] rgba1, float[] rgba2, float eps)
//package com.java2s; //License from project: BSD License public class Main { /**//from ww w . j av a2 s. c o m * Checks if two colors differ within supplied epsilon. Colors must * have length of at least 3. If only RGB is supplied, the alpha * component is assumed to be one. * @param rgba1 first color * @param rgba2 second color * @return true if any component differs by more than epsilon */ public static boolean RGBAequals(float[] rgba1, float[] rgba2, float eps) { for (int i = 0; i < 3; ++i) { if (Math.abs(rgba1[i] - rgba2[2]) > eps) { return false; } } float a1 = 1; float a2 = 1; if (rgba1.length > 3) { a1 = rgba1[3]; } if (rgba2.length > 3) { a2 = rgba2[3]; } return (Math.abs(a1 - a2) <= eps); } }