<commit_before>/*******************************************************************************
 * Copyright 2010 <NAME> (<EMAIL>)
 * 
 * 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
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * 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.
 ******************************************************************************/
package com.badlogic.gdx.graphics;


/**
 * A color class, holding the r, g, b and alpha component
 * as floats in the range [0,1]. All methods perform clamping
 * on the internal values after execution. 
 * 
 * @author mzechner
 *
 */
public class Color 
{
	public static final Color WHITE = new Color( 1, 1, 1, 1 );
	public static final Color BLACK = new Color( 0, 0, 0, 1 );
	public static final Color RED = new Color( 1, 0, 0, 1 );
	public static final Color GREEN = new Color( 0, 1, 0, 1 );
	public static final Color BLUE = new Color( 0, 0, 1, 1 );
	
	/** the red, green, blue and alpha components **/
	public float r, g, b, a;
	
	/**
	 * Constructor, sets the components of the color
	 * @param r the red component
	 * @param g the green component
	 * @param b the blue component
	 * @param a the alpha component
	 */
	public Color( float r, float g, float b, float a )
	{
		this.r = r;
		this.g = g;
		this.b = b;
		this.a = a;
		clamp();
	}

	/**
	 * Constructs a new color using the given color
	 * @param color the color
	 */
	public Color( Color color )
	{
		set( color );
	}
	
	/**
	 * Sets this color to the given color.
	 * @param color the Color
	 */
	public Color set( Color color )
	{
		this.r = color.r;
		this.g = color.g;
		this.b = color.b;
		this.a = color.a;
		clamp();
		return this;
	}
	
	/**
	 * Multiplies the this color and the given color
	 * @param color the color
	 * @return this color.
	 */
	public Color mul( Color color )
	{
		this.r *= color.r;
		this.g *= color.g;
		this.b *= color.b;
		this.a *= color.a;
		clamp();
		return this;
	}

	/**
	 * Multiplies all components of this Color with the given value. 
	 * 
	 * @param value the value
	 * @return this color
	 */
	public Color mul(float value) 
	{	
		this.r *= value;
		this.g *= value;
		this.b *= value;
		this.a *= value;
		clamp();
		return this;
	}
	
	/**
	 * Adds the given color to this color.
	 * @param color the color
	 * @return this color
	 */
	public Color add( Color color )
	{
		this.r += color.r;
		this.g += color.g;
		this.b += color.b;
		this.a += color.a;		
		clamp();
		return this;
	}

	/**
	 * Subtracts the given color from this color
	 * @param color the color
	 * @return this color
	 */
	public Color sub(Color color) 
	{	
		this.r -= color.r;
		this.g -= color.g;
		this.b -= color.b;
		this.a -= color.a;
		clamp();
		return this;
	}
	
	private void clamp( )
	{
		if( r < 0 ) r = 0; <commit_msg>[changed] Color.clamp() ist public now<commit_after>/*******************************************************************************
 * Copyright 2010 Mario Zechner (<EMAIL>)
 * 
 * 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
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * 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.
 ******************************************************************************/
package com.badlogic.gdx.graphics;


/**
 * A color class, holding the r, g, b and alpha component
 * as floats in the range [0,1]. All methods perform clamping
 * on the internal values after execution. 
 * 
 * @author mzechner
 *
 */
public class Color 
{
	public static final Color WHITE = new Color( 1, 1, 1, 1 );
	public static final Color BLACK = new Color( 0, 0, 0, 1 );
	public static final Color RED = new Color( 1, 0, 0, 1 );
	public static final Color GREEN = new Color( 0, 1, 0, 1 );
	public static final Color BLUE = new Color( 0, 0, 1, 1 );
	
	/** the red, green, blue and alpha components **/
	public float r, g, b, a;
	
	/**
	 * Constructor, sets the components of the color
	 * @param r the red component
	 * @param g the green component
	 * @param b the blue component
	 * @param a the alpha component
	 */
	public Color( float r, float g, float b, float a )
	{
		this.r = r;
		this.g = g;
		this.b = b;
		this.a = a;
		clamp();
	}

	/**
	 * Constructs a new color using the given color
	 * @param color the color
	 */
	public Color( Color color )
	{
		set( color );
	}
	
	/**
	 * Sets this color to the given color.
	 * @param color the Color
	 */
	public Color set( Color color )
	{
		this.r = color.r;
		this.g = color.g;
		this.b = color.b;
		this.a = color.a;
		clamp();
		return this;
	}
	
	/**
	 * Multiplies the this color and the given color
	 * @param color the color
	 * @return this color.
	 */
	public Color mul( Color color )
	{
		this.r *= color.r;
		this.g *= color.g;
		this.b *= color.b;
		this.a *= color.a;
		clamp();
		return this;
	}

	/**
	 * Multiplies all components of this Color with the given value. 
	 * 
	 * @param value the value
	 * @return this color
	 */
	public Color mul(float value) 
	{	
		this.r *= value;
		this.g *= value;
		this.b *= value;
		this.a *= value;
		clamp();
		return this;
	}
	
	/**
	 * Adds the given color to this color.
	 * @param color the color
	 * @return this color
	 */
	public Color add( Color color )
	{
		this.r += color.r;
		this.g += color.g;
		this.b += color.b;
		this.a += color.a;		
		clamp();
		return this;
	}

	/**
	 * Subtracts the given color from this color
	 * @param color the color
	 * @return this color
	 */
	public Color sub(Color color) 
	{	
		this.r -= color.r;
		this.g -= color.g;
		this.b -= color.b;
		this.a -= color.a;
		clamp();
		return this;
	}
	
	public void clamp( )
	{
		if( r < 0 ) r = 0; 
{'fraction_non_alphanumeric': 0.16336401934779216, 'fraction_numerical': 0.009985957247620534, 'mean_word_length': 2.8268656716417913, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5441128', 'n_tokens_mistral': 2269, 'n_tokens_neox': 2005, 'n_words': 817}