controlp5/reference/controlP5/Canvas.html

527 lines
16 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (version 1.7.0_51) on Sun Apr 27 21:39:46 SGT 2014 -->
<title>Canvas (Javadocs: controlP5)</title>
<meta name="date" content="2014-04-27">
<link rel="stylesheet" type="text/css" href="../stylesheet.css" title="Style">
</head>
<body>
<script type="text/javascript"><!--
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="Canvas (Javadocs: controlP5)";
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar_top">
<!-- -->
</a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../controlP5/package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../index-all.html">Index</a></li>
<li><a href="../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../controlP5/CallbackListener.html" title="interface in controlP5"><span class="strong">Prev Class</span></a></li>
<li><a href="../controlP5/CColor.html" title="class in controlP5"><span class="strong">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../index.html?controlP5/Canvas.html" target="_top">Frames</a></li>
<li><a href="Canvas.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li><a href="#field_summary">Field</a>&nbsp;|&nbsp;</li>
<li><a href="#constructor_summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method_summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li><a href="#field_detail">Field</a>&nbsp;|&nbsp;</li>
<li><a href="#constructor_detail">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method_detail">Method</a></li>
</ul>
</div>
<a name="skip-navbar_top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle">controlP5</div>
<h2 title="Class Canvas" class="title">Class Canvas</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li>java.lang.Object</li>
<li>
<ul class="inheritance">
<li>controlP5.Canvas</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<hr>
<br>
<pre>public abstract class <span class="strong">Canvas</span>
extends java.lang.Object</pre>
<div class="block">Use a Canvas to draw custom graphics into a control
window or the default sketch window.
The Canvas is an abstract class and must be extended by
your custom Canvas class, see the ControlP5canvas example
for details.</div>
<dl><script type="text/javascript">
<!--
document.getElementsByTagName('html')[0].className = 'isjs';function toggle(dt) { var display, dd=dt; do{ dd = dd.nextSibling } while(dd.tagName!='DD'); toOpen =!dd.style.display;dd.style.display = toOpen? 'block':''; dt.getElementsByTagName('span')[0].innerHTML = toOpen? '-':'+' ; }
-->
</script>
<div id="test" class="toggleList"><dl><dt onclick="toggle(this);"><span>+</span>Example</dt><dd><code><pre>/**
* ControlP5 Canvas
* The ControlWindowCanvas allow you to add custom graphics to
* the default controlP5 renderer or a controlWindow rednerer.
*
* find a list of public methods available for the Canvas Controller
* at the bottom of this sketch's source code
*
* by Andreas Schlegel, 2011
* www.sojamo.de/libraries/controlp5
*
*/
import controlP5.*;
ControlP5 cp5;
ControlWindow controlWindow;
Canvas cc;
// MyCanvas, your Canvas render class
class MyCanvas extends Canvas {
int y;
int mx = 0;
int my = 0;
public void setup(PGraphics pg) {
y = 200;
}
public void update(PApplet p) {
mx = p.mouseX;
my = p.mouseY;
}
public void draw(PGraphics pg) {
// renders a square with randomly changing colors
// make changes here.
pg.fill(100);
pg.rect(mx-20, y-20, 240, 30);
pg.fill(255);
pg.text("This text is drawn by MyCanvas", mx,y);
}
}
void setup() {
size(400, 400);
frameRate(30);
cp5 = new ControlP5(this);
// create a control window canvas and add it to
// the previously created control window.
cc = new MyCanvas();
cc.pre(); // use cc.post(); to draw on top of existing controllers.
cp5.addCanvas(cc); // add the canvas to cp5
}
void draw() {
background(0);
fill(60);
rect(100, 100, 200, 200);
}
/*
a list of all methods available for the ControlWindowCanvas Controller
use ControlP5.printPublicMethodsFor(Canvas.class);
to print the following list into the console.
You can find further details about class Canvas in the javadoc.
Format:
ClassName : returnType methodName(parameter type)
controlP5.Canvas : void moveTo(ControlWindow)
controlP5.Canvas : void setup(PApplet)
controlP5.Canvas : void draw(PApplet)
java.lang.Object : String toString()
java.lang.Object : boolean equals(Object)
*/
</pre></code></dd></dl></div></dl>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- =========== FIELD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="field_summary">
<!-- -->
</a>
<h3>Field Summary</h3>
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Field Summary table, listing fields, and an explanation">
<caption><span>Fields</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Field and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><strong><a href="../controlP5/Canvas.html#POST">POST</a></strong></code>&nbsp;</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><strong><a href="../controlP5/Canvas.html#PRE">PRE</a></strong></code>&nbsp;</td>
</tr>
</table>
</li>
</ul>
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor_summary">
<!-- -->
</a>
<h3>Constructor Summary</h3>
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Constructor Summary table, listing constructors, and an explanation">
<caption><span>Constructors</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colOne" scope="col">Constructor and Description</th>
</tr>
<tr class="altColor">
<td class="colOne"><code><strong><a href="../controlP5/Canvas.html#Canvas()">Canvas</a></strong>()</code>&nbsp;</td>
</tr>
</table>
</li>
</ul>
<!-- ========== METHOD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="method_summary">
<!-- -->
</a>
<h3>Method Summary</h3>
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
<caption><span>Methods</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>abstract void</code></td>
<td class="colLast"><code><strong><a href="../controlP5/Canvas.html#draw(processing.core.PGraphics)">draw</a></strong>(processing.core.PGraphics&nbsp;theGraphics)</code>
<div class="block">controlWindowCanvas is an abstract class and
therefore needs to be extended by your class.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>int</code></td>
<td class="colLast"><code><strong><a href="../controlP5/Canvas.html#mode()">mode</a></strong>()</code>
<div class="block">get the drawing mode of a Canvas.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../controlP5/Canvas.html#moveTo(controlP5.ControlWindow)">moveTo</a></strong>(<a href="../controlP5/ControlWindow.html" title="class in controlP5">ControlWindow</a>&nbsp;theControlWindow)</code>
<div class="block">move a canvas to another controlWindow</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../controlP5/Canvas.html#post()">post</a></strong>()</code>
<div class="block">set the drawing mode to POST.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../controlP5/Canvas.html#pre()">pre</a></strong>()</code>
<div class="block">set the drawing mode to PRE.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../controlP5/Canvas.html#setMode(int)">setMode</a></strong>(int&nbsp;theMode)</code>&nbsp;</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../controlP5/Canvas.html#setup(processing.core.PGraphics)">setup</a></strong>(processing.core.PGraphics&nbsp;theGraphics)</code>&nbsp;</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../controlP5/Canvas.html#update(processing.core.PApplet)">update</a></strong>(processing.core.PApplet&nbsp;theApplet)</code>&nbsp;</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code><a href="../controlP5/ControlWindow.html" title="class in controlP5">ControlWindow</a></code></td>
<td class="colLast"><code><strong><a href="../controlP5/Canvas.html#window()">window</a></strong>()</code>&nbsp;</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods_inherited_from_class_java.lang.Object">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;java.lang.Object</h3>
<code>equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</code></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ============ FIELD DETAIL =========== -->
<ul class="blockList">
<li class="blockList"><a name="field_detail">
<!-- -->
</a>
<h3>Field Detail</h3>
<a name="POST">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>POST</h4>
<pre>public static final&nbsp;int POST</pre>
<dl><dt><span class="strong">See Also:</span></dt><dd><a href="../constant-values.html#controlP5.Canvas.POST">Constant Field Values</a></dd></dl>
</li>
</ul>
<a name="PRE">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>PRE</h4>
<pre>public static final&nbsp;int PRE</pre>
<dl><dt><span class="strong">See Also:</span></dt><dd><a href="../constant-values.html#controlP5.Canvas.PRE">Constant Field Values</a></dd></dl>
</li>
</ul>
</li>
</ul>
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor_detail">
<!-- -->
</a>
<h3>Constructor Detail</h3>
<a name="Canvas()">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>Canvas</h4>
<pre>public&nbsp;Canvas()</pre>
</li>
</ul>
</li>
</ul>
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method_detail">
<!-- -->
</a>
<h3>Method Detail</h3>
<a name="draw(processing.core.PGraphics)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>draw</h4>
<pre>public abstract&nbsp;void&nbsp;draw(processing.core.PGraphics&nbsp;theGraphics)</pre>
<div class="block">controlWindowCanvas is an abstract class and
therefore needs to be extended by your class.
draw(PApplet theApplet) is the only method that needs
to be overwritten.</div>
</li>
</ul>
<a name="mode()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>mode</h4>
<pre>public final&nbsp;int&nbsp;mode()</pre>
<div class="block">get the drawing mode of a Canvas. this can be PRE or
POST.</div>
<dl><dt><span class="strong">Returns:</span></dt><dd></dd></dl>
</li>
</ul>
<a name="moveTo(controlP5.ControlWindow)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>moveTo</h4>
<pre>public&nbsp;void&nbsp;moveTo(<a href="../controlP5/ControlWindow.html" title="class in controlP5">ControlWindow</a>&nbsp;theControlWindow)</pre>
<div class="block">move a canvas to another controlWindow</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>theControlWindow</code> - </dd></dl>
</li>
</ul>
<a name="post()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>post</h4>
<pre>public final&nbsp;void&nbsp;post()</pre>
<div class="block">set the drawing mode to POST.</div>
</li>
</ul>
<a name="pre()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>pre</h4>
<pre>public final&nbsp;void&nbsp;pre()</pre>
<div class="block">set the drawing mode to PRE. PRE is the default.</div>
</li>
</ul>
<a name="setMode(int)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>setMode</h4>
<pre>public final&nbsp;void&nbsp;setMode(int&nbsp;theMode)</pre>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>theMode</code> - </dd></dl>
</li>
</ul>
<a name="setup(processing.core.PGraphics)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>setup</h4>
<pre>public&nbsp;void&nbsp;setup(processing.core.PGraphics&nbsp;theGraphics)</pre>
</li>
</ul>
<a name="update(processing.core.PApplet)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>update</h4>
<pre>public&nbsp;void&nbsp;update(processing.core.PApplet&nbsp;theApplet)</pre>
</li>
</ul>
<a name="window()">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>window</h4>
<pre>public final&nbsp;<a href="../controlP5/ControlWindow.html" title="class in controlP5">ControlWindow</a>&nbsp;window()</pre>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar_bottom">
<!-- -->
</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../controlP5/package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../index-all.html">Index</a></li>
<li><a href="../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../controlP5/CallbackListener.html" title="interface in controlP5"><span class="strong">Prev Class</span></a></li>
<li><a href="../controlP5/CColor.html" title="class in controlP5"><span class="strong">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../index.html?controlP5/Canvas.html" target="_top">Frames</a></li>
<li><a href="Canvas.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li><a href="#field_summary">Field</a>&nbsp;|&nbsp;</li>
<li><a href="#constructor_summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method_summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li><a href="#field_detail">Field</a>&nbsp;|&nbsp;</li>
<li><a href="#constructor_detail">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method_detail">Method</a></li>
</ul>
</div>
<a name="skip-navbar_bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<p class="legalCopy"><small>processing library controlP5 by Andreas Schlegel. (c) 2006-2014</small></p>
</body>
</html>