305 lines
11 KiB
HTML
305 lines
11 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
<head>
|
|
<title>PShape \ Language (API) \ Processing 2+</title>
|
|
|
|
<link rel="icon" href="/favicon.ico" type="image/x-icon" />
|
|
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
<meta name="Author" content="Processing Foundation" />
|
|
<meta name="Publisher" content="Processing Foundation" />
|
|
<meta name="Keywords" content="Processing, Sketchbook, Programming, Coding, Code, Art, Design" />
|
|
<meta name="Description" content="Processing is a flexible software sketchbook and a language for learning how to code within the context of the visual arts. Since 2001, Processing has promoted software literacy within the visual arts and visual literacy within technology." />
|
|
<meta name="Copyright" content="All contents copyright the Processing Foundation, Ben Fry, Casey Reas, and the MIT Media Laboratory" />
|
|
|
|
<script src="javascript/modernizr-2.6.2.touch.js" type="text/javascript"></script>
|
|
<link href="css/style.css" rel="stylesheet" type="text/css" />
|
|
|
|
</head>
|
|
<body id="Langauge-en" onload="" >
|
|
|
|
<!-- ==================================== PAGE ============================ -->
|
|
<div id="container">
|
|
|
|
|
|
<!-- ==================================== HEADER ============================ -->
|
|
<div id="ribbon">
|
|
<ul class="left">
|
|
<li class="highlight"><a href="http://processing.org/">Processing</a></li>
|
|
<li><a href="http://p5js.org/">p5.js</a></li>
|
|
<li><a href="http://py.processing.org/">Processing.py</a></li>
|
|
<li><a href="http://android.processing.org/">Processing for Android</a></li>
|
|
</ul>
|
|
<ul class="right">
|
|
<li><a href="https://processingfoundation.org/">Processing Foundation</a></li>
|
|
</ul>
|
|
<div class="clear"></div>
|
|
</div>
|
|
<div id="header">
|
|
<a href="/" title="Back to the Processing cover."><div class="processing-logo no-cover" alt="Processing cover"></div></a>
|
|
<form name="search" method="get" action="//www.google.com/search">
|
|
<p><input type="hidden" name="as_sitesearch" value="processing.org" />
|
|
<input type="text" name="as_q" value="" size="20" class="text" />
|
|
<input type="submit" value=" " /></p>
|
|
</form>
|
|
</div>
|
|
<a id="TOP" name="TOP"></a>
|
|
|
|
<div id="navigation">
|
|
<div class="navBar" id="mainnav">
|
|
<a href="index.html" class='active'>Language</a><br>
|
|
<a href="libraries/index.html" >Libraries</a><br>
|
|
<a href="tools/index.html">Tools</a><br>
|
|
<a href="environment/index.html">Environment</a><br>
|
|
</div>
|
|
|
|
<script> document.querySelectorAll(".processing-logo")[0].className = "processing-logo"; </script>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- ==================================== CONTENT - Headers ============================ -->
|
|
<div class="content">
|
|
|
|
<p class="ref-notice">This reference is for Processing 3.0+. If you have a previous version, use the reference included with your software in the Help menu. If you see any errors or have suggestions, <a href="https://github.com/processing/processing-docs/issues?state=open">please let us know</a>. If you prefer a more technical reference, visit the <a href="http://processing.github.io/processing-javadocs/core/">Processing Core Javadoc</a> and <a href="http://processing.github.io/processing-javadocs/libraries/">Libraries Javadoc</a>.</p>
|
|
|
|
<table cellpadding="0" cellspacing="0" border="0" class="ref-item">
|
|
<tr class="name-row">
|
|
<th scope="row">Name</th>
|
|
<td><h3>PShape</h3></td>
|
|
</tr>
|
|
|
|
<tr class=""><th scope="row">Examples</th><td><div class="example"><pre >
|
|
PShape s;
|
|
|
|
void setup() {
|
|
size(100, 100);
|
|
// The file "bot.svg" must be in the data folder
|
|
// of the current sketch to load successfully
|
|
s = loadShape("bot.svg");
|
|
}
|
|
|
|
void draw() {
|
|
shape(s, 10, 10, 80, 80);
|
|
}
|
|
</pre></div>
|
|
<hr class="noshade" noshade="noshade" size="1">
|
|
<div class="example"><pre >
|
|
PShape square; // The PShape object
|
|
|
|
void setup() {
|
|
size(100, 100);
|
|
// Creating the PShape as a square. The corner
|
|
// is 0,0 so that the center is at 40,40
|
|
square = createShape(RECT, 0, 0, 80, 80);
|
|
}
|
|
|
|
void draw() {
|
|
shape(square, 10, 10);
|
|
}
|
|
</pre></div>
|
|
</td></tr>
|
|
|
|
<tr class="">
|
|
<th scope="row">Description</th>
|
|
<td>
|
|
Datatype for storing shapes. Before a shape is used, it must be loaded with the <b>loadShape()</b> or created with the <b>createShape()</b>. The <b>shape()</b> function is used to draw the shape to the display window. Processing can currently load and display SVG (Scalable Vector Graphics) and OBJ shapes. OBJ files can only be opened using the <b>P3D</b> renderer. The <b>loadShape()</b> function supports SVG files created with Inkscape and Adobe Illustrator. It is not a full SVG implementation, but offers some straightforward support for handling vector data.
|
|
<br /><br />
|
|
The <b>PShape</b> object contains a group of methods that can operate on the shape data. Some of the methods are listed below, but the full list used for creating and modifying shapes is <a href="http://processing.github.io/processing-javadocs/core/">available here in the Processing Javadoc</a>.<br />
|
|
<br />
|
|
To create a new shape, use the <b>createShape()</b> function. Do not use the syntax <b>new PShape()</b>.
|
|
</td>
|
|
</tr>
|
|
|
|
<tr class=""><th scope="row"><b>Fields</b></th><td><table cellpadding="0" cellspacing="0" border="0"><tr class="">
|
|
|
|
<th scope="row"><a href="PShape_width.html">width</a></th>
|
|
<td>Shape document width</td>
|
|
</tr>
|
|
<tr class="">
|
|
|
|
<th scope="row"><a href="PShape_height.html">height</a></th>
|
|
<td>Shape document height</td>
|
|
</tr></table></td></tr>
|
|
|
|
<tr class=""><th scope="row">Methods</th><td><table cellpadding="0" cellspacing="0" border="0"><tr class="">
|
|
|
|
<th scope="row"><a href="PShape_isVisible_.html">isVisible()</a></th>
|
|
<td>Returns a boolean value "true" if the image is set to be visible, "false" if not</td>
|
|
</tr>
|
|
<tr class="">
|
|
|
|
<th scope="row"><a href="PShape_setVisible_.html">setVisible()</a></th>
|
|
<td>Sets the shape to be visible or invisible</td>
|
|
</tr>
|
|
<tr class="">
|
|
|
|
<th scope="row"><a href="PShape_disableStyle_.html">disableStyle()</a></th>
|
|
<td>Disables the shape's style data and uses Processing styles</td>
|
|
</tr>
|
|
<tr class="">
|
|
|
|
<th scope="row"><a href="PShape_enableStyle_.html">enableStyle()</a></th>
|
|
<td>Enables the shape's style data and ignores the Processing styles</td>
|
|
</tr>
|
|
<tr class="">
|
|
|
|
<th scope="row"><a href="PShape_beginContour_.html">beginContour()</a></th>
|
|
<td>Starts a new contour</td>
|
|
</tr>
|
|
<tr class="">
|
|
|
|
<th scope="row"><a href="PShape_endContour_.html">endContour()</a></th>
|
|
<td>Ends a contour</td>
|
|
</tr>
|
|
<tr class="">
|
|
|
|
<th scope="row"><a href="PShape_beginShape_.html">beginShape()</a></th>
|
|
<td>Starts the creation of a new PShape</td>
|
|
</tr>
|
|
<tr class="">
|
|
|
|
<th scope="row"><a href="PShape_endShape_.html">endShape()</a></th>
|
|
<td>Finishes the creation of a new PShape</td>
|
|
</tr>
|
|
<tr class="">
|
|
|
|
<th scope="row"><a href="PShape_getChildCount_.html">getChildCount()</a></th>
|
|
<td>Returns the number of children</td>
|
|
</tr>
|
|
<tr class="">
|
|
|
|
<th scope="row"><a href="PShape_getChild_.html">getChild()</a></th>
|
|
<td>Returns a child element of a shape as a PShape object</td>
|
|
</tr>
|
|
<tr class="">
|
|
|
|
<th scope="row"><a href="PShape_addChild_.html">addChild()</a></th>
|
|
<td>Adds a new child</td>
|
|
</tr>
|
|
<tr class="">
|
|
|
|
<th scope="row"><a href="PShape_getVertexCount_.html">getVertexCount()</a></th>
|
|
<td>Returns the total number of vertices as an int</td>
|
|
</tr>
|
|
<tr class="">
|
|
|
|
<th scope="row"><a href="PShape_getVertex_.html">getVertex()</a></th>
|
|
<td>Returns the vertex at the index position</td>
|
|
</tr>
|
|
<tr class="">
|
|
|
|
<th scope="row"><a href="PShape_setVertex_.html">setVertex()</a></th>
|
|
<td>Sets the vertex at the index position</td>
|
|
</tr>
|
|
<tr class="">
|
|
|
|
<th scope="row"><a href="PShape_setFill_.html">setFill()</a></th>
|
|
<td>Set the fill value</td>
|
|
</tr>
|
|
<tr class="">
|
|
|
|
<th scope="row"><a href="PShape_setStroke_.html">setStroke()</a></th>
|
|
<td>Set the stroke value</td>
|
|
</tr>
|
|
<tr class="">
|
|
|
|
<th scope="row"><a href="PShape_translate_.html">translate()</a></th>
|
|
<td>Displaces the shape</td>
|
|
</tr>
|
|
<tr class="">
|
|
|
|
<th scope="row"><a href="PShape_rotateX_.html">rotateX()</a></th>
|
|
<td>Rotates the shape around the x-axis</td>
|
|
</tr>
|
|
<tr class="">
|
|
|
|
<th scope="row"><a href="PShape_rotateY_.html">rotateY()</a></th>
|
|
<td>Rotates the shape around the y-axis</td>
|
|
</tr>
|
|
<tr class="">
|
|
|
|
<th scope="row"><a href="PShape_rotateZ_.html">rotateZ()</a></th>
|
|
<td>Rotates the shape around the z-axis</td>
|
|
</tr>
|
|
<tr class="">
|
|
|
|
<th scope="row"><a href="PShape_rotate_.html">rotate()</a></th>
|
|
<td>Rotates the shape</td>
|
|
</tr>
|
|
<tr class="">
|
|
|
|
<th scope="row"><a href="PShape_scale_.html">scale()</a></th>
|
|
<td>Increases and decreases the size of a shape</td>
|
|
</tr>
|
|
<tr class="">
|
|
|
|
<th scope="row"><a href="PShape_resetMatrix_.html">resetMatrix()</a></th>
|
|
<td>Replaces the current matrix of a shape with the identity matrix</td>
|
|
</tr></table></td></tr>
|
|
|
|
<tr class=""><th scope="row">Constructor</th><td><pre>PShape(<kbd>g</kbd>, <kbd>kind</kbd>, <kbd>params</kbd>)
|
|
</pre></td></tr>
|
|
|
|
<tr class=""><th scope="row">Related</th><td><a class="code" href="loadShape_.html">loadShape()</a><br />
|
|
<a class="code" href="createShape_.html">createShape()</a><br />
|
|
<a class="code" href="shapeMode_.html">shapeMode()</a><br /></td></tr>
|
|
</table>
|
|
|
|
Updated on April 30, 2017 02:33:19pm EDT<br /><br />
|
|
|
|
<!-- Creative Commons License -->
|
|
|
|
<div class="license">
|
|
<a rel="license" href="//creativecommons.org/licenses/by-nc-sa/4.0/"><img alt="Creative Commons License" style="border: none" src="https://licensebuttons.net/l/by-nc-sa/4.0/88x31.png" /></a>
|
|
</div>
|
|
<!--
|
|
|
|
<?xpacket begin='' id=''?>
|
|
<x:xmpmeta xmlns:x='adobe:ns:meta/'>
|
|
<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
|
|
<rdf:Description rdf:about=''
|
|
xmlns:xapRights='http://ns.adobe.com/xap/1.0/rights/'>
|
|
<xapRights:Marked>True</xapRights:Marked>
|
|
</rdf:Description>
|
|
<rdf:Description rdf:about=''
|
|
xmlns:xapRights='http://ns.adobe.com/xap/1.0/rights/'
|
|
>
|
|
<xapRights:UsageTerms>
|
|
<rdf:Alt>
|
|
<rdf:li xml:lang='x-default' >This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.</rdf:li>
|
|
<rdf:li xml:lang='en' >This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.</rdf:li>
|
|
</rdf:Alt>
|
|
</xapRights:UsageTerms>
|
|
</rdf:Description>
|
|
<rdf:Description rdf:about=''
|
|
xmlns:cc='http://creativecommons.org/ns#'>
|
|
<cc:license rdf:resource='http://creativecommons.org/licenses/by-nc-sa/4.0/'/>
|
|
</rdf:Description>
|
|
|
|
</rdf:RDF>
|
|
</x:xmpmeta>
|
|
<?xpacket end='r'?>
|
|
|
|
-->
|
|
|
|
</div>
|
|
|
|
<!-- ==================================== FOOTER ============================ -->
|
|
<div id="footer">
|
|
<div id="copyright">Processing is an open project intiated by <a href="http://benfry.com/">Ben Fry</a> and <a href="http://reas.com">Casey Reas</a>. It is developed by a <a href="about/people.html">team of volunteers</a>. </div>
|
|
<div id="colophon">
|
|
|
|
<a href="copyright.html">© Info</a>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
<script src="javascript/jquery-1.9.1.min.js"></script>
|
|
<script src="javascript/site.js" type="text/javascript"></script>
|
|
</body>
|
|
|
|
</html>
|