Java Color Lighten lighter(final Color color, final int rgbOffset)

Here you can find the source of lighter(final Color color, final int rgbOffset)

Description

Returns a lighter version of the given color.

License

Apache License

Parameter

Parameter Description
color Base color to use.
rgbOffset Offset by which the color should be lightened.

Return

a lighter version of the given color.

Declaration

public static Color lighter(final Color color, final int rgbOffset) 

Method Source Code

//package com.java2s;
/**//www. ja  va  2 s . c o m
 * This class offers a few utility methods useful when handling Colors.
 * <p/>
 * <hr/> Copyright 2006-2012 Torsten Heup
 * <p/>
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * <p/>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p/>
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations under the License.
 */

import java.awt.*;

public class Main {
    /**
     * Returns a lighter version of the given color.
     *
     * @param color     Base color to use.
     * @param rgbOffset Offset by which the color should be lightened.
     * @return a lighter version of the given color.
     */
    public static Color lighter(final Color color, final int rgbOffset) {
        if (color == null)
            throw new IllegalArgumentException("Parameter 'color' must not be null!");
        final int red = Math.min(color.getRed() + rgbOffset, 255);
        final int green = Math.min(color.getGreen() + rgbOffset, 255);
        final int blue = Math.min(color.getBlue() + rgbOffset, 255);
        return new Color(red, green, blue, color.getAlpha());
    }
}

Related

  1. lighter(Color c, float factor)
  2. lighter(Color clr)
  3. lighter(Color clr, double saturationFraction)
  4. lighter(Color color, double fraction)
  5. lighter(Color color, float ratio)
  6. lighter(final Color color, float factor)
  7. lighterColor(Color c, double amount)
  8. lighterColor(Color lineColor, int adj)