<?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>richardjdare.com &#187; processing</title>
	<atom:link href="http://richardjdare.com/blog/tag/processing/feed/" rel="self" type="application/rss+xml" />
	<link>http://richardjdare.com</link>
	<description>Games, Ideas, Imagination</description>
	<lastBuildDate>Thu, 06 Apr 2023 12:02:17 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.2.38</generator>
	<item>
		<title>Making a heat map effect for Toxin</title>
		<link>http://richardjdare.com/blog/2013/06/making-a-heat-map-effect-for-toxin/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=making-a-heat-map-effect-for-toxin</link>
		<comments>http://richardjdare.com/blog/2013/06/making-a-heat-map-effect-for-toxin/#comments</comments>
		<pubDate>Thu, 20 Jun 2013 14:18:07 +0000</pubDate>
		<dc:creator><![CDATA[Richard Dare]]></dc:creator>
				<category><![CDATA[game development]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[Toxin]]></category>
		<category><![CDATA[graphics]]></category>
		<category><![CDATA[processing]]></category>

		<guid isPermaLink="false">http://richardjdare.com/blog/?p=1010</guid>
		<description><![CDATA[As you might already know my forthcoming iOS game, Toxin involves shooting rapidly dividing toxic cells which eventually fill the playfield or burst to spawn.]]></description>
				<content:encoded><![CDATA[<p><img class="aligncenter size-full wp-image-1011" style="border: 0;" src="http://richardjdare.com/blog/wp-content/uploads/2013/06/heatmap-shot.jpg" alt="Toxin Heatmap" width="500" height="259" /></p>
<p>As you might already know my forthcoming iOS game, <a href="http://toxingame.com" target="_blank">Toxin</a> involves shooting rapidly dividing toxic cells which eventually fill the playfield or burst to spawn flying enemies.</p>
<p>Now, not long ago I read an <a href="http://twitter-heatmap.vertalab.com/" target="_blank">article</a> about generating <a href="http://en.wikipedia.org/wiki/Heat_map" target="_blank">heat maps </a>to display web statistics, and I thought it would be cool to use this technique to colourise the ever changing clumps of cells in Toxin. After finding out how they work, I knocked up a prototype in <a href="http://processing.org" target="_blank">Processing</a> before adding the effect to the game.</p>
<p>Generating heatmaps is pretty simple. Take a 2d grid of values, perform a Gaussian blur on it, then use each resulting value as an index into a gradient of colours.</p>
<p>For Toxin, the first step was to create a simple array of numbers representing the current state of the cell grid. Toxin cells can be different sizes. To simplify things, I store each big cell as several small cells.</p>
<p>Each cell is given an initial value of 255. When we draw our cells, we use a range from black to white, where values of 0 are black, 255 is white and values in between are shades of gray.</p>
<p><img class="aligncenter size-full wp-image-1020" style="border: 0;" src="http://richardjdare.com/blog/wp-content/uploads/2013/06/heatmap-initial.jpg" alt="heatmap-initial" width="500" height="361" /><br />
<em><span style="color: #808080; padding-bottom: 20px;">The cells are represented as a grid of numbers. Each cell is given the initial value of 255</span></em></p>
<p>The next step is to apply a simple <a href="http://en.wikipedia.org/wiki/Box_blur" target="_blank">box blur</a> to this grid of numbers. Normally heat maps use <a href="http://en.wikipedia.org/wiki/Gaussian_blur" target="_blank">Gaussian blur</a>, but since Toxin&#8217;s grid is such a low resolution we can get away with using a simpler algorithm which is much faster to calculate. To learn more about blurring techniques, I recommend <a href="http://www.gamasutra.com/view/feature/3102/four_tricks_for_fast_blurring_in_.php?print=1" target="_blank">Alex Evan&#8217;s article</a> on Gamasutra.</p>
<p><img class="aligncenter size-full wp-image-1027" style="border: 0;" src="http://richardjdare.com/blog/wp-content/uploads/2013/06/heatmap-blur.jpg" alt="Toxin heat map blur" width="500" height="361" /><br />
<em><span style="color: #808080; padding-bottom: 20px;">The cell grid after being blurred. Notice how the values have changed</span></em></p>
<p>Now look what happens when we draw our original cell grid using the values from the blur operation. Cells in the middle of large clumps have higher values than solitary cells.</p>
<p><img class="aligncenter size-full wp-image-1033" style="border: 0;" src="http://richardjdare.com/blog/wp-content/uploads/2013/06/heatmap-grayscale.jpg" alt="Toxin heat map grayscale" width="500" height="361" /><br />
<em><span style="color: #808080; padding-bottom: 20px;">Drawing the original grid with the blurred values</span></em></p>
<p>The final step is to colourise these grayscale values so they look cool. We do this by mapping these values onto a gradient I made in Photoshop. Values of 0 map onto the left of this gradient, 255 to the right, and the others to the colours in between.</p>
<div style="text-align: center;"><img class="aligncenter wp-image-1037 size-full" style="border: 0;" src="http://www.richardjdare.com/blog/wp-content/uploads/2013/06/heatmap-gradient.jpg" alt="Toxin heat map gradient" width="320" height="80" /></div>
<div style="width: 500px; text-align: center;"></div>
<p>When we draw the grid with the colours from the gradient we get our heatmap!</p>
<p><img class="aligncenter size-full wp-image-1044" style="border: 0;" src="http://richardjdare.com/blog/wp-content/uploads/2013/06/final-heatmap.jpg" alt="Toxin final heat map" width="500" height="361" /></p>
]]></content:encoded>
			<wfw:commentRss>http://richardjdare.com/blog/2013/06/making-a-heat-map-effect-for-toxin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Next Photoshop</title>
		<link>http://richardjdare.com/blog/2013/02/the-next-photoshop/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=the-next-photoshop</link>
		<comments>http://richardjdare.com/blog/2013/02/the-next-photoshop/#comments</comments>
		<pubDate>Sun, 24 Feb 2013 15:06:12 +0000</pubDate>
		<dc:creator><![CDATA[Richard Dare]]></dc:creator>
				<category><![CDATA[photoshop]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[photoshop scripting]]></category>
		<category><![CDATA[processing]]></category>

		<guid isPermaLink="false">http://richardjdare.com/blog/?p=905</guid>
		<description><![CDATA[If you’ve read this blog for very long you’ll know that I am a big fan of Photoshop scripting and procedural graphics. Toxin, the iPhone.]]></description>
				<content:encoded><![CDATA[<p>If you’ve read this blog for very long you’ll know that I am a big fan of Photoshop scripting and procedural graphics. <a href="http://toxingame.com" target="_blank">Toxin</a>, the iPhone game I’ve been <a href="http://richardjdare.com/blog/category/toxin/" target="_blank">working on</a>, uses procedural art and animated image processing effects extensively. I don’t think the game would be possible without Photoshop scripting.</p>
<p>However, Photoshop’s scripting system is far from perfect. You cannot access pixel data from within scripts, nor can you draw lines or circles or anything like that. These limitations have become really frustrating to me.</p>
<p>For example, on the day I started work on Toxin, I needed to draw an ellipse with precise dimensions. The whole game takes place inside an ellipse, you see. I couldn’t do it in Photoshop by clicking and dragging, it was too inaccurate, so I wrote a C program using the <a href="http://alleg.sourceforge.net/" target="_blank">Allegro</a> game library to create the precise shapes I needed. These were then loaded into Photoshop and used as guides while I created the game artwork.</p>
<p>Later I discovered <a href="http://processing.org/" target="_blank">Processing</a>, which is much quicker to develop in than C. I soon developed a workflow where I would go back and forth between Photoshop and Processing, generating procedural content then processing it or running it through scripts until I got the desired result.</p>
<p>Processing, however has some frustrating quirks of its own. As a simplified front end to Java, you often get Java errors that are incomprehensible without digging into the underlying platform. Also, it cannot effectively save semi-transparent PNGs which means that the anti-aliased sprites I was creating all had a solid background which had to be removed. I ended up redesigning my workflow and using the excellent Ghost and AntiGhost plugins from <a href="http://www.flamingpear.com/download.html" target="_blank">Flaming Pear</a> to overcome these problems.</p>
<h3>From graphics app to graphics platform</h3>
<p>All these issues got me thinking about what I really want from a high end graphics program. What I want is something like a programmable, graphical <a href="http://en.wikipedia.org/wiki/Lisp_machine" target="_blank">Lisp Machine</a>; a powerful graphics programming platform with the UI of an art application, not an art application with a bolted-on scripting system.</p>
<p>I want the ability to programmatically control every aspect of Photoshop from both external scripts and from a real-time <a href="http://en.wikipedia.org/wiki/Read–eval–print_loop" target="_blank">REPL</a> inside Photoshop that works like the command line used in some CAD programs.</p>
<p>I want to be able to type<em> line(10,10,100,100)</em> and have a line appear on my presently selected image. I want to be able to open the REPL and assign my current selection to a variable which I can later re-select with a simple command. I want to be able to access the pixel data in my images, and write my own filters in Javascript within the scripting system itself. I think anyone in high-end graphics or scientific imaging would love something like this.</p>
<p>A true graphics platform like I have described would likely have to be written from the ground up with programmability built in. Nevertheless I did spend some time finding out how far I could go with Photoshop&#8217;s native capabilities.</p>
<p>I had the idea of writing a Photoshop plugin that contained a number of drawing functions which could be called from scripts via a Javascript library that integrates with the Photoshop document model. So you could write <em>PSDraw.line(10,10,100,100);</em> in ExtendScript Toolkit, and my Javascript library would construct a call to the plugin which would draw the line.</p>
<p>Unfortunately, it&#8217;s not possible to get information from a plugin back to the Photoshop script thats running it, so it wouldn&#8217;t be possible to do a <em>getPixel()</em> or anything like that. At best, this plugin/script combo would give us a somewhat clunky way of drawing programmatically but little else that would justify the effort involved. (have you ever seen the <a href="http://www.mactech.com/articles/mactech/Vol.15/15.04/PhotoshopPlug-InsPart1/index.html" target="_blank">Photoshop plugin API?</a>)</p>
<p>As a secondary option I thought about actually embedding <a href="https://code.google.com/p/v8/" target="_blank">V8</a> inside a plugin which would contain an editor and debugger. Besides the ugliness of having 2 distinct Javascript engines running in the same app, the plugin architecture put paid to this idea. Photoshop plugins are one-shot operations. Load the plugin, set the parameters, perform the operation, then shutdown. My idea would only be effective if the plugin was a persistent part of the Photoshop environment.</p>
<p>So the only options then, would be for Adobe to integrate scripting more completely, or for someone else to start making what would be a true sucessor to Photoshop.</p>
<p>&nbsp;</p>
<p><figure class='media-wrapper player'><iframe width="500" height="375" src="http://www.youtube.com/embed/mOZqRJzE8xg?wmode=transparent" frameborder="0" allowfullscreen wmode="Opaque"></iframe></figure></p>
]]></content:encoded>
			<wfw:commentRss>http://richardjdare.com/blog/2013/02/the-next-photoshop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Toxin &#8211; Creating sprites in Processing</title>
		<link>http://richardjdare.com/blog/2012/11/toxin-creating-sprites-in-processing/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=toxin-creating-sprites-in-processing</link>
		<comments>http://richardjdare.com/blog/2012/11/toxin-creating-sprites-in-processing/#comments</comments>
		<pubDate>Sun, 18 Nov 2012 18:19:34 +0000</pubDate>
		<dc:creator><![CDATA[Richard Dare]]></dc:creator>
				<category><![CDATA[game development]]></category>
		<category><![CDATA[Toxin]]></category>
		<category><![CDATA[ios]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[processing]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://richardjdare.com/blog/?p=490</guid>
		<description><![CDATA[One of the most powerful graphical tools I am using to make Toxin is Processing, a Java based platform used to create generative art. Processing.]]></description>
				<content:encoded><![CDATA[<p>One of the most powerful graphical tools I am using to make <a href="http://toxingame.com" target="_blank">Toxin</a> is <a href="http://processing.org/" target="_blank">Processing</a>, a Java based platform used to create generative art. Processing provides you with a basic IDE, a graphics API and a simplified front end to Java that lets you get things up and running with a minimal amount of work. It&#8217;s great for doing experiments or when you need to create art programmatically rather than with a graphics program.</p>
<p><img class="aligncenter size-full wp-image-517" style="border: 0px;" title="Processing IDE" src="http://richardjdare.com/blog/wp-content/uploads/2012/11/processing-ide.jpg" alt="" width="480" height="542" /><br />
<em><span style="color: #808080;">Processing provides a simplified front end to Java, ideal for quick experiments</span></em></p>
<p>The green cells in Toxin were all generated using a Processing program. Each cell is a circle made up of a number of connected spline segments. I animate the cell by displacing the spline control points using Perlin noise. The cells are then resized and colourized in Photoshop.</p>
<p><img class="aligncenter size-full wp-image-542" style="border: 0px;" title="Toxin's cells being rendered in processing" src="http://richardjdare.com/blog/wp-content/uploads/2012/11/processing-cells.jpg" alt="" width="400" height="210" /><br />
<em><span style="color: #808080;">Left, a cell being rendered in Processing. Right, the finished result</span></em></p>
<p>As you can see, the finished product does not look exactly like the original Processing output. I had to do a lot of tweaking, re-rendering and reprocessing until I got them looking right. It was very time consuming. There were many moments where I wondered if I was going to get useable results at all.</p>
<p>Many of Toxin&#8217;s graphical effects have their origins in experiments I did with Photoshop blend modes. I discovered that certain combinations of layers and modes resulted in nice abstract animations when the layers were dragged around. I wrote photoshop scripts to perform these movements and spit out animation frames. Unfortunately these scripts revealed many bugs and inaccuracies in Photoshop and its scripting system. You only have to look through the source of my <a title="Texture Atlas Maker" href="http://richardjdare.com/blog/2009/08/texture-atlas-maker/" target="_blank">AtlasMaker</a> Photoshop script to see how many strange workarounds are required to accomplish straightforward tasks.</p>
<p>To solve these problems I implemented Photoshop&#8217;s blending modes in Processing, and use this to create my animations. Below are a few frames from Toxin&#8217;s shot animation that demonstrate the technique. The way the colours shift throughout the animation is down to the movement of multiple layers blended into a simple white shot sprite. You can get a better idea of how this looks in the game by looking at the <a href="http://richardjdare.com/blog/2012/10/toxin-for-iphone-and-ipod-touch/">screenshots</a> I posted a couple of weeks ago.</p>
<p><img class="aligncenter size-full wp-image-550" style="border: 0px;" title="Toxin Shots" src="http://richardjdare.com/blog/wp-content/uploads/2012/11/toxin-shots1.jpg" alt="" width="372" height="84" /><br />
<em><span style="color: #808080;">Many of Toxin&#8217;s sprites use animated image processing effects</span></em></p>
<p><em></em><br />
I also used Processing as a test bed to work out algorithms before implementing them in the game. For example, Toxin has a weapon which freezes the edges of groups of cells. It didn&#8217;t take long to prototype this in Processing.</p>
<p><img class="aligncenter size-full wp-image-553" title="Testing an algorithm in Processing" src="http://richardjdare.com/blog/wp-content/uploads/2012/11/cellbounds.jpg" alt="" width="480" height="368" style="border:0px" /><br />
<em><span style="color: #808080;">Testing a powerup that uses a flood fill algorithm to find edge cells</span></em></p>
<p>Stay tuned for more posts on Toxin, and a new version of my texture atlas Photoshop script which is in final testing&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://richardjdare.com/blog/2012/11/toxin-creating-sprites-in-processing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Toxin Graphics &#8211; Introduction</title>
		<link>http://richardjdare.com/blog/2012/11/toxin-graphics-introduction/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=toxin-graphics-introduction</link>
		<comments>http://richardjdare.com/blog/2012/11/toxin-graphics-introduction/#comments</comments>
		<pubDate>Sat, 03 Nov 2012 12:22:48 +0000</pubDate>
		<dc:creator><![CDATA[Richard Dare]]></dc:creator>
				<category><![CDATA[game development]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Toxin]]></category>
		<category><![CDATA[games]]></category>
		<category><![CDATA[ios]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[photoshop]]></category>
		<category><![CDATA[processing]]></category>

		<guid isPermaLink="false">http://richardjdare.com/blog/?p=57</guid>
		<description><![CDATA[It has taken me a long time and a lot of experimentation to get the graphics right for Toxin. When I began, I didn&#8217;t really.]]></description>
				<content:encoded><![CDATA[<p>It has taken me a long time and a lot of experimentation to get the graphics right for <a href="http://toxingame.com" target="_blank">Toxin.</a> When I began, I didn&#8217;t really have a single picture in mind of how the game was going to look. I knew I wanted abstract, and I knew I wanted a contemporary style influenced by <a href="http://en.wikipedia.org/wiki/Information_graphics" target="_blank">information graphics</a> and designers like <a href="http://blog.signalnoise.com/" target="_blank">James White</a>, but that was all. Most of my inner images of the game were fleeting. I had a gameplay concept and a &#8220;feel&#8221; in mind more than anything else.</p>
<p>Also, Toxin is the first game I have worked on since the <a title="Games" href="http://richardjdare.com/blog/games/" target="_blank">Smartphone stuff</a> I did around 2002-2003. I was desperate to get back into game development and I mistakenly thought I could begin again where I left off. It was like running into a brick wall. The first artwork I did was so bad I deleted everything, took the bus into Stratford on Avon and spent the rest of the day sitting by the side of the river in despair!</p>
<p>It took me some time to reach my old level again and then improve on it. As much as I have enjoyed developing Toxin and the creative discoveries I have made, there has been a great deal of struggle and fruitless experimentation involved.</p>
<p>The interior designer and UK TV legend <a href="http://www.llb.co.uk/" target="_blank">Laurence Llewelyn-Bowen</a> was an unlikely influence. On his TV home makeover shows he&#8217;d get his clients to collect images they liked and pin them to a board for inspiration. I had a Toxin folder on my laptop which I filled with images from <a href="http://ffffound.com/" target="_blank">ffffound</a> and other design inspiration sites. When I got stuck I&#8217;d fire up <a href="http://www.irfanview.com/" target="_blank">IrfanView</a> and spend half an hour blanky staring at images until some ideas popped up. I highly recommend this practice. A few of the images from my Toxin folder are in the image below.</p>
<p style="text-align: center;"><img class="size-full wp-image-66 aligncenter" title="toxin-image-board" src="http://richardjdare.com/blog/wp-content/uploads/2011/11/toxin-image-board.jpg" alt="Toxin Image Board" width="500" height="375" /></p>
<p><em><span style="color: #808080;">That watch is a <a href="http://dievaswatches.com/aqualuna-blue-professional/">Dievas Aqualuna Blue Professional.</a> No I can&#8217;t afford one yet. Buy Toxin!</span></em></p>
<p><em></em><br />
<img class="alignleft size-full wp-image-447" title="Toxin Ship" src="http://richardjdare.com/blog/wp-content/uploads/2012/11/toxin-ship.jpg" alt="Toxin Ship Sprite" width="170" height="148" />The first thing I did was the main ship, which is the only thing I got right first time; it remained unchanged throughout development whereas everything else got remade at least three times! I think it works really well and has a nicely balanced, iconic look. I designed it in a vector drawing package which I later abandoned in favour of using rendered, animated splines created in a 3d program.</p>
<p>The background was next. It was essential to get the background style nailed as it would define the look of the whole game. I tried a few different styles as you can see in the rough drafts below.</p>
<p style="text-align: center;"><img class="size-full wp-image-70 aligncenter" title="toxin-background-drafts" src="http://richardjdare.com/blog/wp-content/uploads/2011/11/toxin-background-drafts.jpg" alt="toxin background drafts" width="400" height="266" /></p>
<p>One of my biggest goals here was to create something that looked good within the phone. Too often, mobile games just present windows on to the game world without any consideration for the device that is running the game. To me this is like designing a watch face without taking the case into account.</p>
<p>Next time I&#8217;ll talk about how Toxin uses procedural graphics and describe how I used Photoshop scripting and <a href="http://processing.org/" target="_blank">Processing</a>, a Java based generative arts platform to create much of the game&#8217;s artwork.</p>
]]></content:encoded>
			<wfw:commentRss>http://richardjdare.com/blog/2012/11/toxin-graphics-introduction/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
