<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>GAmuza</title>
	<atom:link href="http://gamuza.d3cod3.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://gamuza.d3cod3.org</link>
	<description></description>
	<lastBuildDate>Tue, 01 Jan 2013 13:15:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>ga.captureBackground()</title>
		<link>http://gamuza.d3cod3.org/ga/ga-capturebackground/</link>
		<comments>http://gamuza.d3cod3.org/ga/ga-capturebackground/#comments</comments>
		<pubDate>Tue, 01 Jan 2013 13:15:19 +0000</pubDate>
		<dc:creator>n3m3da</dc:creator>
				<category><![CDATA[ga]]></category>
		<category><![CDATA[gawebcam]]></category>

		<guid isPermaLink="false">http://gamuza.d3cod3.org/?p=2161</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<strong>Name</strong><br />
<h4>ga.captureBackground()</h4>
<strong>Examples</strong><br />
<h4><code class="bwp-syntax-inline">camID = <span style="color: #000000;">0</span><br />
runningBlobs = <span style="color: #000000;">0</span><br />
cam = <span style="color: #FF7F32;">of.texture</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
<br />
<span style="color: #FF7F32;">function</span> <span style="color: #FF7F32;">setup</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; cam:<span style="color: #FF7F32;">allocate</span><span style="color: #000000;">&#40;</span><span style="color: #1F73B3;">CAPTURE_W</span>,<span style="color: #1F73B3;">CAPTURE_H</span>,GL_RGB<span style="color: #000000;">&#41;</span><br />
<span style="color: #FF7F32;">end</span><br />
<br />
<span style="color: #FF7F32;">function</span> <span style="color: #FF7F32;">update</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; cam = <span style="color: #FF7F32;">ga.cameraTexture</span><span style="color: #000000;">&#40;</span>camID<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; runningBlobs = <span style="color: #FF7F32;">ga.camBlobs</span><span style="color: #000000;">&#40;</span>camID<span style="color: #000000;">&#41;</span><br />
<span style="color: #FF7F32;">end</span><br />
<br />
<span style="color: #FF7F32;">function</span> <span style="color: #FF7F32;">draw</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">ga.background</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">0.0</span>,<span style="color: #000000;">1.0</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7F7F7F; font-style: italic;">// draw the live image from device</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">of.setColor</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">255</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; cam:<span style="color: #FF7F32;">draw</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">0</span>,<span style="color: #000000;">0</span>,<span style="color: #1F73B3;">OUTPUT_W</span>,<span style="color: #1F73B3;">OUTPUT_H</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">of.pushMatrix</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">of.scale</span><span style="color: #000000;">&#40;</span><span style="color: #1F73B3;">OUTPUT_W</span>/<span style="color: #1F73B3;">CAPTURE_W</span>,<span style="color: #1F73B3;">OUTPUT_H</span>/<span style="color: #1F73B3;">CAPTURE_H</span>,<span style="color: #000000;">1.0</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">for</span> j=<span style="color: #000000;">0</span>, runningBlobs-<span style="color: #000000;">1</span> <span style="color: #FF7F32;">do</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7F7F7F; font-style: italic;">// draw contours for each blob detected</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">of.setLineWidth</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">1</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">of.setColor</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">255</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">of.fill</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">of.beginShape</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">for</span> i=<span style="color: #000000;">0</span>, <span style="color: #FF7F32;">ga.camBlobContourSize</span><span style="color: #000000;">&#40;</span>camID,j<span style="color: #000000;">&#41;</span>-<span style="color: #000000;">1</span> <span style="color: #FF7F32;">do</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x = <span style="color: #FF7F32;">ga.camBlobCPointX</span><span style="color: #000000;">&#40;</span>camID,j,i<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; y = <span style="color: #FF7F32;">ga.camBlobCPointY</span><span style="color: #000000;">&#40;</span>camID,j,i<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">of.vertex</span><span style="color: #000000;">&#40;</span>x,y<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">end</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">of.endShape</span><span style="color: #000000;">&#40;</span><span style="color: #FF7F32;">false</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">end</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">of.popMatrix</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
<br />
<span style="color: #FF7F32;">end</span><br />
<br />
<span style="color: #FF7F32;">function</span> <span style="color: #FF7F32;">keyReleased</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">if</span> <span style="color: #FF7F32;">ga.key</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> == <span style="color: #FF7F32;">string.byte</span><span style="color: #000000;">&#40;</span><span style="color: #FF1919;">' '</span><span style="color: #000000;">&#41;</span> <span style="color: #FF7F32;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">ga.captureBackground</span><span style="color: #000000;">&#40;</span>camID<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">end</span><br />
<span style="color: #FF7F32;">end</span></code></h4>
<strong>Description</strong><br />
<h4>Control the background subtraction capture from code. If you have three cameras connected on your machine, then you can use this funtion with 0, 1 or 2 as specified camera device; the order will be the same order of openFrameworks console listing available devices, or instead the videoTracking tab order in GAmuza GUI.<br />Be sure to activate the video tracking module in the <strong>settingManager</strong> and have, at least, one camera connected and up&running, in order to have this function working.</h4>
<strong>Syntax</strong><br />
<h4><code class="bwp-syntax-inline"><span style="color: #FF7F32;">ga.captureBackground</span><span style="color: #000000;">&#40;</span>device<span style="color: #000000;">&#41;</span></code></h4>
<strong>Parameters</strong><br />
<h4><table>
<tr><td>device</td><td>the camera device id</td></tr>
</table></h4>
<strong>Returns</strong><br />
<h4>None.</h4>
]]></content:encoded>
			<wfw:commentRss>http://gamuza.d3cod3.org/ga/ga-capturebackground/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>blur</title>
		<link>http://gamuza.d3cod3.org/examples/blur/</link>
		<comments>http://gamuza.d3cod3.org/examples/blur/#comments</comments>
		<pubDate>Wed, 19 Sep 2012 13:57:13 +0000</pubDate>
		<dc:creator>n3m3da</dc:creator>
				<category><![CDATA[examples]]></category>
		<category><![CDATA[exshaders]]></category>

		<guid isPermaLink="false">http://gamuza.d3cod3.org/?p=2133</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<img src="http://www.d3cod3.org/gamuza/examplesImages/Shaders/blur.jpg" width="500" height="313" />
<h4>Shaders examples from ofx.fx() class.<br />
This example shows the blur effect.<br />
Original addon from patriciogonzalezvivo <a href="https://github.com/patriciogonzalezvivo/ofxFX" target="_blank">https://github.com/patriciogonzalezvivo/ofxFX</a>
</h4>
<h4><code class="bwp-syntax-inline"><span style="color: #7F7F7F; font-style: italic;">/* <br />
&nbsp; &nbsp;<br />
&nbsp;GAmuza 0.4.1 examples <br />
&nbsp;---------------------<br />
&nbsp;Shaders/blur.ga<br />
&nbsp;<br />
&nbsp;Shaders examples from ofx.fx addon<br />
&nbsp;&lt;https://github.com/patriciogonzalezvivo/ofxFX&gt;; <br />
&nbsp;this example shows the blur effect.<br />
&nbsp;<br />
&nbsp;created by n3m3da | www.d3cod3.org<br />
&nbsp;<br />
*/</span><br />
<br />
_blur = <span style="color: #FF7F32;">ofx.blur</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
cam = <span style="color: #FF7F32;">of.texture</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
<br />
<span style="color: #FF7F32;">function</span> <span style="color: #FF7F32;">setup</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; cam:<span style="color: #FF7F32;">allocate</span><span style="color: #000000;">&#40;</span><span style="color: #1F73B3;">CAPTURE_W</span>,<span style="color: #1F73B3;">CAPTURE_H</span>,GL_RGB<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; _blur:<span style="color: #FF7F32;">allocate</span><span style="color: #000000;">&#40;</span><span style="color: #1F73B3;">CAPTURE_W</span>,<span style="color: #1F73B3;">CAPTURE_H</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; _blur:<span style="color: #FF7F32;">setPasses</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">6</span><span style="color: #000000;">&#41;</span><br />
<span style="color: #FF7F32;">end</span><br />
<br />
<span style="color: #FF7F32;">function</span> <span style="color: #FF7F32;">update</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; cam = <span style="color: #FF7F32;">ga.cameraTexture</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">0</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; _blur:<span style="color: #FF7F32;">setRadius</span><span style="color: #000000;">&#40;</span><span style="color: #FF7F32;">ga.mouseX</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>/<span style="color: #1F73B3;">OUTPUT_W</span>*<span style="color: #000000;">10</span><span style="color: #000000;">&#41;</span><br />
<span style="color: #FF7F32;">end</span><br />
<br />
<span style="color: #FF7F32;">function</span> <span style="color: #FF7F32;">draw</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">ga.background</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">0.0</span>,<span style="color: #000000;">1.0</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; _blur:<span style="color: #FF7F32;">beginFx</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">of.setColor</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">255</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cam:<span style="color: #FF7F32;">draw</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">0</span>,<span style="color: #000000;">0</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">of.circle</span><span style="color: #000000;">&#40;</span><span style="color: #FF7F32;">ga.mouseX</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>,<span style="color: #FF7F32;">ga.mouseY</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>,<span style="color: #000000;">5</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; _blur:<span style="color: #FF7F32;">endFx</span><span style="color: #000000;">&#40;</span><span style="color: #FF7F32;">true</span><span style="color: #000000;">&#41;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">of.pushMatrix</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">of.scale</span><span style="color: #000000;">&#40;</span><span style="color: #1F73B3;">OUTPUT_W</span>/<span style="color: #1F73B3;">CAPTURE_W</span>,<span style="color: #1F73B3;">OUTPUT_H</span>/<span style="color: #1F73B3;">CAPTURE_H</span>,<span style="color: #000000;">1</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">of.setColor</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">255</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _blur:<span style="color: #FF7F32;">draw</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">0</span>,<span style="color: #000000;">0</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">of.popMatrix</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">of.setColor</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">255</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; cam:<span style="color: #FF7F32;">draw</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">0</span>,<span style="color: #000000;">0</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <br />
<span style="color: #FF7F32;">end</span></code></h4>
]]></content:encoded>
			<wfw:commentRss>http://gamuza.d3cod3.org/examples/blur/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>composite</title>
		<link>http://gamuza.d3cod3.org/examples/composite/</link>
		<comments>http://gamuza.d3cod3.org/examples/composite/#comments</comments>
		<pubDate>Wed, 19 Sep 2012 13:55:34 +0000</pubDate>
		<dc:creator>n3m3da</dc:creator>
				<category><![CDATA[examples]]></category>
		<category><![CDATA[exshaders]]></category>

		<guid isPermaLink="false">http://gamuza.d3cod3.org/?p=2132</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<img src="http://www.d3cod3.org/gamuza/examplesImages/Shaders/composite.jpg" width="500" height="313" />
<h4>Shaders examples from ofx.fx() class.<br />
This example shows how to composite from different effects.<br />
Original addon from patriciogonzalezvivo <a href="https://github.com/patriciogonzalezvivo/ofxFX" target="_blank">https://github.com/patriciogonzalezvivo/ofxFX</a>
</h4>
<h4><code class="bwp-syntax-inline"><span style="color: #7F7F7F; font-style: italic;">/* <br />
&nbsp; &nbsp;<br />
&nbsp;GAmuza 0.4.1 examples <br />
&nbsp;---------------------<br />
&nbsp;Shaders/composite.ga<br />
&nbsp;<br />
&nbsp;Shaders examples from ofx.fx addon<br />
&nbsp;&lt;https://github.com/patriciogonzalezvivo/ofxFX&gt;; <br />
&nbsp;this example shows how to composite from different effects.<br />
&nbsp;<br />
&nbsp;created by n3m3da | www.d3cod3.org<br />
&nbsp;<br />
*/</span><br />
<br />
oldTv = <span style="color: #FF7F32;">ofx.oldTv</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
<span style="color: #FF7F32;">blur</span> = <span style="color: #FF7F32;">ofx.blur</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
maskFx = <span style="color: #FF7F32;">ofx.mask</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
mask = <span style="color: #FF7F32;">of.image</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
cam = <span style="color: #FF7F32;">of.texture</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
<br />
<span style="color: #FF7F32;">function</span> <span style="color: #FF7F32;">setup</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; mask:<span style="color: #FF7F32;">loadImage</span><span style="color: #000000;">&#40;</span><span style="color: #FF1919;">&quot;images/mask.png&quot;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; mask:<span style="color: #FF7F32;">resize</span><span style="color: #000000;">&#40;</span><span style="color: #1F73B3;">OUTPUT_W</span>,<span style="color: #1F73B3;">OUTPUT_H</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; maskFx:<span style="color: #FF7F32;">allocate</span><span style="color: #000000;">&#40;</span><span style="color: #1F73B3;">OUTPUT_W</span>,<span style="color: #1F73B3;">OUTPUT_H</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #FF7F32;">blur</span>:<span style="color: #FF7F32;">allocate</span><span style="color: #000000;">&#40;</span><span style="color: #1F73B3;">OUTPUT_W</span>,<span style="color: #1F73B3;">OUTPUT_H</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #FF7F32;">blur</span>:<span style="color: #FF7F32;">setPasses</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">10</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; oldTv:<span style="color: #FF7F32;">allocate</span><span style="color: #000000;">&#40;</span><span style="color: #1F73B3;">OUTPUT_W</span>,<span style="color: #1F73B3;">OUTPUT_H</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; oldTv:<span style="color: #FF7F32;">setRows</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">0.01</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; oldTv:<span style="color: #FF7F32;">setBrightness</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">1.0</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; cam:<span style="color: #FF7F32;">allocate</span><span style="color: #000000;">&#40;</span><span style="color: #1F73B3;">CAPTURE_W</span>,<span style="color: #1F73B3;">CAPTURE_H</span>,GL_RGB<span style="color: #000000;">&#41;</span><br />
<span style="color: #FF7F32;">end</span><br />
<br />
<span style="color: #FF7F32;">function</span> <span style="color: #FF7F32;">update</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; cam = <span style="color: #FF7F32;">ga.cameraTexture</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">0</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #FF7F32;">blur</span>:<span style="color: #FF7F32;">setRadius</span><span style="color: #000000;">&#40;</span><span style="color: #FF7F32;">ga.mouseX</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>/<span style="color: #000000;">100</span><span style="color: #000000;">&#41;</span><br />
<span style="color: #FF7F32;">end</span><br />
<br />
<span style="color: #FF7F32;">function</span> <span style="color: #FF7F32;">draw</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">ga.background</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">0.0</span>,<span style="color: #000000;">1.0</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7F7F7F; font-style: italic;">// draw the camera inside blur fx</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">blur</span>:<span style="color: #FF7F32;">beginFx</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">of.setColor</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">255</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cam:<span style="color: #FF7F32;">draw</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">0</span>,<span style="color: #000000;">0</span>,<span style="color: #1F73B3;">OUTPUT_W</span>,<span style="color: #1F73B3;">OUTPUT_H</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">blur</span>:<span style="color: #FF7F32;">endFx</span><span style="color: #000000;">&#40;</span><span style="color: #FF7F32;">false</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #7F7F7F; font-style: italic;">// create a mask</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; maskFx:<span style="color: #FF7F32;">beginMask</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">of.setColor</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">255</span>*<span style="color: #FF7F32;">ga.mouseY</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>/<span style="color: #1F73B3;">OUTPUT_H</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mask:<span style="color: #FF7F32;">draw</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">0</span>,<span style="color: #000000;">0</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; maskFx:<span style="color: #FF7F32;">endMask</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7F7F7F; font-style: italic;">// draw the camera with the mask</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; maskFx:<span style="color: #FF7F32;">beginFx</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cam:<span style="color: #FF7F32;">draw</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">0</span>,<span style="color: #000000;">0</span>,<span style="color: #1F73B3;">OUTPUT_W</span>,<span style="color: #1F73B3;">OUTPUT_H</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; maskFx:<span style="color: #FF7F32;">endFx</span><span style="color: #000000;">&#40;</span><span style="color: #FF7F32;">false</span><span style="color: #000000;">&#41;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7F7F7F; font-style: italic;">// draw the masked camera on top of the blurred camera</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7F7F7F; font-style: italic;">// all inside the oldTV effect</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; oldTv:<span style="color: #FF7F32;">beginFx</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">blur</span>:<span style="color: #FF7F32;">draw</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">0</span>,<span style="color: #000000;">0</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; maskFx:<span style="color: #FF7F32;">draw</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">0</span>,<span style="color: #000000;">0</span><span style="color: #000000;">&#41;</span> &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; oldTv:<span style="color: #FF7F32;">endFx</span><span style="color: #000000;">&#40;</span><span style="color: #FF7F32;">false</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7F7F7F; font-style: italic;">// finally draw the oldTV container</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; oldTv:<span style="color: #FF7F32;">draw</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">0</span>,<span style="color: #000000;">0</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <br />
<span style="color: #FF7F32;">end</span></code></h4>
]]></content:encoded>
			<wfw:commentRss>http://gamuza.d3cod3.org/examples/composite/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FBOWithShader</title>
		<link>http://gamuza.d3cod3.org/examples/fbowithshader/</link>
		<comments>http://gamuza.d3cod3.org/examples/fbowithshader/#comments</comments>
		<pubDate>Wed, 19 Sep 2012 13:50:38 +0000</pubDate>
		<dc:creator>n3m3da</dc:creator>
				<category><![CDATA[examples]]></category>
		<category><![CDATA[exshaders]]></category>

		<guid isPermaLink="false">http://gamuza.d3cod3.org/?p=2130</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<img src="http://www.d3cod3.org/gamuza/examplesImages/Shaders/FBOWithShader.jpg" width="500" height="281" />
<h4>Simple example for loading a shader inside an FBO texture.
<br />
</h4>, <h4>Simple example for loading a shader inside an FBO texture.
<br />
</h4>
<h4><code class="bwp-syntax-inline"><span style="color: #7F7F7F; font-style: italic;">/* <br />
&nbsp; &nbsp;<br />
&nbsp;GAmuza 0.4.1 examples <br />
&nbsp;---------------------<br />
&nbsp;Shaders/FBOWithShader.ga<br />
&nbsp;<br />
&nbsp;Simple example for loading a shader inside an FBO texture.<br />
&nbsp;<br />
&nbsp;created by n3m3da | www.d3cod3.org<br />
&nbsp;<br />
*/</span><br />
<br />
fboTex = <span style="color: #FF7F32;">of.fbo</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
shader = <span style="color: #FF7F32;">of.shader</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
start = <span style="color: #FF7F32;">true</span><br />
<br />
<span style="color: #FF7F32;">function</span> <span style="color: #FF7F32;">setup</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #FF7F32;">of.setCircleResolution</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">6</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #7F7F7F; font-style: italic;">// allocate(width,height,color range,samples)</span><br />
&nbsp; &nbsp; fboTex:<span style="color: #FF7F32;">allocate</span><span style="color: #000000;">&#40;</span><span style="color: #1F73B3;">OUTPUT_W</span>,<span style="color: #1F73B3;">OUTPUT_H</span>,GL_RGB,<span style="color: #000000;">0</span><span style="color: #000000;">&#41;</span> &nbsp;<br />
&nbsp; &nbsp; shader:<span style="color: #FF7F32;">load</span><span style="color: #000000;">&#40;</span><span style="color: #FF7F32;">ga.importFile</span><span style="color: #000000;">&#40;</span><span style="color: #FF1919;">&quot;noise&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><br />
<span style="color: #FF7F32;">end</span><br />
<br />
<span style="color: #FF7F32;">function</span> <span style="color: #FF7F32;">update</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <br />
<span style="color: #FF7F32;">end</span><br />
<br />
<span style="color: #FF7F32;">function</span> <span style="color: #FF7F32;">draw</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">ga.background</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">0.0</span>,<span style="color: #000000;">1.0</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7F7F7F; font-style: italic;">// draw inside de FBO texture</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; fboTex:<span style="color: #FF7F32;">beginFbo</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #7F7F7F; font-style: italic;">// start FBO</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; shader:<span style="color: #FF7F32;">beginShader</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #7F7F7F; font-style: italic;">// start shader</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7F7F7F; font-style: italic;">// clean the FBO just once at beginning</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">if</span> start <span style="color: #FF7F32;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; start = <span style="color: #FF7F32;">false</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">of.clear</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">0</span>,<span style="color: #000000;">0</span>,<span style="color: #000000;">0</span>,<span style="color: #000000;">255</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">end</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7F7F7F; font-style: italic;">// simulate trails effect</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">of.enableAlphaBlending</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">of.fill</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">of.setColor</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">0</span>,<span style="color: #000000;">0</span>,<span style="color: #000000;">0</span>,<span style="color: #000000;">7</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">of.rect</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">0</span>,<span style="color: #000000;">0</span>,fboTex:<span style="color: #FF7F32;">getWidth</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>,fboTex:<span style="color: #FF7F32;">getHeight</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">of.disableAlphaBlending</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7F7F7F; font-style: italic;">// draw a red circle</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">of.setColor</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">19</span>,<span style="color: #000000;">170</span>,<span style="color: #000000;">211</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">of.circle</span><span style="color: #000000;">&#40;</span><span style="color: #FF7F32;">of.randomuf</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>*fboTex:<span style="color: #FF7F32;">getWidth</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>, <span style="color: #FF7F32;">of.randomuf</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>*fboTex:<span style="color: #FF7F32;">getHeight</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>, <span style="color: #000000;">200</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; shader:<span style="color: #FF7F32;">endShader</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #7F7F7F; font-style: italic;">// close shader</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; fboTex:<span style="color: #FF7F32;">endFbo</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #7F7F7F; font-style: italic;">// close FBO</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7F7F7F; font-style: italic;">// draw the FBO with shader</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">of.setColor</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">255</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; fboTex:<span style="color: #FF7F32;">draw</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">0</span>,<span style="color: #000000;">0</span>,<span style="color: #1F73B3;">OUTPUT_W</span>,<span style="color: #1F73B3;">OUTPUT_H</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <br />
<span style="color: #FF7F32;">end</span></code></h4>
]]></content:encoded>
			<wfw:commentRss>http://gamuza.d3cod3.org/examples/fbowithshader/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>glow</title>
		<link>http://gamuza.d3cod3.org/examples/glow/</link>
		<comments>http://gamuza.d3cod3.org/examples/glow/#comments</comments>
		<pubDate>Wed, 19 Sep 2012 13:49:42 +0000</pubDate>
		<dc:creator>n3m3da</dc:creator>
				<category><![CDATA[examples]]></category>
		<category><![CDATA[exshaders]]></category>

		<guid isPermaLink="false">http://gamuza.d3cod3.org/?p=2128</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<img src="http://www.d3cod3.org/gamuza/examplesImages/Shaders/glow.jpg" width="500" height="313" />
<h4>Shaders examples from ofx.fx() class.<br />
This example shows the glow effect.<br />
Original addon from patriciogonzalezvivo <a href="https://github.com/patriciogonzalezvivo/ofxFX" target="_blank">https://github.com/patriciogonzalezvivo/ofxFX</a>
</h4>
<h4><code class="bwp-syntax-inline"><span style="color: #7F7F7F; font-style: italic;">/* <br />
&nbsp; &nbsp;<br />
&nbsp;GAmuza 0.4.1 examples <br />
&nbsp;---------------------<br />
&nbsp;Shaders/glow.ga<br />
&nbsp;<br />
&nbsp;Shaders examples from ofx.fx addon<br />
&nbsp;&lt;https://github.com/patriciogonzalezvivo/ofxFX&gt;; <br />
&nbsp;this example shows the glow effect.<br />
&nbsp;<br />
&nbsp;created by n3m3da | www.d3cod3.org<br />
&nbsp;<br />
*/</span><br />
<br />
glow = <span style="color: #FF7F32;">ofx.glow</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
cam = <span style="color: #FF7F32;">of.texture</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
<br />
<span style="color: #FF7F32;">function</span> <span style="color: #FF7F32;">setup</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; cam:<span style="color: #FF7F32;">allocate</span><span style="color: #000000;">&#40;</span><span style="color: #1F73B3;">OUTPUT_W</span>,<span style="color: #1F73B3;">OUTPUT_H</span>,GL_RGB<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; glow:<span style="color: #FF7F32;">allocate</span><span style="color: #000000;">&#40;</span><span style="color: #1F73B3;">OUTPUT_W</span>,<span style="color: #1F73B3;">OUTPUT_H</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; glow:<span style="color: #FF7F32;">setPasses</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">6</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <br />
<span style="color: #FF7F32;">end</span><br />
<br />
<span style="color: #FF7F32;">function</span> <span style="color: #FF7F32;">update</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; cam = <span style="color: #FF7F32;">ga.cameraTexture</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">0</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; glow:<span style="color: #FF7F32;">setRadius</span><span style="color: #000000;">&#40;</span><span style="color: #FF7F32;">ga.mouseX</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>/<span style="color: #1F73B3;">OUTPUT_W</span>*<span style="color: #000000;">20</span><span style="color: #000000;">&#41;</span><br />
<span style="color: #FF7F32;">end</span><br />
<br />
<span style="color: #FF7F32;">function</span> <span style="color: #FF7F32;">draw</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">ga.background</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">0.0</span>,<span style="color: #000000;">1.0</span><span style="color: #000000;">&#41;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; glow:<span style="color: #FF7F32;">beginFx</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">of.setColor</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">255</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cam:<span style="color: #FF7F32;">draw</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">0</span>,<span style="color: #000000;">0</span>,<span style="color: #1F73B3;">OUTPUT_W</span>,<span style="color: #1F73B3;">OUTPUT_H</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; glow:<span style="color: #FF7F32;">endFx</span><span style="color: #000000;">&#40;</span><span style="color: #FF7F32;">false</span><span style="color: #000000;">&#41;</span><br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; glow:<span style="color: #FF7F32;">draw</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">0</span>,<span style="color: #000000;">0</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
<span style="color: #FF7F32;">end</span></code></h4>
]]></content:encoded>
			<wfw:commentRss>http://gamuza.d3cod3.org/examples/glow/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>grayscott</title>
		<link>http://gamuza.d3cod3.org/examples/grayscott/</link>
		<comments>http://gamuza.d3cod3.org/examples/grayscott/#comments</comments>
		<pubDate>Wed, 19 Sep 2012 13:45:51 +0000</pubDate>
		<dc:creator>n3m3da</dc:creator>
				<category><![CDATA[examples]]></category>
		<category><![CDATA[exshaders]]></category>

		<guid isPermaLink="false">http://gamuza.d3cod3.org/?p=2126</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<img src="http://www.d3cod3.org/gamuza/examplesImages/Shaders/grayscott.jpg" width="500" height="313" />
<h4>Shaders examples from ofx.fx() class.<br />
This example shows the grayscott algorithm effect.<br />
Original addon from patriciogonzalezvivo <a href="https://github.com/patriciogonzalezvivo/ofxFX" target="_blank">https://github.com/patriciogonzalezvivo/ofxFX</a>
</h4>
<h4><code class="bwp-syntax-inline"><span style="color: #7F7F7F; font-style: italic;">/* <br />
&nbsp; &nbsp;<br />
&nbsp;GAmuza 0.4.1 examples <br />
&nbsp;---------------------<br />
&nbsp;Shaders/grayscott.ga<br />
&nbsp;<br />
&nbsp;Shaders examples from ofx.fx addon<br />
&nbsp;&lt;https://github.com/patriciogonzalezvivo/ofxFX&gt;; <br />
&nbsp;this example shows the grayscott algorithm effect.<br />
&nbsp;<br />
&nbsp;created by n3m3da | www.d3cod3.org<br />
&nbsp;<br />
*/</span><br />
<br />
grayscott = <span style="color: #FF7F32;">ofx.grayScott</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
cam = <span style="color: #FF7F32;">of.texture</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
<br />
<span style="color: #FF7F32;">function</span> <span style="color: #FF7F32;">setup</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; cam:<span style="color: #FF7F32;">allocate</span><span style="color: #000000;">&#40;</span><span style="color: #1F73B3;">CAPTURE_W</span>,<span style="color: #1F73B3;">CAPTURE_H</span>,GL_RGB<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; grayscott:<span style="color: #FF7F32;">allocate</span><span style="color: #000000;">&#40;</span><span style="color: #1F73B3;">CAPTURE_W</span>,<span style="color: #1F73B3;">CAPTURE_H</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; grayscott:<span style="color: #FF7F32;">setIterations</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">5</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; grayscott:<span style="color: #FF7F32;">setDiffV</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">0.01</span><span style="color: #000000;">&#41;</span><br />
<span style="color: #FF7F32;">end</span><br />
<br />
<span style="color: #FF7F32;">function</span> <span style="color: #FF7F32;">update</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; cam = <span style="color: #FF7F32;">ga.cameraTexture</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">0</span><span style="color: #000000;">&#41;</span><br />
<span style="color: #FF7F32;">end</span><br />
<br />
<span style="color: #FF7F32;">function</span> <span style="color: #FF7F32;">draw</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #FF7F32;">ga.background</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">0.0</span>,<span style="color: #000000;">1.0</span><span style="color: #000000;">&#41;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; grayscott:<span style="color: #FF7F32;">beginFx</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">of.setColor</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">10</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cam:<span style="color: #FF7F32;">draw</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">0</span>,<span style="color: #000000;">0</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; grayscott:<span style="color: #FF7F32;">endFx</span><span style="color: #000000;">&#40;</span><span style="color: #FF7F32;">false</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">of.pushMatrix</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">of.scale</span><span style="color: #000000;">&#40;</span><span style="color: #1F73B3;">OUTPUT_W</span>/<span style="color: #1F73B3;">CAPTURE_W</span>,<span style="color: #1F73B3;">OUTPUT_H</span>/<span style="color: #1F73B3;">CAPTURE_H</span>,<span style="color: #000000;">1</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; grayscott:<span style="color: #FF7F32;">draw</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">0</span>,<span style="color: #000000;">0</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">of.popMatrix</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
<span style="color: #FF7F32;">end</span></code></h4>
]]></content:encoded>
			<wfw:commentRss>http://gamuza.d3cod3.org/examples/grayscott/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>oldTV</title>
		<link>http://gamuza.d3cod3.org/examples/oldtv/</link>
		<comments>http://gamuza.d3cod3.org/examples/oldtv/#comments</comments>
		<pubDate>Wed, 19 Sep 2012 13:39:42 +0000</pubDate>
		<dc:creator>n3m3da</dc:creator>
				<category><![CDATA[examples]]></category>
		<category><![CDATA[exshaders]]></category>

		<guid isPermaLink="false">http://gamuza.d3cod3.org/?p=2124</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<img src="http://www.d3cod3.org/gamuza/examplesImages/Shaders/oldTv.jpg" width="500" height="313" />
<h4>Shaders examples from ofx.fx() class.<br />
This example shows the oldTv effect.<br />
Original addon from patriciogonzalezvivo <a href="https://github.com/patriciogonzalezvivo/ofxFX" target="_blank">https://github.com/patriciogonzalezvivo/ofxFX</a>
</h4>
<h4><code class="bwp-syntax-inline"><span style="color: #7F7F7F; font-style: italic;">/* <br />
&nbsp; &nbsp;<br />
&nbsp;GAmuza 0.4.1 examples <br />
&nbsp;---------------------<br />
&nbsp;Shaders/oldTV.ga<br />
&nbsp;<br />
&nbsp;Shaders examples from ofx.fx addon<br />
&nbsp;&lt;https://github.com/patriciogonzalezvivo/ofxFX&gt;; <br />
&nbsp;this example shows the oldTv effect.<br />
&nbsp;<br />
&nbsp;created by n3m3da | www.d3cod3.org<br />
&nbsp;<br />
*/</span><br />
<br />
oldTv = <span style="color: #FF7F32;">ofx.oldTv</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
cam = <span style="color: #FF7F32;">of.texture</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
<br />
<span style="color: #FF7F32;">function</span> <span style="color: #FF7F32;">setup</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; cam:<span style="color: #FF7F32;">allocate</span><span style="color: #000000;">&#40;</span><span style="color: #1F73B3;">CAPTURE_W</span>,<span style="color: #1F73B3;">CAPTURE_H</span>,GL_RGB<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; oldTv:<span style="color: #FF7F32;">allocate</span><span style="color: #000000;">&#40;</span><span style="color: #1F73B3;">OUTPUT_W</span>,<span style="color: #1F73B3;">OUTPUT_H</span><span style="color: #000000;">&#41;</span><br />
<span style="color: #FF7F32;">end</span><br />
<br />
<span style="color: #FF7F32;">function</span> <span style="color: #FF7F32;">update</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; cam = <span style="color: #FF7F32;">ga.cameraTexture</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">0</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; oldTv:<span style="color: #FF7F32;">setRows</span><span style="color: #000000;">&#40;</span><span style="color: #FF7F32;">ga.mouseX</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>/<span style="color: #1F73B3;">OUTPUT_W</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; oldTv:<span style="color: #FF7F32;">setBrightness</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">1.0</span><span style="color: #000000;">&#41;</span><br />
<span style="color: #FF7F32;">end</span><br />
<br />
<span style="color: #FF7F32;">function</span> <span style="color: #FF7F32;">draw</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">ga.background</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">0.0</span>,<span style="color: #000000;">1.0</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; oldTv:<span style="color: #FF7F32;">beginFx</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">of.setColor</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">255</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cam:<span style="color: #FF7F32;">draw</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">0</span>,<span style="color: #000000;">0</span>,<span style="color: #1F73B3;">OUTPUT_W</span>,<span style="color: #1F73B3;">OUTPUT_H</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; oldTv:<span style="color: #FF7F32;">endFx</span><span style="color: #000000;">&#40;</span><span style="color: #FF7F32;">true</span><span style="color: #000000;">&#41;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">of.enableAlphaBlending</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; oldTv:<span style="color: #FF7F32;">draw</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">0</span>,<span style="color: #000000;">0</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">of.disableAlphaBlending</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
<span style="color: #FF7F32;">end</span></code></h4>
]]></content:encoded>
			<wfw:commentRss>http://gamuza.d3cod3.org/examples/oldtv/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mask</title>
		<link>http://gamuza.d3cod3.org/examples/mask/</link>
		<comments>http://gamuza.d3cod3.org/examples/mask/#comments</comments>
		<pubDate>Wed, 19 Sep 2012 13:39:10 +0000</pubDate>
		<dc:creator>n3m3da</dc:creator>
				<category><![CDATA[examples]]></category>
		<category><![CDATA[exshaders]]></category>

		<guid isPermaLink="false">http://gamuza.d3cod3.org/?p=2122</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<img src="http://www.d3cod3.org/gamuza/examplesImages/Shaders/mask.jpg" width="500" height="281" />
<h4>Shaders examples from ofx.fx() class.<br />
This example shows the mask effect.<br />
Original addon from patriciogonzalezvivo <a href="https://github.com/patriciogonzalezvivo/ofxFX" target="_blank">https://github.com/patriciogonzalezvivo/ofxFX</a>
</h4>
<h4><code class="bwp-syntax-inline"><span style="color: #7F7F7F; font-style: italic;">/* <br />
&nbsp; &nbsp;<br />
&nbsp;GAmuza 0.4.1 examples <br />
&nbsp;---------------------<br />
&nbsp;Shaders/mask.ga<br />
&nbsp;<br />
&nbsp;Shaders examples from ofx.fx addon<br />
&nbsp;&lt;https://github.com/patriciogonzalezvivo/ofxFX&gt;; <br />
&nbsp;this example shows the mask effect.<br />
&nbsp;<br />
&nbsp;created by n3m3da | www.d3cod3.org<br />
&nbsp;<br />
*/</span><br />
<br />
maskFx = <span style="color: #FF7F32;">ofx.mask</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
top = <span style="color: #FF7F32;">of.image</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
bottom = <span style="color: #FF7F32;">of.image</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
mask = <span style="color: #FF7F32;">of.image</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
<br />
<span style="color: #FF7F32;">function</span> <span style="color: #FF7F32;">setup</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; top:<span style="color: #FF7F32;">loadImage</span><span style="color: #000000;">&#40;</span><span style="color: #FF7F32;">ga.importFile</span><span style="color: #000000;">&#40;</span><span style="color: #FF1919;">&quot;misteryMen0.jpg&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; mask:<span style="color: #FF7F32;">loadImage</span><span style="color: #000000;">&#40;</span><span style="color: #FF7F32;">ga.importFile</span><span style="color: #000000;">&#40;</span><span style="color: #FF1919;">&quot;horizontalMask.png&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; mask:<span style="color: #FF7F32;">resize</span><span style="color: #000000;">&#40;</span>top.width,top.height<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; bottom:<span style="color: #FF7F32;">loadImage</span><span style="color: #000000;">&#40;</span><span style="color: #FF7F32;">ga.importFile</span><span style="color: #000000;">&#40;</span><span style="color: #FF1919;">&quot;misteryMen1.jpg&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; maskFx:<span style="color: #FF7F32;">allocate</span><span style="color: #000000;">&#40;</span>top.width,top.height<span style="color: #000000;">&#41;</span> <br />
<span style="color: #FF7F32;">end</span><br />
<br />
<span style="color: #FF7F32;">function</span> <span style="color: #FF7F32;">draw</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">ga.background</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">0.0</span>,<span style="color: #000000;">1.0</span><span style="color: #000000;">&#41;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7F7F7F; font-style: italic;">// create mask</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; maskFx:<span style="color: #FF7F32;">beginMask</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">of.clear</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">255</span>,<span style="color: #000000;">255</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">of.setColor</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">255</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mask:<span style="color: #FF7F32;">draw</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">0</span>,<span style="color: #FF7F32;">ga.mouseY</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>-<span style="color: #000000;">&#40;</span><span style="color: #1F73B3;">OUTPUT_H</span>/<span style="color: #000000;">2</span> - top.height/<span style="color: #000000;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; maskFx:<span style="color: #FF7F32;">endMask</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">of.pushMatrix</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">of.translate</span><span style="color: #000000;">&#40;</span><span style="color: #1F73B3;">OUTPUT_W</span>/<span style="color: #000000;">2</span> - top.width/<span style="color: #000000;">2</span>, <span style="color: #1F73B3;">OUTPUT_H</span>/<span style="color: #000000;">2</span> - top.height/<span style="color: #000000;">2</span>,<span style="color: #000000;">0</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7F7F7F; font-style: italic;">// draw the base image</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">of.setColor</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">255</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; bottom:<span style="color: #FF7F32;">draw</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">0</span>,<span style="color: #000000;">0</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #7F7F7F; font-style: italic;">// draw the masked image</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; maskFx:<span style="color: #FF7F32;">beginFx</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; top:<span style="color: #FF7F32;">draw</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">0</span>,<span style="color: #000000;">0</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; maskFx:<span style="color: #FF7F32;">endFx</span><span style="color: #000000;">&#40;</span><span style="color: #FF7F32;">true</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">of.popMatrix</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
<span style="color: #FF7F32;">end</span></code>/h4>
]]></content:encoded>
			<wfw:commentRss>http://gamuza.d3cod3.org/examples/mask/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CH2_attractRepel</title>
		<link>http://gamuza.d3cod3.org/examples/ch2_attractrepel/</link>
		<comments>http://gamuza.d3cod3.org/examples/ch2_attractrepel/#comments</comments>
		<pubDate>Wed, 19 Sep 2012 13:32:55 +0000</pubDate>
		<dc:creator>n3m3da</dc:creator>
				<category><![CDATA[examples]]></category>
		<category><![CDATA[exnoc]]></category>

		<guid isPermaLink="false">http://gamuza.d3cod3.org/?p=2120</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<img src="http://www.d3cod3.org/gamuza/examplesImages/Shiffman_NatureOfCode/CH2_attractRepel.jpg" width="500" height="281" />
<h4>This example is one of the series of GAmuza adaptation to Daniel Shiffman <strong>Nature of Code</strong><br />
book examples.<br />
<br />
More info: <a href="http://www.shiffman.net/teaching/nature/" target="_blank">http://www.shiffman.net/teaching/nature/</a>
</h4>
<h4><code class="bwp-syntax-inline"><span style="color: #7F7F7F; font-style: italic;">/* <br />
&nbsp; &nbsp;<br />
&nbsp;GAmuza 0.4.1 examples<br />
&nbsp;---------------------<br />
&nbsp;Shiffman_NatureOfCode/CH2_attractRepel.ga<br />
&nbsp;<br />
&nbsp;This example is one of the series of GAmuza adaptation to<br />
&nbsp;Daniel Shiffman &lt;Nature of Code&gt; book examples.<br />
&nbsp;<br />
&nbsp;More info: &lt;http://www.shiffman.net/teaching/nature/&gt;<br />
&nbsp;<br />
&nbsp;created by n3m3da | www.d3cod3.org<br />
&nbsp;<br />
*/</span><br />
<br />
<span style="color: #FF7F32;">dofile</span><span style="color: #000000;">&#40;</span><span style="color: #FF7F32;">ga.importFile</span><span style="color: #000000;">&#40;</span><span style="color: #FF1919;">&quot;classes/Mover.ga&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><br />
<span style="color: #FF7F32;">dofile</span><span style="color: #000000;">&#40;</span><span style="color: #FF7F32;">ga.importFile</span><span style="color: #000000;">&#40;</span><span style="color: #FF1919;">&quot;classes/Attractor.ga&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><br />
<br />
<br />
g = <span style="color: #000000;">1</span><br />
NUM_MOVERS = <span style="color: #000000;">20</span><br />
movers = <span style="color: #000000;">&#123;</span><span style="color: #000000;">&#125;</span><br />
a = Attractor<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
<br />
<span style="color: #FF7F32;">function</span> <span style="color: #FF7F32;">setup</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">of.setCircleResolution</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">50</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">for</span> i=<span style="color: #000000;">0</span>,NUM_MOVERS-<span style="color: #000000;">1</span> <span style="color: #FF7F32;">do</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; movers<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span> = Mover<span style="color: #000000;">&#40;</span><span style="color: #FF7F32;">of.random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">4</span>,<span style="color: #000000;">12</span><span style="color: #000000;">&#41;</span>,<span style="color: #FF7F32;">of.random</span><span style="color: #000000;">&#40;</span><span style="color: #1F73B3;">OUTPUT_W</span><span style="color: #000000;">&#41;</span>,<span style="color: #FF7F32;">of.random</span><span style="color: #000000;">&#40;</span><span style="color: #1F73B3;">OUTPUT_H</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">end</span><br />
<span style="color: #FF7F32;">end</span><br />
<br />
<span style="color: #FF7F32;">function</span> <span style="color: #FF7F32;">update</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">for</span> i=<span style="color: #000000;">0</span>,NUM_MOVERS-<span style="color: #000000;">1</span> <span style="color: #FF7F32;">do</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">for</span> j=<span style="color: #000000;">0</span>,NUM_MOVERS-<span style="color: #000000;">1</span> <span style="color: #FF7F32;">do</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">if</span> i != j <span style="color: #FF7F32;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; force = <span style="color: #FF7F32;">of.vec2f</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; force = movers<span style="color: #000000;">&#91;</span>j<span style="color: #000000;">&#93;</span>:repel<span style="color: #000000;">&#40;</span>movers<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; movers<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span>:applyForce<span style="color: #000000;">&#40;</span>force<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">end</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">end</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; attraction = <span style="color: #FF7F32;">of.vec2f</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; attraction = a:attract<span style="color: #000000;">&#40;</span>movers<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; movers<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span>:applyForce<span style="color: #000000;">&#40;</span>attraction<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; movers<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span>:<span style="color: #FF7F32;">update</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; movers<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span>:checkEdges<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">end</span><br />
<span style="color: #FF7F32;">end</span><br />
<br />
<span style="color: #FF7F32;">function</span> <span style="color: #FF7F32;">draw</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">ga.background</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">1.0</span>,<span style="color: #000000;">0.1</span><span style="color: #000000;">&#41;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; a:display<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">for</span> i=<span style="color: #000000;">0</span>,NUM_MOVERS-<span style="color: #000000;">1</span> <span style="color: #FF7F32;">do</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; movers<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span>:display<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">end</span><br />
<span style="color: #FF7F32;">end</span><br />
<span style="color: #7F7F7F; font-style: italic;">//-------------------------------------</span><br />
<span style="color: #7F7F7F; font-style: italic;">// Attractor Class</span><br />
<br />
class <span style="color: #FF1919;">'Attractor'</span><br />
<br />
<span style="color: #FF7F32;">function</span> Attractor:__init<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #FF7F32;">self</span>.mass = <span style="color: #000000;">60</span><br />
&nbsp; &nbsp; <span style="color: #FF7F32;">self</span>.loc = <span style="color: #FF7F32;">of.vec2f</span><span style="color: #000000;">&#40;</span><span style="color: #1F73B3;">OUTPUT_W</span>/<span style="color: #000000;">2</span>,<span style="color: #1F73B3;">OUTPUT_H</span>/<span style="color: #000000;">2</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #FF7F32;">self</span>.dragging = <span style="color: #FF7F32;">false</span><br />
&nbsp; &nbsp; <span style="color: #FF7F32;">self</span>.rollover = <span style="color: #FF7F32;">false</span><br />
&nbsp; &nbsp; <span style="color: #FF7F32;">self</span>.drag = <span style="color: #FF7F32;">of.vec2f</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">0</span>,<span style="color: #000000;">0</span><span style="color: #000000;">&#41;</span><br />
<span style="color: #FF7F32;">end</span><br />
<br />
<span style="color: #FF7F32;">function</span> Attractor:attract<span style="color: #000000;">&#40;</span>mover<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; force = <span style="color: #FF7F32;">of.vec2f</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; force = <span style="color: #FF7F32;">self</span>.loc - mover.loc<br />
&nbsp; &nbsp; d = force:<span style="color: #FF7F32;">length</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; d = <span style="color: #FF7F32;">of.clamp</span><span style="color: #000000;">&#40;</span>d,<span style="color: #000000;">5.0</span>,<span style="color: #000000;">25.0</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; force:<span style="color: #FF7F32;">normalize</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; strength = <span style="color: #000000;">&#40;</span>g*<span style="color: #FF7F32;">self</span>.mass*mover.mass<span style="color: #000000;">&#41;</span> / <span style="color: #FF7F32;">math.pow</span><span style="color: #000000;">&#40;</span>d,<span style="color: #000000;">2</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; force = force * strength<br />
&nbsp; &nbsp; <span style="color: #FF7F32;">return</span> force<br />
<span style="color: #FF7F32;">end</span><br />
<br />
<span style="color: #FF7F32;">function</span> Attractor:display<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #FF7F32;">of.setColor</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">0</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #FF7F32;">of.noFill</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #FF7F32;">of.circle</span><span style="color: #000000;">&#40;</span><span style="color: #FF7F32;">self</span>.loc.x,<span style="color: #FF7F32;">self</span>.loc.y,<span style="color: #FF7F32;">self</span>.mass<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #FF7F32;">of.fill</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #FF7F32;">if</span> <span style="color: #FF7F32;">self</span>.dragging <span style="color: #FF7F32;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">of.setColor</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">50</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #FF7F32;">elseif</span> <span style="color: #FF7F32;">self</span>.rollover <span style="color: #FF7F32;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">of.setColor</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">100</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #FF7F32;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">of.setColor</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">0</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #FF7F32;">end</span><br />
&nbsp; &nbsp; <span style="color: #FF7F32;">of.circle</span><span style="color: #000000;">&#40;</span><span style="color: #FF7F32;">self</span>.loc.x,<span style="color: #FF7F32;">self</span>.loc.y,<span style="color: #FF7F32;">self</span>.mass<span style="color: #000000;">&#41;</span><br />
<span style="color: #FF7F32;">end</span><br />
<br />
<span style="color: #FF7F32;">function</span> Attractor:isClicked<span style="color: #000000;">&#40;</span>mx,my<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; d = <span style="color: #FF7F32;">of.dist</span><span style="color: #000000;">&#40;</span>mx,my,<span style="color: #FF7F32;">self</span>.loc.x,<span style="color: #FF7F32;">self</span>.loc.y<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #FF7F32;">if</span> d &lt; <span style="color: #FF7F32;">self</span>.mass <span style="color: #FF7F32;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">self</span>.dragging = <span style="color: #FF7F32;">true</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">self</span>.drag:<span style="color: #FF7F32;">set</span><span style="color: #000000;">&#40;</span><span style="color: #FF7F32;">self</span>.loc.x - mx,<span style="color: #FF7F32;">self</span>.loc.y - my<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #FF7F32;">end</span><br />
<span style="color: #FF7F32;">end</span><br />
<br />
<span style="color: #FF7F32;">function</span> Attractor:isRollover<span style="color: #000000;">&#40;</span>mx,my<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; d = <span style="color: #FF7F32;">of.dist</span><span style="color: #000000;">&#40;</span>mx,my,<span style="color: #FF7F32;">self</span>.loc.x,<span style="color: #FF7F32;">self</span>.loc.y<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #FF7F32;">if</span> d &lt; <span style="color: #FF7F32;">self</span>.mass <span style="color: #FF7F32;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">self</span>.rollover = <span style="color: #FF7F32;">true</span><br />
&nbsp; &nbsp; <span style="color: #FF7F32;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">self</span>.rollover = <span style="color: #FF7F32;">false</span><br />
&nbsp; &nbsp; <span style="color: #FF7F32;">end</span><br />
<span style="color: #FF7F32;">end</span><br />
<br />
<span style="color: #FF7F32;">function</span> Attractor:stopDragging<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #FF7F32;">self</span>.dragging = <span style="color: #FF7F32;">false</span><br />
<span style="color: #FF7F32;">end</span><br />
<br />
<span style="color: #FF7F32;">function</span> Attractor:drag<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #FF7F32;">if</span> <span style="color: #FF7F32;">self</span>.dragging <span style="color: #FF7F32;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">self</span>.loc:<span style="color: #FF7F32;">set</span><span style="color: #000000;">&#40;</span><span style="color: #FF7F32;">ga.mouseX</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> + <span style="color: #FF7F32;">self</span>.drag.x,<span style="color: #FF7F32;">ga.mouseY</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> + <span style="color: #FF7F32;">self</span>.drag.y<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #FF7F32;">end</span><br />
<span style="color: #FF7F32;">end</span><br />
<span style="color: #7F7F7F; font-style: italic;">//-------------------------------------</span><br />
<span style="color: #7F7F7F; font-style: italic;">//-------------------------------------</span><br />
<span style="color: #7F7F7F; font-style: italic;">// Mover Class</span><br />
<br />
class <span style="color: #FF1919;">'Mover'</span><br />
<br />
<span style="color: #FF7F32;">function</span> Mover:__init<span style="color: #000000;">&#40;</span>m,x,y<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #FF7F32;">self</span>.mass = m<br />
&nbsp; &nbsp; <span style="color: #FF7F32;">self</span>.loc = <span style="color: #FF7F32;">of.vec2f</span><span style="color: #000000;">&#40;</span>x,y<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #FF7F32;">self</span>.vel = <span style="color: #FF7F32;">of.vec2f</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">0</span>,<span style="color: #000000;">0</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #FF7F32;">self</span>.acc = <span style="color: #FF7F32;">of.vec2f</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">0</span>,<span style="color: #000000;">0</span><span style="color: #000000;">&#41;</span><br />
<span style="color: #FF7F32;">end</span><br />
<br />
<span style="color: #FF7F32;">function</span> Mover:applyForce<span style="color: #000000;">&#40;</span>force<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; f = <span style="color: #FF7F32;">of.vec2f</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; f = force / <span style="color: #FF7F32;">self</span>.mass<br />
&nbsp; &nbsp; <span style="color: #FF7F32;">self</span>.acc = <span style="color: #FF7F32;">self</span>.acc + f<br />
<span style="color: #FF7F32;">end</span><br />
<br />
<span style="color: #FF7F32;">function</span> Mover:<span style="color: #FF7F32;">update</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #FF7F32;">self</span>.vel = <span style="color: #FF7F32;">self</span>.vel + <span style="color: #FF7F32;">self</span>.acc<br />
&nbsp; &nbsp; <span style="color: #FF7F32;">self</span>.loc = <span style="color: #FF7F32;">self</span>.loc + <span style="color: #FF7F32;">self</span>.vel<br />
&nbsp; &nbsp; <span style="color: #FF7F32;">self</span>.acc = <span style="color: #FF7F32;">self</span>.acc * <span style="color: #000000;">0</span><br />
<span style="color: #FF7F32;">end</span><br />
<br />
<span style="color: #FF7F32;">function</span> Mover:display<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #FF7F32;">of.setColor</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">0</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #FF7F32;">of.noFill</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #FF7F32;">of.circle</span><span style="color: #000000;">&#40;</span><span style="color: #FF7F32;">self</span>.loc.x,<span style="color: #FF7F32;">self</span>.loc.y,<span style="color: #FF7F32;">self</span>.mass*<span style="color: #000000;">2</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #FF7F32;">of.setColor</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">175</span>,<span style="color: #000000;">200</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #FF7F32;">of.fill</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #FF7F32;">of.circle</span><span style="color: #000000;">&#40;</span><span style="color: #FF7F32;">self</span>.loc.x,<span style="color: #FF7F32;">self</span>.loc.y,<span style="color: #FF7F32;">self</span>.mass*<span style="color: #000000;">2</span><span style="color: #000000;">&#41;</span><br />
<span style="color: #FF7F32;">end</span><br />
<br />
<span style="color: #FF7F32;">function</span> Mover:repel<span style="color: #000000;">&#40;</span>mover<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; force = <span style="color: #FF7F32;">of.vec2f</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; force = <span style="color: #FF7F32;">self</span>.loc - mover.loc<br />
&nbsp; &nbsp; <span style="color: #FF7F32;">distance</span> = force:<span style="color: #FF7F32;">length</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #FF7F32;">distance</span> = <span style="color: #FF7F32;">of.clamp</span><span style="color: #000000;">&#40;</span><span style="color: #FF7F32;">distance</span>,<span style="color: #000000;">1.0</span>,<span style="color: #000000;">10000.0</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; force = force:<span style="color: #FF7F32;">normalize</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
<br />
&nbsp; &nbsp; strenght = <span style="color: #000000;">&#40;</span>g*<span style="color: #FF7F32;">self</span>.mass*mover.mass<span style="color: #000000;">&#41;</span> / <span style="color: #FF7F32;">math.pow</span><span style="color: #000000;">&#40;</span><span style="color: #FF7F32;">distance</span>,<span style="color: #000000;">2</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; force = force * <span style="color: #000000;">&#40;</span><span style="color: #000000;">1</span>-strenght<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #FF7F32;">return</span> force<br />
<span style="color: #FF7F32;">end</span><br />
<br />
<span style="color: #FF7F32;">function</span> Mover:checkEdges<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #FF7F32;">if</span> <span style="color: #FF7F32;">self</span>.loc.x &gt; <span style="color: #1F73B3;">OUTPUT_W</span> <span style="color: #FF7F32;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">self</span>.loc.x = <span style="color: #1F73B3;">OUTPUT_W</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">self</span>.vel.x = <span style="color: #FF7F32;">self</span>.vel.x * -<span style="color: #000000;">0.9</span><br />
&nbsp; &nbsp; <span style="color: #FF7F32;">elseif</span> <span style="color: #FF7F32;">self</span>.loc.x &lt; <span style="color: #000000;">0</span> <span style="color: #FF7F32;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">self</span>.loc.x = <span style="color: #000000;">0</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">self</span>.vel.x = <span style="color: #FF7F32;">self</span>.vel.x * -<span style="color: #000000;">0.9</span><br />
&nbsp; &nbsp; <span style="color: #FF7F32;">end</span><br />
<br />
&nbsp; &nbsp; <span style="color: #FF7F32;">if</span> <span style="color: #FF7F32;">self</span>.loc.y &gt; <span style="color: #1F73B3;">OUTPUT_H</span> <span style="color: #FF7F32;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">self</span>.loc.y = <span style="color: #1F73B3;">OUTPUT_H</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">self</span>.vel.y = <span style="color: #FF7F32;">self</span>.vel.y * -<span style="color: #000000;">0.9</span><br />
&nbsp; &nbsp; <span style="color: #FF7F32;">elseif</span> <span style="color: #FF7F32;">self</span>.loc.y &lt; <span style="color: #000000;">0</span> <span style="color: #FF7F32;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">self</span>.loc.y = <span style="color: #000000;">0</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">self</span>.vel.y = <span style="color: #FF7F32;">self</span>.vel.y * -<span style="color: #000000;">0.9</span><br />
&nbsp; &nbsp; <span style="color: #FF7F32;">end</span><br />
<span style="color: #FF7F32;">end</span><br />
<span style="color: #7F7F7F; font-style: italic;">//-------------------------------------</span></code></h4>
]]></content:encoded>
			<wfw:commentRss>http://gamuza.d3cod3.org/examples/ch2_attractrepel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>camDither</title>
		<link>http://gamuza.d3cod3.org/examples/camdither/</link>
		<comments>http://gamuza.d3cod3.org/examples/camdither/#comments</comments>
		<pubDate>Wed, 19 Sep 2012 09:36:53 +0000</pubDate>
		<dc:creator>n3m3da</dc:creator>
				<category><![CDATA[examples]]></category>
		<category><![CDATA[exvideo]]></category>

		<guid isPermaLink="false">http://gamuza.d3cod3.org/?p=2118</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<img src="http://www.d3cod3.org/gamuza/examplesImages/Video/camDither.jpg" width="500" height="313" />
<h4>This shows how to filter the camera image with ofx.dither() class.<br />
<br />
Original addon from julapy <a href="https://github.com/julapy/ofxDither" target="_blank">https://github.com/julapy/ofxDither</a><br />
</h4>
<h4><code class="bwp-syntax-inline"><span style="color: #7F7F7F; font-style: italic;">/* <br />
&nbsp; &nbsp;<br />
&nbsp;GAmuza 0.4.1 examples <br />
&nbsp;---------------------<br />
&nbsp;Video/camDither.ga<br />
&nbsp;<br />
&nbsp;This shows how to filter the camera image with ofx.dither() class.<br />
&nbsp;<br />
&nbsp;created by n3m3da | www.d3cod3.org<br />
&nbsp;<br />
*/</span><br />
<br />
dither = <span style="color: #FF7F32;">ofx.dither</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
_type = <span style="color: #000000;">1</span><br />
cam = <span style="color: #FF7F32;">of.texture</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
pixels = <span style="color: #FF7F32;">of.pixels</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
imageIn = <span style="color: #FF7F32;">of.image</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
imageOut = <span style="color: #FF7F32;">of.image</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
<br />
<span style="color: #FF7F32;">function</span> <span style="color: #FF7F32;">setup</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; cam:<span style="color: #FF7F32;">allocate</span><span style="color: #000000;">&#40;</span><span style="color: #1F73B3;">CAPTURE_W</span>,<span style="color: #1F73B3;">CAPTURE_H</span>,GL_RGB<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; imageIn:<span style="color: #FF7F32;">allocate</span><span style="color: #000000;">&#40;</span><span style="color: #1F73B3;">CAPTURE_W</span>,<span style="color: #1F73B3;">CAPTURE_H</span>,<span style="color: #1F73B3;">OF_IMAGE_GRAYSCALE</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; imageOut:<span style="color: #FF7F32;">allocate</span><span style="color: #000000;">&#40;</span><span style="color: #1F73B3;">CAPTURE_W</span>,<span style="color: #1F73B3;">CAPTURE_H</span>,<span style="color: #1F73B3;">OF_IMAGE_GRAYSCALE</span><span style="color: #000000;">&#41;</span> &nbsp; &nbsp;<br />
<span style="color: #FF7F32;">end</span><br />
<br />
<span style="color: #FF7F32;">function</span> <span style="color: #FF7F32;">update</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7F7F7F; font-style: italic;">// get the cam texture</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; cam = <span style="color: #FF7F32;">ga.cameraTexture</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">0</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7F7F7F; font-style: italic;">// get the cam pixels</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; cam:<span style="color: #FF7F32;">readToPixels</span><span style="color: #000000;">&#40;</span>pixels<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; imageIn:<span style="color: #FF7F32;">setFromPixels</span><span style="color: #000000;">&#40;</span>pixels<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; applyDither<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
<span style="color: #FF7F32;">end</span><br />
<br />
<span style="color: #FF7F32;">function</span> <span style="color: #FF7F32;">draw</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">ga.background</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">0.0</span>,<span style="color: #000000;">1.0</span><span style="color: #000000;">&#41;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">of.setColor</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">255</span><span style="color: #000000;">&#41;</span> &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; imageOut:<span style="color: #FF7F32;">draw</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">0</span>,<span style="color: #000000;">0</span>,<span style="color: #1F73B3;">OUTPUT_W</span>,<span style="color: #1F73B3;">OUTPUT_H</span><span style="color: #000000;">&#41;</span><br />
<span style="color: #FF7F32;">end</span><br />
<br />
<span style="color: #FF7F32;">function</span> <span style="color: #FF7F32;">keyReleased</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">if</span> <span style="color: #FF7F32;">ga.key</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> == <span style="color: #FF7F32;">string.byte</span><span style="color: #000000;">&#40;</span><span style="color: #FF1919;">'0'</span><span style="color: #000000;">&#41;</span> <span style="color: #FF7F32;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _type = <span style="color: #000000;">0</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">elseif</span> <span style="color: #FF7F32;">ga.key</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> == <span style="color: #FF7F32;">string.byte</span><span style="color: #000000;">&#40;</span><span style="color: #FF1919;">'1'</span><span style="color: #000000;">&#41;</span> <span style="color: #FF7F32;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _type = <span style="color: #000000;">1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">elseif</span> <span style="color: #FF7F32;">ga.key</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> == <span style="color: #FF7F32;">string.byte</span><span style="color: #000000;">&#40;</span><span style="color: #FF1919;">'2'</span><span style="color: #000000;">&#41;</span> <span style="color: #FF7F32;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _type = <span style="color: #000000;">2</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">end</span><br />
<span style="color: #FF7F32;">end</span><br />
<br />
<span style="color: #7F7F7F; font-style: italic;">/////////////////////////////////////////</span><br />
<span style="color: #7F7F7F; font-style: italic;">// Custom functions</span><br />
<br />
<span style="color: #7F7F7F; font-style: italic;">// the ofx.dither class has three different alghorithms you can use</span><br />
<span style="color: #FF7F32;">function</span> applyDither<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF7F32;">if</span> _type == <span style="color: #000000;">0</span> <span style="color: #FF7F32;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; dither:<span style="color: #FF7F32;">ordered</span><span style="color: #000000;">&#40;</span>imageIn,imageOut<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #FF7F32;">elseif</span> _type == <span style="color: #000000;">1</span> <span style="color: #FF7F32;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; dither:<span style="color: #FF7F32;">floyd_steinberg</span><span style="color: #000000;">&#40;</span>imageIn,imageOut<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #FF7F32;">elseif</span> _type == <span style="color: #000000;">2</span> <span style="color: #FF7F32;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; dither:<span style="color: #FF7F32;">atkinson</span><span style="color: #000000;">&#40;</span>imageIn,imageOut<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #FF7F32;">end</span><br />
<span style="color: #FF7F32;">end</span></code></h4>
]]></content:encoded>
			<wfw:commentRss>http://gamuza.d3cod3.org/examples/camdither/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
