paper.js/dist/docs/classes/PathStyle.html
2011-06-17 11:41:47 +01:00

334 lines
No EOL
9.4 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<title>PathStyle</title>
<base target="classFrame">
<link rel="stylesheet" href="../resources/css/reference.css" type="text/css">
<link rel="stylesheet" href="../resources/css/style.css" type="text/css">
<link rel="stylesheet" href="../resources/css/paperscript.css" type="text/css">
<link rel="stylesheet" href="../resources/css/codemirror.css" type="text/css">
<script src="../resources/js/bootstrap.js" type="text/javascript"></script>
<script src="../resources/js/paper.js" type="text/javascript"></script>
<script src="../resources/js/codemirror.js" type="text/javascript"></script>
<script src="../resources/js/reference.js" type="text/javascript"></script>
</head>
<body class="reference">
<div class="reference-class">
<h1>PathStyle</h1>
<p>PathStyle is used for changing the visual styles of items
contained within a Paper.js project and is returned by
<a href="../classes/Item.html#style"><tt>item.style</tt></a> and <a href="../classes/Project.html#currentstyle"><tt>project.currentStyle</tt></a>.</p>
<p>All properties of PathStyle are also reflected directly in <a href="../classes/Item.html"><tt>Item</tt></a>,
i.e.: <a href="../classes/Item.html#fillcolor"><tt>item.fillColor</tt></a>.</p>
<p>To set multiple style properties in one go, you can pass an object to
<a href="../classes/Item.html#style"><tt>item.style</tt></a>. This is a convenient way to define a style once and
apply it to a series of items:</p>
<p>
<b>Example</b>
</p>
<div class="paperscript split">
<div class="button">Run</div>
<script type="text/paperscript" canvas="canvas-0">
var circleStyle = {
fillColor: new RGBColor(1, 0, 0),
strokeColor: 'black',
strokeWidth: 5
};
var path = new Path.Circle(new Point(80, 50), 30);
path.style = circleStyle;
</script>
<div class="canvas"><canvas width="516" height="100" id="canvas-0"></canvas></div>
</div>
</div>
<div class="reference-members"><h2>Properties</h2>
<h3>Stroke Style</h3>
<div id="strokecolor-member" class="member">
<div id="strokecolor-link" class="member-link">
<a name="strokecolor" href="#" onClick="return toggleMember('strokecolor', false);"><tt><b>strokeColor</b></tt></a>
</div>
<div id="strokecolor-description" class="member-description hidden">
<div class="member-header">
<div class="member-title">
<div class="member-link">
<a href="#" onClick="return toggleMember('strokecolor', false);"><tt><b>strokeColor</b></tt></a>
</div>
</div>
<div class="member-close"><input type="button" value="Close" onClick="toggleMember('strokecolor', false);"></div>
<div class="clear"></div>
</div>
<div class="member-text">
<p>The color of the stroke.</p>
<ul><b>Type:</b>
<li>
<a href="../classes/RGBColor.html"><tt>RGBColor</tt></a> / <a href="../classes/HSBColor.html"><tt>HSBColor</tt></a> / <a href="../classes/GrayColor.html"><tt>GrayColor</tt></a>
</li>
</ul>
<p>
<b>Example</b> &mdash; Setting the stroke color of a path:
</p>
<div class="paperscript split">
<div class="button">Run</div>
<script type="text/paperscript" canvas="canvas-1">
// Create a circle shaped path at { x: 80, y: 50 }
// with a radius of 35:
var circle = new Path.Circle(new Point(80, 50), 35);
// Set its stroke color to RGB red:
circle.strokeColor = new RGBColor(1, 0, 0);
</script>
<div class="canvas"><canvas width="516" height="100" id="canvas-1"></canvas></div>
</div>
</div>
</div>
</div>
<div id="strokewidth-member" class="member">
<div id="strokewidth-link" class="member-link">
<a name="strokewidth" href="#" onClick="return toggleMember('strokewidth', false);"><tt><b>strokeWidth</b></tt></a>
</div>
<div id="strokewidth-description" class="member-description hidden">
<div class="member-header">
<div class="member-title">
<div class="member-link">
<a href="#" onClick="return toggleMember('strokewidth', false);"><tt><b>strokeWidth</b></tt></a>
</div>
</div>
<div class="member-close"><input type="button" value="Close" onClick="toggleMember('strokewidth', false);"></div>
<div class="clear"></div>
</div>
<div class="member-text">
<p>The width of the stroke.</p>
<ul><b>Default:</b>
<li>
<tt>1</tt>
</li>
</ul>
<ul><b>Type:</b>
<li>
<tt>Number</tt>
</li>
</ul>
<p>
<b>Example</b> &mdash; Setting an item's stroke width:
</p>
<div class="paperscript split">
<div class="button">Run</div>
<script type="text/paperscript" canvas="canvas-2">
// Create a circle shaped path at { x: 80, y: 50 }
// with a radius of 35:
var circle = new Path.Circle(new Point(80, 50), 35);
// Set its stroke color to black:
circle.strokeColor = 'black';
// Set its stroke width to 10:
circle.strokeWidth = 10;
</script>
<div class="canvas"><canvas width="516" height="100" id="canvas-2"></canvas></div>
</div>
</div>
</div>
</div>
<div id="strokejoin-member" class="member">
<div id="strokejoin-link" class="member-link">
<a name="strokejoin" href="#" onClick="return toggleMember('strokejoin', false);"><tt><b>strokeJoin</b></tt></a>
</div>
<div id="strokejoin-description" class="member-description hidden">
<div class="member-header">
<div class="member-title">
<div class="member-link">
<a href="#" onClick="return toggleMember('strokejoin', false);"><tt><b>strokeJoin</b></tt></a>
</div>
</div>
<div class="member-close"><input type="button" value="Close" onClick="toggleMember('strokejoin', false);"></div>
<div class="clear"></div>
</div>
<div class="member-text">
<p>The shape to be used at the corners of paths when they have a stroke.</p>
<ul><b>Default:</b>
<li>
<tt>'miter'</tt>
</li>
</ul>
<ul><b>Type:</b>
<li>
<tt>String</tt> ('miter', 'round', 'bevel')
</li>
</ul>
<p>
<b>Example</b> &mdash; A look at the different stroke joins:
</p>
<div class="paperscript split">
<div class="button">Run</div>
<script type="text/paperscript" canvas="canvas-3">
var path = new Path();
path.add(new Point(80, 100));
path.add(new Point(120, 40));
path.add(new Point(160, 100));
path.strokeColor = 'black';
path.strokeWidth = 20;
// Select the path, so we can see where the stroke is formed:
path.selected = true;
var path2 = path.clone();
path2.position.x += path2.bounds.width * 1.5;
path2.strokeJoin = 'round';
var path3 = path2.clone();
path3.position.x += path3.bounds.width * 1.5;
path3.strokeJoin = 'bevel';
</script>
<div class="canvas"><canvas width="516" height="120" id="canvas-3"></canvas></div>
</div>
</div>
</div>
</div>
<div id="miterlimit-member" class="member">
<div id="miterlimit-link" class="member-link">
<a name="miterlimit" href="#" onClick="return toggleMember('miterlimit', false);"><tt><b>miterLimit</b></tt></a>
</div>
<div id="miterlimit-description" class="member-description hidden">
<div class="member-header">
<div class="member-title">
<div class="member-link">
<a href="#" onClick="return toggleMember('miterlimit', false);"><tt><b>miterLimit</b></tt></a>
</div>
</div>
<div class="member-close"><input type="button" value="Close" onClick="toggleMember('miterlimit', false);"></div>
<div class="clear"></div>
</div>
<div class="member-text">
<p>The miter limit of the stroke.</p>
<p>When two line segments meet at a sharp angle and miter joins have been
specified for <a href="../classes/PathStyle.html#strokejoin" onclick="return toggleMember('strokejoin', true);"><tt>strokeJoin</tt></a>, it is possible for the miter to extend
far beyond the <a href="../classes/PathStyle.html#strokewidth" onclick="return toggleMember('strokewidth', true);"><tt>strokeWidth</tt></a> of the path. The miterLimit imposes a
limit on the ratio of the miter length to the <a href="../classes/PathStyle.html#strokewidth" onclick="return toggleMember('strokewidth', true);"><tt>strokeWidth</tt></a>.</p>
<ul><b>Default:</b>
<li>
<tt>10</tt>
</li>
</ul>
<ul><b>Type:</b>
<li>
<tt>Number</tt>
</li>
</ul>
</div>
</div>
</div>
<h3>Fill Style</h3>
<div id="fillcolor-member" class="member">
<div id="fillcolor-link" class="member-link">
<a name="fillcolor" href="#" onClick="return toggleMember('fillcolor', false);"><tt><b>fillColor</b></tt></a>
</div>
<div id="fillcolor-description" class="member-description hidden">
<div class="member-header">
<div class="member-title">
<div class="member-link">
<a href="#" onClick="return toggleMember('fillcolor', false);"><tt><b>fillColor</b></tt></a>
</div>
</div>
<div class="member-close"><input type="button" value="Close" onClick="toggleMember('fillcolor', false);"></div>
<div class="clear"></div>
</div>
<div class="member-text">
<p>The fill color.</p>
<ul><b>Type:</b>
<li>
<a href="../classes/RGBColor.html"><tt>RGBColor</tt></a> / <a href="../classes/HSBColor.html"><tt>HSBColor</tt></a> / <a href="../classes/GrayColor.html"><tt>GrayColor</tt></a>
</li>
</ul>
<p>
<b>Example</b> &mdash; Setting the fill color of a path to red:
</p>
<div class="paperscript split">
<div class="button">Run</div>
<script type="text/paperscript" canvas="canvas-4">
// Create a circle shaped path at { x: 80, y: 50 }
// with a radius of 35:
var circle = new Path.Circle(new Point(80, 50), 35);
// Set the fill color of the circle to RGB red:
circle.fillColor = new RGBColor(1, 0, 0);
</script>
<div class="canvas"><canvas width="516" height="100" id="canvas-4"></canvas></div>
</div>
</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>