Commit 04cad59e authored by Nico Mack's avatar Nico Mack
Browse files

Initial commit

parent 54558fd1
/**
* Copyright Luxembourg Institute of Science and Technology, 2021. All rights reserved.
*
* This file is part of TULIP.
*
* TULIP is free software: you can redistribute it and/or modify it under the terms of the GNU
* Lesser General Public License as published by the Free Software Foundation, version 3 of the
* License.
*
* TULIP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with TULIP. If
* not, see <http://www.gnu.org/licenses/lgpl-3.0.html>.
*/
package lu.list.itis.dkd.tui.utility;
import java.awt.Color;
/**
* @author nico.mack@list.lu
* @since 2.9
* @version 1.0
*/
// ***************************************************************************
// * Class Definition and Members *
// ***************************************************************************
public class ColorUtils {
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Constructor(s)
// ***************************************************************************
// ---------------------------------------------------------------------------
private ColorUtils() {
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Class Body
// ***************************************************************************
// ---------------------------------------------------------------------------
/**
* @param first
* @param second
* @param epsilon
* @return
*/
// ---------------------------------------------------------------------------
public static boolean areSimilar(Color first, Color second, double epsilon) {
int deltaR = first.getRed() - second.getRed();
int deltaG = first.getGreen() - second.getGreen();
int deltaB = first.getBlue() - second.getBlue();
double distance = (deltaR * deltaR) + (deltaG * deltaG) + (deltaB * deltaB);
return Math.sqrt(distance) <= epsilon;
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * End of Class
// ***************************************************************************
// ---------------------------------------------------------------------------
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment