distance between two Color value - Java 2D Graphics

Java examples for 2D Graphics:Color

Description

distance between two Color value

Demo Code


//package com.java2s;
import java.awt.Color;

public class Main {
    public static int dist(final Color c1, final Color c2) {
        final int r = Math.abs(c1.getRed() - c2.getRed());
        final int g = Math.abs(c1.getGreen() - c2.getGreen());
        final int b = Math.abs(c1.getBlue() - c2.getBlue());
        return (r + g + b) / 3;
    }//  w ww  . java2 s. c o m
}

Related Tutorials