The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Color</title>
<base target="class-frame">
<link href="../assets/css/docs.css" rel="stylesheet" type="text/css">
<script src="../assets/js/paper.js"></script>
<script src="../assets/js/jquery.js"></script>
<script src="../assets/js/codemirror.js"></script>
<script src="../assets/js/docs.js"></script>
</head>
<body class="reference">
<div class="reference-class">
<h1>Color</h1>

<p>All properties and functions that expect color values in the form
of instances of Color objects, also accept named colors and hex values as
strings which are then converted to instances of
<a href="../classes/Color.html"><tt>Color</tt></a> internally.</p>
<p>
<b>Example</b> &mdash; Named color values:
</p>

<div class="paperscript split">

<div class="buttons">
<div class="button run">Run</div>
</div>

<script type="text/paperscript" canvas="canvas-0">
// Create a circle shaped path at {x: 80, y: 50}
// with a radius of 30.
var circle = new Path.Circle(new Point(80, 50), 30);

// Pass a color name to the fillColor property, which is internally
// converted to a Color.
circle.fillColor = 'green';
</script>
<div class="canvas"><canvas width="516" height="100" id="canvas-0"></canvas></div>
</div>


<p>
<b>Example</b> &mdash; Hex color values:
</p>

<div class="paperscript split">

<div class="buttons">
<div class="button run">Run</div>
</div>

<script type="text/paperscript" canvas="canvas-1">
// Create a circle shaped path at {x: 80, y: 50}
// with a radius of 30.
var circle = new Path.Circle(new Point(80, 50), 30);

// Pass a hex string to the fillColor property, which is internally
// converted to a Color.
circle.fillColor = '#ff0000';
</script>
<div class="canvas"><canvas width="516" height="100" id="canvas-1"></canvas></div>
</div>


</div>

<!-- ============================== constructors ========================= -->
<div class="reference-members"><h2>Constructors</h2>
	
		
<div id="color-red-green-blue" class="member">
<div class="member-link">
<a name="color-red-green-blue" href="#color-red-green-blue"><tt><b>Color</b>(red, green, blue[, alpha])</tt></a>
</div>
<div class="member-description hidden">
<div class="member-text">
<p>Creates a RGB Color object.</p>

<ul><b>Parameters:</b>

<li>
<tt>red:</tt> 
<tt>Number</tt>
&mdash;&nbsp;the amount of red in the color as a value
between <tt>0</tt> and <tt>1</tt>

</li>

<li>
<tt>green:</tt> 
<tt>Number</tt>
&mdash;&nbsp;the amount of green in the color as a value
between <tt>0</tt> and <tt>1</tt>

</li>

<li>
<tt>blue:</tt> 
<tt>Number</tt>
&mdash;&nbsp;the amount of blue in the color as a value
between <tt>0</tt> and <tt>1</tt>

</li>

<li>
<tt>alpha:</tt> 
<tt>Number</tt>
&mdash;&nbsp;the alpha of the color as a value between
<tt>0</tt> and <tt>1</tt>
&mdash;&nbsp;optional
</li>

</ul>


<p>
<b>Example</b> &mdash; Creating a RGB Color:
</p>

<div class="paperscript split">

<div class="buttons">
<div class="button run">Run</div>
</div>

<script type="text/paperscript" canvas="canvas-2">
// Create a circle shaped path at {x: 80, y: 50}
// with a radius of 30:
var circle = new Path.Circle(new Point(80, 50), 30);

// 100% red, 0% blue, 50% blue:
circle.fillColor = new Color(1, 0, 0.5);
</script>
<div class="canvas"><canvas width="516" height="100" id="canvas-2"></canvas></div>
</div>



</div>
</div>
</div>
	
		
<div id="color-gray" class="member">
<div class="member-link">
<a name="color-gray" href="#color-gray"><tt><b>Color</b>(gray[, alpha])</tt></a>
</div>
<div class="member-description hidden">
<div class="member-text">
<p>Creates a gray Color object.</p>

<ul><b>Parameters:</b>

<li>
<tt>gray:</tt> 
<tt>Number</tt>
&mdash;&nbsp;the amount of gray in the color as a value
between <tt>0</tt> and <tt>1</tt>

</li>

<li>
<tt>alpha:</tt> 
<tt>Number</tt>
&mdash;&nbsp;the alpha of the color as a value between
<tt>0</tt> and <tt>1</tt>
&mdash;&nbsp;optional
</li>

</ul>


<p>
<b>Example</b> &mdash; Creating a gray Color:
</p>

<div class="paperscript split">

<div class="buttons">
<div class="button run">Run</div>
</div>

<script type="text/paperscript" canvas="canvas-3">
// Create a circle shaped path at {x: 80, y: 50}
// with a radius of 30:
var circle = new Path.Circle(new Point(80, 50), 30);

// Create a GrayColor with 50% gray:
circle.fillColor = new Color(0.5);
</script>
<div class="canvas"><canvas width="516" height="100" id="canvas-3"></canvas></div>
</div>



</div>
</div>
</div>
	
		
<div id="color-object" class="member">
<div class="member-link">
<a name="color-object" href="#color-object"><tt><b>Color</b>(object)</tt></a>
</div>
<div class="member-description hidden">
<div class="member-text">
<p>Creates a HSB, HSL or gradient Color object from the properties of
the provided object:</p>
<p><b>HSB Color</b>:<br>
<tt>hue: Number</tt> — the hue of the color as a value in
degrees between <tt>0</tt> and <tt>360</tt><br>
<tt>saturation: Number</tt> — the saturation of the color as a
value between <tt>0</tt> and <tt>1</tt><br>
<tt>brightness: Number</tt> — the brightness of the color as a
value between <tt>0</tt> and <tt>1</tt><br>
<tt>alpha: Number</tt> — the alpha of the color as a value between
<tt>0</tt> and <tt>1</tt></p>
<p><b>HSL Color</b>:<br>
<tt>hue: Number</tt> — the hue of the color as a value in
degrees between <tt>0</tt> and <tt>360</tt><br>
<tt>saturation: Number</tt> — the saturation of the color as a
value between <tt>0</tt> and <tt>1</tt><br>
<tt>lightness: Number</tt> — the lightness of the color as a
value between <tt>0</tt> and <tt>1</tt><br>
<tt>alpha: Number</tt> — the alpha of the color as a value between
<tt>0</tt> and <tt>1</tt></p>
<p><b>Gradient Color</b>:<br>
<tt>gradient: Gradient</tt> — the gradient object that describes the
 color stops and type of gradient to be used.<br>
<tt>origin: Point</tt> — the origin point of the gradient<br>
<tt>destination: Point</tt> — the destination point of the gradient
<tt>stops: Array of GradientStop</tt> — the gradient stops describing
the gradient, as an alternative to providing a gradient object<br>
<tt>radial: Boolean</tt> — controls whether the gradient is radial,
as an alternative to providing a gradient object<br></p>

<ul><b>Parameters:</b>

<li>
<tt>object:</tt> 
<tt>Object</tt>
&mdash;&nbsp;an object describing the components and
       properties of the color.

</li>

</ul>


<p>
<b>Example</b> &mdash; Creating a HSB Color:
</p>

<div class="paperscript split">

<div class="buttons">
<div class="button run">Run</div>
</div>

<script type="text/paperscript" canvas="canvas-4">
// Create a circle shaped path at {x: 80, y: 50}
// with a radius of 30:
var circle = new Path.Circle(new Point(80, 50), 30);

// Create an HSB Color with a hue of 90 degrees, a saturation
// 100% and a brightness of 100%:
circle.fillColor = { hue: 90, saturation: 1, brightness: 1 };
</script>
<div class="canvas"><canvas width="516" height="100" id="canvas-4"></canvas></div>
</div>


<p>
<b>Example</b> &mdash; Creating a HSL Color:
</p>

<div class="paperscript split">

<div class="buttons">
<div class="button run">Run</div>
</div>

<script type="text/paperscript" canvas="canvas-5">
// Create a circle shaped path at {x: 80, y: 50}
// with a radius of 30:
var circle = new Path.Circle(new Point(80, 50), 30);

// Create an HSL Color with a hue of 90 degrees, a saturation
// 100% and a lightness of 50%:
circle.fillColor = { hue: 90, saturation: 1, lightness: 0.5 };
</script>
<div class="canvas"><canvas width="516" height="100" id="canvas-5"></canvas></div>
</div>


<p>
<b>Example</b> &mdash; Creating a gradient color from an object literal:
</p>

<div class="paperscript split">

<div class="buttons">
<div class="button run">Run</div>
</div>

<script type="text/paperscript" canvas="canvas-6">
// Define two points which we will be using to construct
// the path and to position the gradient color:
var topLeft = view.center - [80, 80];
var bottomRight = view.center + [80, 80];

var path = new Path.Rectangle({
	topLeft: topLeft,
	bottomRight: bottomRight,
	// Fill the path with a gradient of three color stops
	// that runs between the two points we defined earlier:
	fillColor: {
		stops: ['yellow', 'red', 'blue'],
		origin: topLeft,
		destination: bottomRight
	}
});
</script>
<div class="canvas"><canvas width="516" height="200" id="canvas-6"></canvas></div>
</div>



</div>
</div>
</div>
	
		
<div id="color-gradient-origin-destination" class="member">
<div class="member-link">
<a name="color-gradient-origin-destination" href="#color-gradient-origin-destination"><tt><b>Color</b>(gradient, origin, destination[, highlight])</tt></a>
</div>
<div class="member-description hidden">
<div class="member-text">
<p>Creates a gradient Color object.</p>

<ul><b>Parameters:</b>

<li>
<tt>gradient:</tt> 
<a href="../classes/Gradient.html"><tt>Gradient</tt></a>


</li>

<li>
<tt>origin:</tt> 
<a href="../classes/Point.html"><tt>Point</tt></a>


</li>

<li>
<tt>destination:</tt> 
<a href="../classes/Point.html"><tt>Point</tt></a>


</li>

<li>
<tt>highlight:</tt> 
<a href="../classes/Point.html"><tt>Point</tt></a>

&mdash;&nbsp;optional
</li>

</ul>


<p>
<b>Example</b> &mdash; Applying a linear gradient color containing evenly distributed color stops:
</p>

<div class="paperscript split">

<div class="buttons">
<div class="button run">Run</div>
</div>

<script type="text/paperscript" canvas="canvas-7">
// Define two points which we will be using to construct
// the path and to position the gradient color:
var topLeft = view.center - [80, 80];
var bottomRight = view.center + [80, 80];

// Create a rectangle shaped path between
// the topLeft and bottomRight points:
var path = new Path.Rectangle(topLeft, bottomRight);

// Create the gradient, passing it an array of colors to be converted
// to evenly distributed color stops:
var gradient = new Gradient(['yellow', 'red', 'blue']);

// Have the gradient color run between the topLeft and
// bottomRight points we defined earlier:
var gradientColor = new Color(gradient, topLeft, bottomRight);

// Set the fill color of the path to the gradient color:
path.fillColor = gradientColor;
</script>
<div class="canvas"><canvas width="516" height="200" id="canvas-7"></canvas></div>
</div>


<p>
<b>Example</b> &mdash; Applying a radial gradient color containing unevenly distributed color stops:
</p>

<div class="paperscript split">

<div class="buttons">
<div class="button run">Run</div>
</div>

<script type="text/paperscript" canvas="canvas-8">
// Create a circle shaped path at the center of the view
// with a radius of 80:
var path = new Path.Circle({
    center: view.center,
    radius: 80
});

// The stops array: yellow mixes with red between 0 and 15%,
// 15% to 30% is pure red, red mixes with black between 30% to 100%:
var stops = [
    ['yellow', 0],
    ['red', 0.15],
    ['red', 0.3],
    ['black', 0.9]
];

// Create a radial gradient using the color stops array:
var gradient = new Gradient(stops, true);

// We will use the center point of the circle shaped path as
// the origin point for our gradient color
var from = path.position;

// The destination point of the gradient color will be the
// center point of the path + 80pt in horizontal direction:
var to = path.position + [80, 0];

// Create the gradient color:
var gradientColor = new Color(gradient, from, to);

// Set the fill color of the path to the gradient color:
path.fillColor = gradientColor;
</script>
<div class="canvas"><canvas width="516" height="200" id="canvas-8"></canvas></div>
</div>



</div>
</div>
</div>
	
</div>



<!-- ============================== properties ========================= -->
	<div class="reference-members"><h2>Operators</h2>
		
			<div id="add" class="member">
<div class="member-link">
<a name="add" href="#add"><tt><tt><b>+</b> Number</tt>, <tt><b>+</b> Color</tt></tt></a>
</div>
<div class="member-description hidden">


	<div class="member-text">
		<p>Returns the addition of the supplied value to both coordinates of
the color as a new color.</p>
<p>The object itself is not modified!</p>
		
	<ul><b>Returns:</b>
	
		<li>
<tt><a href="../classes/Color.html"><tt>Color</tt></a></tt>&nbsp;&mdash;&nbsp;the addition of the color and the value as a new
color
</li>
	
	</ul>

		
		<p>
<b>Example</b> 
</p>


<pre class="code">var color = new Color(0.5, 1, 1);
var result = color + 1;
console.log(result); // { red: 1, blue: 1, green: 1 }</pre>

	</div>



	<div class="member-text">
		<p>Returns the addition of the supplied color to the color as a new
color.</p>
<p>The object itself is not modified!</p>
		
	<ul><b>Returns:</b>
	
		<li>
<tt><a href="../classes/Color.html"><tt>Color</tt></a></tt>&nbsp;&mdash;&nbsp;the addition of the two colors as a new color
</li>
	
	</ul>

		
		<p>
<b>Example</b> 
</p>


<pre class="code">var color1 = new Color(0, 1, 1);
var color2 = new Color(1, 0, 0);
var result = color1 + color2;
console.log(result); // { red: 1, blue: 1, green: 1 }</pre>

	</div>


</div>
</div>

		
			<div id="subtract" class="member">
<div class="member-link">
<a name="subtract" href="#subtract"><tt><tt><b>-</b> Number</tt>, <tt><b>-</b> Color</tt></tt></a>
</div>
<div class="member-description hidden">


	<div class="member-text">
		<p>Returns the subtraction of the supplied value to both coordinates of
the color as a new color.</p>
<p>The object itself is not modified!</p>
		
	<ul><b>Returns:</b>
	
		<li>
<tt><a href="../classes/Color.html"><tt>Color</tt></a></tt>&nbsp;&mdash;&nbsp;the subtraction of the color and the value as a new
        color
</li>
	
	</ul>

		
		<p>
<b>Example</b> 
</p>


<pre class="code">var color = new Color(0.5, 1, 1);
var result = color - 1;
console.log(result); // { red: 0, blue: 0, green: 0 }</pre>

	</div>



	<div class="member-text">
		<p>Returns the subtraction of the supplied color to the color as a new
color.</p>
<p>The object itself is not modified!</p>
		
	<ul><b>Returns:</b>
	
		<li>
<tt><a href="../classes/Color.html"><tt>Color</tt></a></tt>&nbsp;&mdash;&nbsp;the subtraction of the two colors as a new color
</li>
	
	</ul>

		
		<p>
<b>Example</b> 
</p>


<pre class="code">var color1 = new Color(0, 1, 1);
var color2 = new Color(1, 0, 0);
var result = color1 - color2;
console.log(result); // { red: 0, blue: 1, green: 1 }</pre>

	</div>


</div>
</div>

		
			<div id="multiply" class="member">
<div class="member-link">
<a name="multiply" href="#multiply"><tt><tt><b>*</b> Number</tt>, <tt><b>*</b> Color</tt></tt></a>
</div>
<div class="member-description hidden">


	<div class="member-text">
		<p>Returns the multiplication of the supplied value to both coordinates
of the color as a new color.</p>
<p>The object itself is not modified!</p>
		
	<ul><b>Returns:</b>
	
		<li>
<tt><a href="../classes/Color.html"><tt>Color</tt></a></tt>&nbsp;&mdash;&nbsp;the multiplication of the color and the value as a
        new color
</li>
	
	</ul>

		
		<p>
<b>Example</b> 
</p>


<pre class="code">var color = new Color(0.5, 1, 1);
var result = color * 0.5;
console.log(result); // { red: 0.25, blue: 0.5, green: 0.5 }</pre>

	</div>



	<div class="member-text">
		<p>Returns the multiplication of the supplied color to the color as a
new color.</p>
<p>The object itself is not modified!</p>
		
	<ul><b>Returns:</b>
	
		<li>
<tt><a href="../classes/Color.html"><tt>Color</tt></a></tt>&nbsp;&mdash;&nbsp;the multiplication of the two colors as a new color
</li>
	
	</ul>

		
		<p>
<b>Example</b> 
</p>


<pre class="code">var color1 = new Color(0, 1, 1);
var color2 = new Color(0.5, 0, 0.5);
var result = color1 * color2;
console.log(result); // { red: 0, blue: 0, green: 0.5 }</pre>

	</div>


</div>
</div>

		
			<div id="divide" class="member">
<div class="member-link">
<a name="divide" href="#divide"><tt><tt><b>/</b> Number</tt>, <tt><b>/</b> Color</tt></tt></a>
</div>
<div class="member-description hidden">


	<div class="member-text">
		<p>Returns the division of the supplied value to both coordinates of
the color as a new color.</p>
<p>The object itself is not modified!</p>
		
	<ul><b>Returns:</b>
	
		<li>
<tt><a href="../classes/Color.html"><tt>Color</tt></a></tt>&nbsp;&mdash;&nbsp;the division of the color and the value as a new
        color
</li>
	
	</ul>

		
		<p>
<b>Example</b> 
</p>


<pre class="code">var color = new Color(0.5, 1, 1);
var result = color / 2;
console.log(result); // { red: 0.25, blue: 0.5, green: 0.5 }</pre>

	</div>



	<div class="member-text">
		<p>Returns the division of the supplied color to the color as a new
color.</p>
<p>The object itself is not modified!</p>
		
	<ul><b>Returns:</b>
	
		<li>
<tt><a href="../classes/Color.html"><tt>Color</tt></a></tt>&nbsp;&mdash;&nbsp;the division of the two colors as a new color
</li>
	
	</ul>

		
		<p>
<b>Example</b> 
</p>


<pre class="code">var color1 = new Color(0, 1, 1);
var color2 = new Color(0.5, 0, 0.5);
var result = color1 / color2;
console.log(result); // { red: 0, blue: 0, green: 1 }</pre>

	</div>


</div>
</div>

		
	</div>



	<div class="reference-members"><h2>Properties</h2>
		
			
<div id="type" class="member">
<div class="member-link">
<a name="type" href="#type"><tt><b>type</b></tt></a>
</div>
<div class="member-description hidden">

<div class="member-text">
	<p>The type of the color as a string.</p>
	
	
	<ul><b>Type:</b>
	<li>
		<tt>String('rgb', 'gray', 'hsb', 'hsl')</tt>
	</li>
	</ul>
	
	<p>
<b>Example</b> 
</p>


<pre class="code">var color = new Color(1, 0, 0);
console.log(color.type); // 'rgb'</pre>

</div>

</div>
</div>
		
			
<div id="components" class="member">
<div class="member-link">
<a name="components" href="#components"><tt><b>components</b></tt></a>
</div>
<div class="member-description hidden">

<div class="member-text">
	<p>The color components that define the color, including the alpha value
if defined.</p>
	
		<p>Read only.</p>
	
	
	<ul><b>Type:</b>
	<li>
		<tt>Number</tt>
	</li>
	</ul>
	
	
</div>

</div>
</div>
		
			
<div id="alpha" class="member">
<div class="member-link">
<a name="alpha" href="#alpha"><tt><b>alpha</b></tt></a>
</div>
<div class="member-description hidden">

<div class="member-text">
	<p>The color's alpha value as a number between <tt>0</tt> and <tt>1</tt>.</p>
<p>All colors of the different subclasses support alpha values.</p>
	
	
	<ul><b>Type:</b>
	<li>
		<tt>Number</tt>
	</li>
	</ul>
	
	<p>
<b>Example</b> &mdash; A filled path with a half transparent stroke:
</p>

<div class="paperscript split">

<div class="buttons">
<div class="button run">Run</div>
</div>

<script type="text/paperscript" canvas="canvas-9">
var circle = new Path.Circle(new Point(80, 50), 30);

// Fill the circle with red and give it a 20pt green stroke:
circle.style = {
	fillColor: 'red',
	strokeColor: 'green',
	strokeWidth: 20
};

// Make the stroke half transparent:
circle.strokeColor.alpha = 0.5;
</script>
<div class="canvas"><canvas width="516" height="100" id="canvas-9"></canvas></div>
</div>


</div>

</div>
</div>
		
			
	<h3>RGB Components</h3>

<div id="red" class="member">
<div class="member-link">
<a name="red" href="#red"><tt><b>red</b></tt></a>
</div>
<div class="member-description hidden">

<div class="member-text">
	<p>The amount of red in the color as a value between <tt>0</tt> and
<tt>1</tt>.</p>
	
	
	<ul><b>Type:</b>
	<li>
		<tt>Number</tt>
	</li>
	</ul>
	
	<p>
<b>Example</b> &mdash; Changing the amount of red in a color:
</p>

<div class="paperscript split">

<div class="buttons">
<div class="button run">Run</div>
</div>

<script type="text/paperscript" canvas="canvas-10">
var circle = new Path.Circle(new Point(80, 50), 30);
circle.fillColor = 'blue';

// Blue + red = purple:
circle.fillColor.red = 1;
</script>
<div class="canvas"><canvas width="516" height="100" id="canvas-10"></canvas></div>
</div>


</div>

</div>
</div>
		
			
<div id="green" class="member">
<div class="member-link">
<a name="green" href="#green"><tt><b>green</b></tt></a>
</div>
<div class="member-description hidden">

<div class="member-text">
	<p>The amount of green in the color as a value between <tt>0</tt> and
<tt>1</tt>.</p>
	
	
	<ul><b>Type:</b>
	<li>
		<tt>Number</tt>
	</li>
	</ul>
	
	<p>
<b>Example</b> &mdash; Changing the amount of green in a color:
</p>

<div class="paperscript split">

<div class="buttons">
<div class="button run">Run</div>
</div>

<script type="text/paperscript" canvas="canvas-11">
var circle = new Path.Circle(new Point(80, 50), 30);

// First we set the fill color to red:
circle.fillColor = 'red';

// Red + green = yellow:
circle.fillColor.green = 1;
</script>
<div class="canvas"><canvas width="516" height="100" id="canvas-11"></canvas></div>
</div>


</div>

</div>
</div>
		
			
<div id="blue" class="member">
<div class="member-link">
<a name="blue" href="#blue"><tt><b>blue</b></tt></a>
</div>
<div class="member-description hidden">

<div class="member-text">
	<p>The amount of blue in the color as a value between <tt>0</tt> and
<tt>1</tt>.</p>
	
	
	<ul><b>Type:</b>
	<li>
		<tt>Number</tt>
	</li>
	</ul>
	
	<p>
<b>Example</b> &mdash; Changing the amount of blue in a color:
</p>

<div class="paperscript split">

<div class="buttons">
<div class="button run">Run</div>
</div>

<script type="text/paperscript" canvas="canvas-12">
var circle = new Path.Circle(new Point(80, 50), 30);

// First we set the fill color to red:
circle.fillColor = 'red';

// Red + blue = purple:
circle.fillColor.blue = 1;
</script>
<div class="canvas"><canvas width="516" height="100" id="canvas-12"></canvas></div>
</div>


</div>

</div>
</div>
		
			
	<h3>Gray Components</h3>

<div id="gray" class="member">
<div class="member-link">
<a name="gray" href="#gray"><tt><b>gray</b></tt></a>
</div>
<div class="member-description hidden">

<div class="member-text">
	<p>The amount of gray in the color as a value between <tt>0</tt> and
<tt>1</tt>.</p>
	
	
	<ul><b>Type:</b>
	<li>
		<tt>Number</tt>
	</li>
	</ul>
	
	
</div>

</div>
</div>
		
			
	<h3>HSB Components</h3>

<div id="hue" class="member">
<div class="member-link">
<a name="hue" href="#hue"><tt><b>hue</b></tt></a>
</div>
<div class="member-description hidden">

<div class="member-text">
	<p>The hue of the color as a value in degrees between <tt>0</tt> and
<tt>360</tt>.</p>
	
	
	<ul><b>Type:</b>
	<li>
		<tt>Number</tt>
	</li>
	</ul>
	
	<p>
<b>Example</b> &mdash; Changing the hue of a color:
</p>

<div class="paperscript split">

<div class="buttons">
<div class="button run">Run</div>
</div>

<script type="text/paperscript" canvas="canvas-13">
var circle = new Path.Circle(new Point(80, 50), 30);
circle.fillColor = 'red';
circle.fillColor.hue += 30;
</script>
<div class="canvas"><canvas width="516" height="100" id="canvas-13"></canvas></div>
</div>


<p>
<b>Example</b> &mdash; Hue cycling:
</p>

<div class="paperscript split">

<div class="buttons">
<div class="button run">Run</div>
</div>

<script type="text/paperscript" canvas="canvas-14">
// Create a rectangle shaped path, using the dimensions
// of the view:
var path = new Path.Rectangle(view.bounds);
path.fillColor = 'red';

function onFrame(event) {
	path.fillColor.hue += 0.5;
}
</script>
<div class="canvas"><canvas width="516" height="100" id="canvas-14"></canvas></div>
</div>


</div>

</div>
</div>
		
			
<div id="saturation" class="member">
<div class="member-link">
<a name="saturation" href="#saturation"><tt><b>saturation</b></tt></a>
</div>
<div class="member-description hidden">

<div class="member-text">
	<p>The saturation of the color as a value between <tt>0</tt> and
<tt>1</tt>.</p>
	
	
	<ul><b>Type:</b>
	<li>
		<tt>Number</tt>
	</li>
	</ul>
	
	
</div>

</div>
</div>
		
			
<div id="brightness" class="member">
<div class="member-link">
<a name="brightness" href="#brightness"><tt><b>brightness</b></tt></a>
</div>
<div class="member-description hidden">

<div class="member-text">
	<p>The brightness of the color as a value between <tt>0</tt> and
<tt>1</tt>.</p>
	
	
	<ul><b>Type:</b>
	<li>
		<tt>Number</tt>
	</li>
	</ul>
	
	
</div>

</div>
</div>
		
			
	<h3>HSL Components</h3>

<div id="lightness" class="member">
<div class="member-link">
<a name="lightness" href="#lightness"><tt><b>lightness</b></tt></a>
</div>
<div class="member-description hidden">

<div class="member-text">
	<p>The lightness of the color as a value between <tt>0</tt> and
<tt>1</tt>.</p>
<p>Note that all other components are shared with HSB.</p>
	
	
	<ul><b>Type:</b>
	<li>
		<tt>Number</tt>
	</li>
	</ul>
	
	
</div>

</div>
</div>
		
			
	<h3>Gradient Components</h3>

<div id="gradient" class="member">
<div class="member-link">
<a name="gradient" href="#gradient"><tt><b>gradient</b></tt></a>
</div>
<div class="member-description hidden">

<div class="member-text">
	<p>The gradient object describing the type of gradient and the stops.</p>
	
	
	<ul><b>Type:</b>
	<li>
		<a href="../classes/Gradient.html"><tt>Gradient</tt></a>
	</li>
	</ul>
	
	
</div>

</div>
</div>
		
			
<div id="highlight" class="member">
<div class="member-link">
<a name="highlight" href="#highlight"><tt><b>highlight</b></tt></a>
</div>
<div class="member-description hidden">

<div class="member-text">
	<p>The highlight point of the gradient.</p>
	
	
	<ul><b>Type:</b>
	<li>
		<a href="../classes/Point.html"><tt>Point</tt></a>
	</li>
	</ul>
	
	<p>
<b>Example</b> &mdash; Create a circle shaped path at the center of the view, using 40% of the height of the view as its radius and fill it with a radial gradient color:
</p>

<div class="paperscript split">

<div class="buttons">
<div class="button run">Run</div>
</div>

<script type="text/paperscript" canvas="canvas-15">
var path = new Path.Circle({
	center: view.center,
	radius: view.bounds.height * 0.4
});

path.fillColor = {
	gradient: {
		stops: ['yellow', 'red', 'black'],
		radial: true
	},
	origin: path.position,
	destination: path.bounds.rightCenter
};

function onMouseMove(event) {
	// Set the origin highlight of the path's gradient color
	// to the position of the mouse:
	path.fillColor.highlight = event.point;
}
</script>
<div class="canvas"><canvas width="516" height="300" id="canvas-15"></canvas></div>
</div>


</div>

</div>
</div>
		
	</div>



<!-- ============================== methods ================================ -->
	<div class="reference-members"><h2>Methods</h2>
		
			
<div id="convert-type" class="member">
<div class="member-link">
<a name="convert-type" href="#convert-type"><tt><b>convert</b>(type)</tt></a>
</div>
<div class="member-description hidden">
<div class="member-text">
	<p>Converts the color another type.</p>
	
<ul><b>Parameters:</b>

<li>
<tt>type:</tt> 
<tt>String('rgb'|'gray'|'hsb'|'hsl')</tt>
&mdash;&nbsp;the color type to
convert to.

</li>

</ul>

	
	<ul><b>Returns:</b>
	
		<li>
<tt><a href="../classes/Color.html"><tt>Color</tt></a></tt>&nbsp;&mdash;&nbsp;the converted color as a new instance
</li>
	
	</ul>

	
	
</div>
</div>
</div>
		
			
<div id="hasalpha" class="member">
<div class="member-link">
<a name="hasalpha" href="#hasalpha"><tt><b>hasAlpha</b>()</tt></a>
</div>
<div class="member-description hidden">
<div class="member-text">
	<p>Checks if the color has an alpha value.</p>
	
	
	<ul><b>Returns:</b>
	
		<li>
<tt><tt>Boolean</tt></tt>&nbsp;&mdash;&nbsp;<tt>true</tt> if the color has an alpha value, <tt>false</tt> otherwise
</li>
	
	</ul>

	
	
</div>
</div>
</div>
		
			
<div id="equals-color" class="member">
<div class="member-link">
<a name="equals-color" href="#equals-color"><tt><b>equals</b>(color)</tt></a>
</div>
<div class="member-description hidden">
<div class="member-text">
	<p>Checks if the component color values of the color are the
same as those of the supplied one.</p>
	
<ul><b>Parameters:</b>

<li>
<tt>color:</tt> 
<a href="../classes/Color.html"><tt>Color</tt></a>
&mdash;&nbsp;the color to compare with

</li>

</ul>

	
	<ul><b>Returns:</b>
	
		<li>
<tt><tt>Boolean</tt></tt>&nbsp;&mdash;&nbsp;<tt>true</tt> if the colors are the same, <tt>false</tt> otherwise
</li>
	
	</ul>

	
	
</div>
</div>
</div>
		
			
<div id="clone" class="member">
<div class="member-link">
<a name="clone" href="#clone"><tt><b>clone</b>()</tt></a>
</div>
<div class="member-description hidden">
<div class="member-text">
	
	
	
	<ul><b>Returns:</b>
	
		<li>
<tt><a href="../classes/Color.html"><tt>Color</tt></a></tt>&nbsp;&mdash;&nbsp;a copy of the color object
</li>
	
	</ul>

	
	
</div>
</div>
</div>
		
			
<h3>String Representations</h3>

<div id="tostring" class="member">
<div class="member-link">
<a name="tostring" href="#tostring"><tt><b>toString</b>()</tt></a>
</div>
<div class="member-description hidden">
<div class="member-text">
	
	
	
	<ul><b>Returns:</b>
	
		<li>
<tt><tt>String</tt></tt>&nbsp;&mdash;&nbsp;a string representation of the color
</li>
	
	</ul>

	
	
</div>
</div>
</div>
		
			
<div id="tocss-hex" class="member">
<div class="member-link">
<a name="tocss-hex" href="#tocss-hex"><tt><b>toCSS</b>(hex)</tt></a>
</div>
<div class="member-description hidden">
<div class="member-text">
	<p>Returns the color as a CSS string.</p>
	
<ul><b>Parameters:</b>

<li>
<tt>hex:</tt> 
<tt>Boolean</tt>
&mdash;&nbsp;whether to return the color in hexadecial
representation or as a CSS RGB / RGBA string.

</li>

</ul>

	
	<ul><b>Returns:</b>
	
		<li>
<tt><tt>String</tt></tt>&nbsp;&mdash;&nbsp;a CSS string representation of the color.
</li>
	
	</ul>

	
	
</div>
</div>
</div>
		
			
<div id="transform-matrix" class="member">
<div class="member-link">
<a name="transform-matrix" href="#transform-matrix"><tt><b>transform</b>(matrix)</tt></a>
</div>
<div class="member-description hidden">
<div class="member-text">
	<p>Transform the gradient color by the specified matrix.</p>
	
<ul><b>Parameters:</b>

<li>
<tt>matrix:</tt> 
<a href="../classes/Matrix.html"><tt>Matrix</tt></a>
&mdash;&nbsp;the matrix to transform the gradient color by

</li>

</ul>

	
	
	
</div>
</div>
</div>
		
	</div>




<!-- =========================== copyright notice ========================= -->
<p class="footer">Copyright &#169; 2011 <a href="http://www.lehni.org" target="_blank">J&uuml;rg Lehni</a> &amp; <a href="http://www.jonathanpuckey.com" target="_blank">Jonathan Puckey</a>. All Rights Reserved.</p>
<div class="content-end"></div>

</body>