<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>xelapond's stuff</title>
	<atom:link href="http://xelapondsstuff.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://xelapondsstuff.wordpress.com</link>
	<description>My thoughts about Python, Human Computer Interaction, and Cats</description>
	<lastBuildDate>Fri, 23 Jan 2009 01:29:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='xelapondsstuff.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>xelapond's stuff</title>
		<link>http://xelapondsstuff.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://xelapondsstuff.wordpress.com/osd.xml" title="xelapond&#039;s stuff" />
	<atom:link rel='hub' href='http://xelapondsstuff.wordpress.com/?pushpress=hub'/>
		<item>
		<title>New Table Design</title>
		<link>http://xelapondsstuff.wordpress.com/2008/12/13/new-table-design/</link>
		<comments>http://xelapondsstuff.wordpress.com/2008/12/13/new-table-design/#comments</comments>
		<pubDate>Sat, 13 Dec 2008 06:38:28 +0000</pubDate>
		<dc:creator>xelapondsstuff</dc:creator>
				<category><![CDATA[DIY]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Multi-Touch]]></category>

		<guid isPermaLink="false">http://xelapondsstuff.wordpress.com/?p=246</guid>
		<description><![CDATA[When I first started this blog I had little idea how Multi-Touch worked, and what was practical and within bounds of readily available technology.  I originally intended to make a large(40 Inch) Rear-Projection DI Table, which through many mistakes and decisions, has now turned into a rear-projection LLP Table.  Unfortunately, my projector bulb recently died, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xelapondsstuff.wordpress.com&amp;blog=3595014&amp;post=246&amp;subd=xelapondsstuff&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>When I first started this blog I had little idea how Multi-Touch worked, and what was practical and within bounds of readily available technology.  I originally intended to make a large(40 Inch) Rear-Projection DI Table, which through many mistakes and decisions, has now turned into a rear-projection LLP Table.  Unfortunately, my projector bulb recently died, killing this table, and as of current I have a front LLP setup on uding old 17 Inch monitor.  This setup, while it does work pretty well, has some major disadvantages.  The lasers have to be pointing away from the camera(so they don&#8217;t appear as blobs), thus illumination can only come from one side.  This causes really bad occlusions, making Multi-User interaction nearly impossible(aside from that fact that it is on a 17 Inch 5:4 monitor).</p>
<p>I came across the LumenLab database of monitors a few days ago, and my 17 Inch Monitor(Samsung 712N) was on the list of those that didn&#8217;t have FCC Issues, so I figured I would give it a go at taking it apart and mounting the camera behind it.  If it turns out to work well I might make a nice box for it.</p>
<p>Taking apart this monitor was amazing, and I _HIGHLY_ recommend it for anyone trying to find a small monitor to take apart for such a project.  It is amazing how high quality and easy to take apart it was built, its almost like they took us into consideration when they designed it!  Ill post a more details description with pictures later(once I take some:)).</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xelapondsstuff.wordpress.com/246/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xelapondsstuff.wordpress.com/246/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xelapondsstuff.wordpress.com/246/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xelapondsstuff.wordpress.com/246/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xelapondsstuff.wordpress.com/246/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xelapondsstuff.wordpress.com/246/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xelapondsstuff.wordpress.com/246/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xelapondsstuff.wordpress.com/246/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xelapondsstuff.wordpress.com/246/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xelapondsstuff.wordpress.com/246/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xelapondsstuff.wordpress.com/246/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xelapondsstuff.wordpress.com/246/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xelapondsstuff.wordpress.com/246/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xelapondsstuff.wordpress.com/246/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xelapondsstuff.wordpress.com&amp;blog=3595014&amp;post=246&amp;subd=xelapondsstuff&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xelapondsstuff.wordpress.com/2008/12/13/new-table-design/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6c32a4f18b03a2e3acdfbdce7becccde?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">xelapondsstuff</media:title>
		</media:content>
	</item>
		<item>
		<title>Getting started with Multi-Touch Development in Python: Part 4</title>
		<link>http://xelapondsstuff.wordpress.com/2008/12/03/getting-started-with-multi-touch-development-in-python-part-4/</link>
		<comments>http://xelapondsstuff.wordpress.com/2008/12/03/getting-started-with-multi-touch-development-in-python-part-4/#comments</comments>
		<pubDate>Wed, 03 Dec 2008 03:10:07 +0000</pubDate>
		<dc:creator>xelapondsstuff</dc:creator>
				<category><![CDATA[Multi-Touch]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://xelapondsstuff.wordpress.com/?p=231</guid>
		<description><![CDATA[Its time for a new tutorial!  This time we will build a slightly(but only slightly) more realistic example.  We will use PyGame to render a green box, and allow us to drag it around, and resize it by pinching and squeezing.  As usual, if you have any suggestions regarding tutorials, or if you have an [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xelapondsstuff.wordpress.com&amp;blog=3595014&amp;post=231&amp;subd=xelapondsstuff&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><span style="color:#888888;"><span style="text-decoration:underline;"></span></span>Its time for a new tutorial!  This time we will build a slightly(but only slightly) more realistic example.  We will use PyGame to render a green box, and allow us to drag it around, and resize it by pinching and squeezing.  As usual, if you have any suggestions regarding tutorials, or if you have an idea for a tutorial I should write, send me an email(can be found in the contact me section to the right), or say something in the comments.</p>
<p><span id="more-231"></span>I am going to follow the same tutorial format I used last time, where I give you the code and explain it line by line.  In this tutorial we will also take a new approach at getting touch events, through a new type of callback called a Decorator(read more about them <a href="http://www.artima.com/weblogs/viewpost.jsp?thread=240808">here</a>).  They are similar to Java&#8217;s Annotations, and are purely a way of representing this(from the first tutorial):</p>
<blockquote>
<div class="highlight">
<pre><span style="color:#007020;font-weight:bold;">class</span> <span style="color:#0e84b5;font-weight:bold;">Observer</span>(<span style="color:#007020;">object</span>):
    <span style="color:#007020;font-weight:bold;">def</span> <span style="color:#06287e;">__init__</span>(<span style="color:#007020;">self</span>, subject):
        subject<span style="color:#666666;">.</span>push_handlers(<span style="color:#007020;">self</span>)

<span style="color:#007020;font-weight:bold;">class</span> <span style="color:#0e84b5;font-weight:bold;">touch_up</span>(Observer):
    <span style="color:#007020;font-weight:bold;">def</span> <span style="color:#06287e;">TOUCH_UP</span>(<span style="color:#007020;">self</span>,blobID, xpos, ypos):
        <span style="color:#60a0b0;font-style:italic;">#Do something here</span>

<span style="color:#007020;font-weight:bold;">class</span> <span style="color:#0e84b5;font-weight:bold;">touch_down</span>(Observer):
    <span style="color:#007020;font-weight:bold;">def</span> <span style="color:#06287e;">TOUCH_DOWN</span>(<span style="color:#007020;">self</span>,blobID):        <span style="color:#60a0b0;font-style:italic;">
        #Do something here</span>

<span style="color:#007020;font-weight:bold;">class</span> <span style="color:#0e84b5;font-weight:bold;">touch_move</span>(Observer):    <span style="color:#007020;font-weight:bold;">
    def</span> <span style="color:#06287e;">TOUCH_MOVE</span>(<span style="color:#007020;">self</span>,blobID):        <span style="color:#60a0b0;font-style:italic;">
        #Do something here</span>

t <span style="color:#666666;">=</span> touchpy()
tu <span style="color:#666666;">=</span> touch_up(t)
td <span style="color:#666666;">=</span> touch_down(t)
tm <span style="color:#666666;">=</span> touch_move(t)</pre>
</div>
</blockquote>
<p>With this:</p>
<blockquote>
<div class="highlight">
<pre><span style="color:#555555;font-weight:bold;">@t</span><span style="color:#666666;">.</span>event<span style="color:#007020;font-weight:bold;">
def</span> <span style="color:#06287e;">TOUCH_DOWN</span>(blobID):    <span style="color:#60a0b0;font-style:italic;">
    #Do Something</span>

<span style="color:#555555;font-weight:bold;">@t</span><span style="color:#666666;">.</span>event<span style="color:#007020;font-weight:bold;">
def</span> <span style="color:#06287e;">TOUCH_MOVE</span>(blobID):    <span style="color:#60a0b0;font-style:italic;">
    #Do Something</span>

<span style="color:#555555;font-weight:bold;">@t</span><span style="color:#666666;">.</span>event<span style="color:#007020;font-weight:bold;">
def</span> <span style="color:#06287e;">TOUCH_UP</span>(blobID):    <span style="color:#60a0b0;font-style:italic;">
    #Do Something</span></pre>
</div>
</blockquote>
<p>Not only is it _much_ easier to write, but its a lot easier to read, and actually makes sense.  So, moving on to the code.  I have not commented to the code, because I will be going over it line by line here, and I figured comments would make it longer then it has to be.  I tried to make this as short as possible while still being readable, so its very global oriented.  I would assume all tutorials from here on out will follow better practice, as they will do more complicated things(The next tutorial will either be a Picture app, or a simple button GUI, not sure yet, but I will get to both eventually).  So, the code:</p>
<blockquote>
<div class="highlight">
<pre><span style="color:#007020;font-weight:bold;">import</span> <span style="color:#0e84b5;font-weight:bold;">sys</span><span style="color:#007020;font-weight:bold;">
import</span> <span style="color:#0e84b5;font-weight:bold;">math</span>

<span style="color:#007020;font-weight:bold;">import</span> <span style="color:#0e84b5;font-weight:bold;">pygame</span><span style="color:#007020;font-weight:bold;">
from</span> <span style="color:#0e84b5;font-weight:bold;">pygame.locals</span> <span style="color:#007020;font-weight:bold;">import</span> <span style="color:#666666;">*</span>

<span style="color:#007020;font-weight:bold;">from</span> <span style="color:#0e84b5;font-weight:bold;">touchpy</span> <span style="color:#007020;font-weight:bold;">import</span> touch<span style="color:#007020;font-weight:bold;">
from</span> <span style="color:#0e84b5;font-weight:bold;">touchpy</span> <span style="color:#007020;font-weight:bold;">import</span> utils

<span style="color:#007020;font-weight:bold;">def</span> <span style="color:#06287e;">make_rectlist</span>(pos, size):    <span style="color:#007020;font-weight:bold;">
    return</span> (pos, (pos[<span style="color:#40a070;">0</span>] <span style="color:#666666;">+</span> size, pos[<span style="color:#40a070;">1</span>]), (pos[<span style="color:#40a070;">0</span>] <span style="color:#666666;">+</span> size, pos[<span style="color:#40a070;">1</span>] <span style="color:#666666;">+</span> size), (pos[<span style="color:#40a070;">0</span>], pos[<span style="color:#40a070;">1</span>] <span style="color:#666666;">+</span> size))

<span style="color:#007020;font-weight:bold;">def</span> <span style="color:#06287e;">get_distance</span>(x1, y1, x2, y2):    <span style="color:#007020;font-weight:bold;">
    return</span> math<span style="color:#666666;">.</span>sqrt((y2 <span style="color:#666666;">-</span> y1)<span style="color:#666666;">**</span><span style="color:#40a070;">2</span> <span style="color:#666666;">+</span> (x2 <span style="color:#666666;">-</span> x1)<span style="color:#666666;">**</span><span style="color:#40a070;">2</span>)

sz <span style="color:#666666;">=</span> utils<span style="color:#666666;">.</span>get_sz()

pygame<span style="color:#666666;">.</span>init()screen <span style="color:#666666;">=</span> pygame<span style="color:#666666;">.</span>display<span style="color:#666666;">.</span>set_mode(sz, pygame<span style="color:#666666;">.</span>FULLSCREEN <span style="color:#666666;">|</span> pygame<span style="color:#666666;">.</span>NOFRAME)

pos <span style="color:#666666;">=</span> [(x<span style="color:#666666;">/</span><span style="color:#40a070;">2</span>) <span style="color:#666666;">-</span> <span style="color:#40a070;">50</span> <span style="color:#007020;font-weight:bold;">for</span> x <span style="color:#007020;font-weight:bold;">in</span> sz]size <span style="color:#666666;">=</span> <span style="color:#40a070;">100</span>bList <span style="color:#666666;">=</span> []

t <span style="color:#666666;">=</span> touch<span style="color:#666666;">.</span>touchpy()

<span style="color:#555555;font-weight:bold;">@t</span><span style="color:#666666;">.</span>event<span style="color:#007020;font-weight:bold;">def</span> <span style="color:#06287e;">TOUCH_DOWN</span>(blobID):    <span style="color:#007020;font-weight:bold;">
    global</span> bList
    bList<span style="color:#666666;">.</span>append(t<span style="color:#666666;">.</span>blobs[blobID])

<span style="color:#555555;font-weight:bold;">@t</span><span style="color:#666666;">.</span>event<span style="color:#007020;font-weight:bold;">def</span> <span style="color:#06287e;">TOUCH_MOVE</span>(blobID):    <span style="color:#007020;font-weight:bold;">
    global</span> bList, sz, size
    <span style="color:#007020;font-weight:bold;">if</span> <span style="color:#007020;">len</span>(bList) <span style="color:#666666;">==</span> <span style="color:#40a070;">1</span>:
        pos[<span style="color:#40a070;">0</span>] <span style="color:#666666;">+=</span> t<span style="color:#666666;">.</span>blobs[blobID]<span style="color:#666666;">.</span>xmot<span style="color:#666666;">*</span>sz[<span style="color:#40a070;">0</span>]
        pos[<span style="color:#40a070;">1</span>] <span style="color:#666666;">+=</span> t<span style="color:#666666;">.</span>blobs[blobID]<span style="color:#666666;">.</span>ymot<span style="color:#666666;">*</span>sz[<span style="color:#40a070;">1</span>]    <span style="color:#007020;font-weight:bold;">
    elif</span> <span style="color:#007020;">len</span>(bList) <span style="color:#666666;">==</span> <span style="color:#40a070;">2</span>:
        oDist <span style="color:#666666;">=</span> get_distance(bList[<span style="color:#40a070;">0</span>]<span style="color:#666666;">.</span>oxpos<span style="color:#666666;">*</span>sz[<span style="color:#40a070;">0</span>], bList[<span style="color:#40a070;">1</span>]<span style="color:#666666;">.</span>oxpos<span style="color:#666666;">*</span>sz[<span style="color:#40a070;">0</span>], bList[<span style="color:#40a070;">0</span>]<span style="color:#666666;">.</span>oypos<span style="color:#666666;">*</span>sz[<span style="color:#40a070;">1</span>], bList[<span style="color:#40a070;">1</span>]<span style="color:#666666;">.</span>oypos<span style="color:#666666;">*</span>sz[<span style="color:#40a070;">1</span>])        cDist <span style="color:#666666;">=</span> get_distance(bList[<span style="color:#40a070;">0</span>]<span style="color:#666666;">.</span>xpos<span style="color:#666666;">*</span>sz[<span style="color:#40a070;">0</span>], bList[<span style="color:#40a070;">1</span>]<span style="color:#666666;">.</span>xpos<span style="color:#666666;">*</span>sz[<span style="color:#40a070;">0</span>], bList[<span style="color:#40a070;">0</span>]<span style="color:#666666;">.</span>ypos<span style="color:#666666;">*</span>sz[<span style="color:#40a070;">1</span>], bList[<span style="color:#40a070;">1</span>]<span style="color:#666666;">.</span>ypos<span style="color:#666666;">*</span>sz[<span style="color:#40a070;">1</span>])

        z <span style="color:#666666;">=</span> <span style="color:#007020;">round</span>(oDist <span style="color:#666666;">/</span> cDist, <span style="color:#40a070;">1</span>)
        <span style="color:#007020;font-weight:bold;">if</span> z <span style="color:#666666;">&gt;=</span> <span style="color:#666666;">.</span><span style="color:#40a070;">5</span>:
            size <span style="color:#666666;">/=</span> z

<span style="color:#555555;font-weight:bold;">@t</span><span style="color:#666666;">.</span>event<span style="color:#007020;font-weight:bold;">
def</span> <span style="color:#06287e;">TOUCH_UP</span>(blobID, xpos, ypos):    <span style="color:#007020;font-weight:bold;">
    global</span> bList
    bList<span style="color:#666666;">.</span>remove(t<span style="color:#666666;">.</span>blobs[blobID])

<span style="color:#007020;font-weight:bold;">while</span> <span style="color:#40a070;">1</span>:
    screen<span style="color:#666666;">.</span>fill((<span style="color:#40a070;">0</span>, <span style="color:#40a070;">0</span>, <span style="color:#40a070;">0</span>))
    pygame<span style="color:#666666;">.</span>draw<span style="color:#666666;">.</span>aalines(screen, (<span style="color:#40a070;">0</span>, <span style="color:#40a070;">255</span>, <span style="color:#40a070;">0</span>), <span style="color:#007020;">True</span>, make_rectlist(pos, size))
<span style="color:#007020;font-weight:bold;">    for</span> event <span style="color:#007020;font-weight:bold;">in</span> pygame<span style="color:#666666;">.</span>event<span style="color:#666666;">.</span>get():
<span style="color:#007020;font-weight:bold;">        if</span> event<span style="color:#666666;">.</span>type <span style="color:#666666;">==</span> QUIT <span style="color:#007020;font-weight:bold;">or</span> (event<span style="color:#666666;">.</span>type <span style="color:#666666;">==</span> KEYDOWN <span style="color:#007020;font-weight:bold;">and</span> event<span style="color:#666666;">.</span>key <span style="color:#666666;">==</span> K_ESCAPE):
            sys<span style="color:#666666;">.</span>exit()
    t<span style="color:#666666;">.</span>update()
    pygame<span style="color:#666666;">.</span>display<span style="color:#666666;">.</span>flip()</pre>
</div>
</blockquote>
<p>We will be skipping all the imports, because they should make sense.  If they don&#8217;t I would recommend going back and reading tutorial 3 again.  There is one new one though, that deserves at least a small mention.</p>
<blockquote>
<div class="highlight">
<pre><span style="color:#007020;font-weight:bold;">from</span> <span style="color:#0e84b5;font-weight:bold;">touchpy</span> <span style="color:#007020;font-weight:bold;">import</span> utils</pre>
</div>
</blockquote>
<p>Since the last tutorial some changes to TouchPy have been made.  Nothing that drastically changes how it operates, just some new features that make working with it a lot easier.  A __init__.py file was added, so it can now be imported as a package, and a utils.py file was added.  All this file does is allow you to get screen dimensions, but it does work across all platforms through a single function, which is really nice.</p>
<blockquote>
<div class="highlight">
<pre><span style="color:#007020;font-weight:bold;">def</span> <span style="color:#06287e;">make_rectlist</span>(pos, size):
    <span style="color:#007020;font-weight:bold;">return</span> (pos, (pos[<span style="color:#40a070;">0</span>] <span style="color:#666666;">+</span> size, pos[<span style="color:#40a070;">1</span>]), (pos[<span style="color:#40a070;">0</span>] <span style="color:#666666;">+</span> size, pos[<span style="color:#40a070;">1</span>] <span style="color:#666666;">+</span> size), (pos[<span style="color:#40a070;">0</span>], pos[<span style="color:#40a070;">1</span>] <span style="color:#666666;">+</span> size))

<span style="color:#007020;font-weight:bold;">def</span> <span style="color:#06287e;">get_distance</span>(x1, y1, x2, y2):    <span style="color:#007020;font-weight:bold;">
    return</span> math<span style="color:#666666;">.</span>sqrt((y2 <span style="color:#666666;">-</span> y1)<span style="color:#666666;">**</span><span style="color:#40a070;">2</span> <span style="color:#666666;">+</span> (x2 <span style="color:#666666;">-</span> x1)<span style="color:#666666;">**</span><span style="color:#40a070;">2</span>)</pre>
</div>
</blockquote>
<p>Next we have two functions, make_rectlist() and get_distance().  make_rectlist() simply takes the position(bottom left corner) and size of a rectangle, and returns the position of each vertex(in pixels), in a four element tuple.  get_distance() uses the distance formula:<br />
<strong><img src='http://s0.wp.com/latex.php?latex=sqrt%7B%28y2-y1%29%5E2++%2B+%28x2-x1%29%5E2%7D&amp;bg=ffffff&amp;fg=656565&amp;s=0' alt='sqrt{(y2-y1)^2  + (x2-x1)^2}' title='sqrt{(y2-y1)^2  + (x2-x1)^2}' class='latex' /></strong></p>
<p>To calculate the distance in pixels between two points(in pixels).</p>
<blockquote><p>sz = utils.get_sz()</p></blockquote>
<p>This line uses that utils file we talked about earlier to get the screen size in pixels.  It would be a good idea to remember this function, as it works across Linux, Mac OS, and Windows, and is very helpful for almost any application with graphics involved.  get_sz() returns the size of the screen in pixels as a two element tuple, so on my system it returns (1280, 1024).</p>
<p>I believe I have adequately explained the next two lines, but if you do not understand them I recommend going back and reading tutorial 3.</p>
<blockquote>
<div class="highlight">
<pre>pos <span style="color:#666666;">=</span> [(x<span style="color:#666666;">/</span><span style="color:#40a070;">2</span>) <span style="color:#666666;">-</span> <span style="color:#40a070;">50</span> <span style="color:#007020;font-weight:bold;">for</span> x <span style="color:#007020;font-weight:bold;">in</span> sz]
size <span style="color:#666666;">=</span> <span style="color:#40a070;">100</span></pre>
</div>
</blockquote>
<p>All this does is center the box on the screen.  You do not have to worry about understanding this line, but if you do thats great!  All its doing is taking each screen dimension, diving by two, and subtracting 50(half the size of the box).  The same thing could be accomplished with:</p>
<blockquote>
<div class="highlight">
<pre>pos <span style="color:#666666;">=</span> [sz[<span style="color:#40a070;">0</span>] <span style="color:#666666;">/</span> <span style="color:#40a070;">2</span> <span style="color:#666666;">-</span> <span style="color:#40a070;">50</span>, sz[<span style="color:#40a070;">1</span>] <span style="color:#666666;">/</span> <span style="color:#40a070;">2</span> <span style="color:#666666;">-</span> <span style="color:#40a070;">50</span>]
size <span style="color:#666666;">=</span> <span style="color:#40a070;">100</span></pre>
</div>
</blockquote>
<p>Both pos and size are global variable that are constantly updated.  pos holds the position of the box(bottom left corner), and size holds the length of one side(its a square).  They are both mutable, because during the callbacks we update these values, then pass them through pygame.draw.lines to draw our square.</p>
<blockquote><p>bList = []</p></blockquote>
<p>This just defines another global, bList, which we use to hold all of the blobs that are currently alive, or have actual positions on the screen.  You will see why this is useful when we get to the TOUCH_MOVE callback.</p>
<p>The next line instantiates the touchy objects, which you should understand pretty well by now, and if you don&#8217;t, I would recommend reading tutorials 1 and 2.  Finally, we get the exciting part of the program!</p>
<p>Starting with the TOUCH_UP Callback:</p>
<div class="highlight">
<pre><span style="color:#555555;font-weight:bold;">@t</span><span style="color:#666666;">.</span>event
<span style="color:#007020;font-weight:bold;">def</span> <span style="color:#06287e;">TOUCH_DOWN</span>(blobID):
<span style="color:#007020;font-weight:bold;">    global</span> bList
    bList<span style="color:#666666;">.</span>append(t<span style="color:#666666;">.</span>blobs[blobID])</pre>
</div>
<p>This example uses a new callback-triggereing mechanism that I have not mentioned before.  They are called decorators. I have already mentioned them, but I will again suggest you read <a href="http://www.artima.com/weblogs/viewpost.jsp?thread=240808">this</a> for more information.</p>
<p>Moving on to the actual contents of this we see two lines.  The first just tells Python to include the global list bList into the scope of this callback, so we can access its elements.  The next appends the blob that was touched down(t.blobs[blobID]) to bList.</p>
<p>The TOUCH_MOVE callback is a bit more complicated, so we will skip over that for now and go over the TOUCH_UP callback.</p>
<div class="highlight">
<pre><span style="color:#555555;font-weight:bold;">@t</span><span style="color:#666666;">.</span>event<span style="color:#007020;font-weight:bold;">
def</span> <span style="color:#06287e;">TOUCH_UP</span>(blobID, xpos, ypos):    <span style="color:#007020;font-weight:bold;">
    global</span> bList    bList<span style="color:#666666;">.</span>remove(t<span style="color:#666666;">.</span>blobs[blobID])</pre>
</div>
<p>This does the opposite of TOUCH_DOWN.  It takes the blob that caused the TOUCH_UP event, and removes it from the list.  We do this because we are trying to keep bList current with the blobs that are actually on the screen, and thus we must remove the blobs that are no longer on the screen.</p>
<div class="highlight">
<pre><span style="color:#555555;font-weight:bold;">@t</span><span style="color:#666666;">.</span>event<span style="color:#007020;font-weight:bold;">
def</span> <span style="color:#06287e;">TOUCH_MOVE</span>(blobID):    <span style="color:#007020;font-weight:bold;">
    global</span> bList, sz, size
    <span style="color:#007020;font-weight:bold;">if</span> <span style="color:#007020;">len</span>(bList) <span style="color:#666666;">==</span> <span style="color:#40a070;">1</span>:
        pos[<span style="color:#40a070;">0</span>] <span style="color:#666666;">+=</span> t<span style="color:#666666;">.</span>blobs[blobID]<span style="color:#666666;">.</span>xmot<span style="color:#666666;">*</span>sz[<span style="color:#40a070;">0</span>]
        pos[<span style="color:#40a070;">1</span>] <span style="color:#666666;">+=</span> t<span style="color:#666666;">.</span>blobs[blobID]<span style="color:#666666;">.</span>ymot<span style="color:#666666;">*</span>sz[<span style="color:#40a070;">1</span>]    <span style="color:#007020;font-weight:bold;">
        if</span> <span style="color:#007020;">len</span>(bList) <span style="color:#666666;">==</span> <span style="color:#40a070;">2</span>:
            oDist <span style="color:#666666;">=</span> get_distance(bList[<span style="color:#40a070;">0</span>]<span style="color:#666666;">.</span>oxpos<span style="color:#666666;">*</span>sz[<span style="color:#40a070;">0</span>], bList[<span style="color:#40a070;">1</span>]<span style="color:#666666;">.</span>oxpos<span style="color:#666666;">*</span>sz[<span style="color:#40a070;">0</span>], bList[<span style="color:#40a070;">0</span>]<span style="color:#666666;">.</span>oypos<span style="color:#666666;">*</span>sz[<span style="color:#40a070;">1</span>], bList[<span style="color:#40a070;">1</span>]<span style="color:#666666;">.</span>oypos<span style="color:#666666;">*</span>sz[<span style="color:#40a070;">1</span>])
            cDist <span style="color:#666666;">=</span> get_distance(bList[<span style="color:#40a070;">0</span>]<span style="color:#666666;">.</span>xpos<span style="color:#666666;">*</span>sz[<span style="color:#40a070;">0</span>], bList[<span style="color:#40a070;">1</span>]<span style="color:#666666;">.</span>xpos<span style="color:#666666;">*</span>sz[<span style="color:#40a070;">0</span>], bList[<span style="color:#40a070;">0</span>]<span style="color:#666666;">.</span>ypos<span style="color:#666666;">*</span>sz[<span style="color:#40a070;">1</span>], bList[<span style="color:#40a070;">1</span>]<span style="color:#666666;">.</span>ypos<span style="color:#666666;">*</span>sz[<span style="color:#40a070;">1</span>])

            z <span style="color:#666666;">=</span> <span style="color:#007020;">round</span>(oDist <span style="color:#666666;">/</span> cDist, <span style="color:#40a070;">1</span>)        <span style="color:#007020;font-weight:bold;">
            if</span> z <span style="color:#666666;">&gt;=</span> <span style="color:#666666;">.</span><span style="color:#40a070;">5</span>:
                size <span style="color:#666666;">/=</span> z</pre>
</div>
<p>In this callback we decide whether the user wants to resize, or move the box.  If there is one blob then it is assumed that they want to move the box, which is done by adding the relative movement of the blob to the position of the box.  If there are two fingers on the table then it is assumed that they would like to resize the box.</p>
<div class="highlight">
<pre>        oDist <span style="color:#666666;">=</span> get_distance(bList[<span style="color:#40a070;">0</span>]<span style="color:#666666;">.</span>oxpos<span style="color:#666666;">*</span>sz[<span style="color:#40a070;">0</span>], bList[<span style="color:#40a070;">1</span>]<span style="color:#666666;">.</span>oxpos<span style="color:#666666;">*</span>sz[<span style="color:#40a070;">0</span>], bList[<span style="color:#40a070;">0</span>]<span style="color:#666666;">.</span>oypos<span style="color:#666666;">*</span>sz[<span style="color:#40a070;">1</span>], bList[<span style="color:#40a070;">1</span>]<span style="color:#666666;">.</span>oypos<span style="color:#666666;">*</span>sz[<span style="color:#40a070;">1</span>])</pre>
</div>
<p>In this line we get the distance between the old position of the blob(oxpos, oypos) in pixels using the distance formula.  In the next line we do the same with the current position.  Next we get the ratio of change between the two, and apply this to the zoom.  This achieves the effect of zooming in.  This is not the best way to do it, as you will notice it is a bit jerky, and will jump around at times.  In a future tutorial I will present some better ways of zooming.</p>
<div class="highlight">
<pre><span style="color:#007020;font-weight:bold;">while</span> <span style="color:#40a070;">1</span>:
    screen<span style="color:#666666;">.</span>fill((<span style="color:#40a070;">0</span>, <span style="color:#40a070;">0</span>, <span style="color:#40a070;">0</span>))
    pygame<span style="color:#666666;">.</span>draw<span style="color:#666666;">.</span>aalines(screen, (<span style="color:#40a070;">0</span>, <span style="color:#40a070;">255</span>, <span style="color:#40a070;">0</span>), <span style="color:#007020;">True</span>, make_rectlist(pos, size))    <span style="color:#007020;font-weight:bold;">
    for</span> event <span style="color:#007020;font-weight:bold;">in</span> pygame<span style="color:#666666;">.</span>event<span style="color:#666666;">.</span>get():        <span style="color:#007020;font-weight:bold;">
        if</span> event<span style="color:#666666;">.</span>type <span style="color:#666666;">==</span> QUIT <span style="color:#007020;font-weight:bold;">or</span> (event<span style="color:#666666;">.</span>type <span style="color:#666666;">==</span> KEYDOWN <span style="color:#007020;font-weight:bold;">and</span> event<span style="color:#666666;">.</span>key <span style="color:#666666;">==</span> K_ESCAPE):
    sys<span style="color:#666666;">.</span>exit()
    t<span style="color:#666666;">.</span>update()
    pygame<span style="color:#666666;">.</span>display<span style="color:#666666;">.</span>flip()</pre>
</div>
<p>Next we have the main program loop.  This is pretty simple.  Clear the display, draw the box, see if the user wants to quit(hit the escape key or get QUIT event from OS), updates touchpy, then flips PyGame&#8217;s display.</p>
<p>That concludes this tutorial!  As always, if you have any suggestions or ideas for a new tutorial I am happyto hear them!  I don&#8217;t really know where to go from here with the tutorials, I think I will start with something useful, or maybe kinetic scrolling, who knows&#8230;  I would love to hear from you and see what you have to think!</p>
<p>Recommended resources for further reading:</p>
<ul>
<li><a href="http://www.artima.com/weblogs/viewpost.jsp?thread=240808">An explanation of Python decorators</a></li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xelapondsstuff.wordpress.com/231/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xelapondsstuff.wordpress.com/231/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xelapondsstuff.wordpress.com/231/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xelapondsstuff.wordpress.com/231/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xelapondsstuff.wordpress.com/231/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xelapondsstuff.wordpress.com/231/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xelapondsstuff.wordpress.com/231/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xelapondsstuff.wordpress.com/231/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xelapondsstuff.wordpress.com/231/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xelapondsstuff.wordpress.com/231/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xelapondsstuff.wordpress.com/231/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xelapondsstuff.wordpress.com/231/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xelapondsstuff.wordpress.com/231/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xelapondsstuff.wordpress.com/231/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xelapondsstuff.wordpress.com&amp;blog=3595014&amp;post=231&amp;subd=xelapondsstuff&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xelapondsstuff.wordpress.com/2008/12/03/getting-started-with-multi-touch-development-in-python-part-4/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6c32a4f18b03a2e3acdfbdce7becccde?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">xelapondsstuff</media:title>
		</media:content>
	</item>
		<item>
		<title>tPhysics:  A Multi-Touch Physics Sandbox</title>
		<link>http://xelapondsstuff.wordpress.com/2008/10/09/tphysics-a-multi-touch-physics-sandbox/</link>
		<comments>http://xelapondsstuff.wordpress.com/2008/10/09/tphysics-a-multi-touch-physics-sandbox/#comments</comments>
		<pubDate>Thu, 09 Oct 2008 14:47:14 +0000</pubDate>
		<dc:creator>xelapondsstuff</dc:creator>
				<category><![CDATA[Multi-Touch]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://xelapondsstuff.wordpress.com/?p=208</guid>
		<description><![CDATA[Lately I have been working on a Multi-Touch Physics application.  It is pretty much a big 2D physics sandbox, you can spawn new objects, make joints, then throw them at stuff.  Its written in Python, using Box2D for the Physics engine.  TouchPy is used for TUIO Parsing, and PyGame for graphical output. It does support [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xelapondsstuff.wordpress.com&amp;blog=3595014&amp;post=208&amp;subd=xelapondsstuff&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Lately I have been working on a Multi-Touch Physics application.  It is pretty much a big 2D physics sandbox, you can spawn new objects, make joints, then throw them at stuff.  Its written in Python, using Box2D for the Physics engine.  TouchPy is used for TUIO Parsing, and PyGame for graphical output.</p>
<p>It does support a ZUI, but it is not a &#8220;full ZUI&#8221;.  It does have simulation limits, so if an object happens to leave this limit it will freeze(as seen in video below).  It also does not implement the Gear Joint, but all the other joints are supported.</p>
<p>Its still in early development, so it has its share of bugs.  The biggest has to do with triangles.  When you choose to make an arbitrary polygon, it works fine with any number of vertices between 4 and 8, but once you try 3 weird things happen.  Half of the time it will work, and the other half it won&#8217;t.  Due to the way PyBox2D was coded, I can&#8217;t catch this error either(or any Box2D error, for that matter), so the program will unceremoniously exit.</p>
<p>Code can be had from the downloads page, and here is a video!</p>
<span style="text-align:center; display: block;"><a href="http://xelapondsstuff.wordpress.com/2008/10/09/tphysics-a-multi-touch-physics-sandbox/"><img src="http://img.youtube.com/vi/DPnCDhkawGk/2.jpg" alt="" /></a></span>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xelapondsstuff.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xelapondsstuff.wordpress.com/208/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xelapondsstuff.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xelapondsstuff.wordpress.com/208/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xelapondsstuff.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xelapondsstuff.wordpress.com/208/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xelapondsstuff.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xelapondsstuff.wordpress.com/208/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xelapondsstuff.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xelapondsstuff.wordpress.com/208/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xelapondsstuff.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xelapondsstuff.wordpress.com/208/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xelapondsstuff.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xelapondsstuff.wordpress.com/208/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xelapondsstuff.wordpress.com&amp;blog=3595014&amp;post=208&amp;subd=xelapondsstuff&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xelapondsstuff.wordpress.com/2008/10/09/tphysics-a-multi-touch-physics-sandbox/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6c32a4f18b03a2e3acdfbdce7becccde?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">xelapondsstuff</media:title>
		</media:content>
	</item>
		<item>
		<title>Getting started with Multi-Touch Development in Python:  Part 3</title>
		<link>http://xelapondsstuff.wordpress.com/2008/09/30/getting-started-with-multi-touch-development-in-python-part-3/</link>
		<comments>http://xelapondsstuff.wordpress.com/2008/09/30/getting-started-with-multi-touch-development-in-python-part-3/#comments</comments>
		<pubDate>Tue, 30 Sep 2008 04:27:59 +0000</pubDate>
		<dc:creator>xelapondsstuff</dc:creator>
				<category><![CDATA[Multi-Touch]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://xelapondsstuff.wordpress.com/?p=192</guid>
		<description><![CDATA[Its been a few weeks since I wrote a tutorial(or posted on this blog, for that matter), so I figured it was about time.  In this tutorial we will be starting from scratch, and using a different method to get touches.  At the end of this tutorial you will have used PyGame to write a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xelapondsstuff.wordpress.com&amp;blog=3595014&amp;post=192&amp;subd=xelapondsstuff&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Its been a few weeks since I wrote a tutorial(or posted on this blog, for that matter), so I figured it was about time.  In this tutorial we will be starting from scratch, and using a different method to get touches.  At the end of this tutorial you will have used PyGame to write a program that will draw circles under each touch, and follow them as they move.  Most importantly, you will understand how to do it yourself!</p>
<p><span id="more-192"></span></p>
<p>Get started by firing up your favorite editor and making a new Python file.  I named mine PyTracer.py, but you can name it anything you want.</p>
<p>So, lets get started coding!</p>
<p>In this program I am going to take a new approach to doing tutorials.  I am going to give you the whole program, then explain it line by line, so you can easily skip over parts you understand, or read through the whole thing.</p>
<p>So, lets get started!</p>
<pre><span style="font-weight:bold;color:#007020;">import</span> <span style="font-weight:bold;color:#0e84b5;">sys</span>

<span style="font-weight:bold;color:#007020;">import</span> <span style="font-weight:bold;color:#0e84b5;">pygame</span>
<span style="font-weight:bold;color:#007020;">from</span> <span style="font-weight:bold;color:#0e84b5;">touch</span> <span style="font-weight:bold;color:#007020;">import</span> touchpy

screen_dimensions <span style="color:#666666;">=</span> (<span style="color:#40a070;">1280</span>, <span style="color:#40a070;">1024</span>)

t <span style="color:#666666;">=</span> touchpy()

pygame<span style="color:#666666;">.</span>init()
screen <span style="color:#666666;">=</span> pygame<span style="color:#666666;">.</span>display<span style="color:#666666;">.</span>set_mode(screen_dimensions, pygame<span style="color:#666666;">.</span>FULLSCREEN <span style="color:#666666;">|</span> pygame<span style="color:#666666;">.</span>NOFRAME)

<span style="font-weight:bold;color:#007020;">while</span> <span style="color:#40a070;">1</span>:
    screen<span style="color:#666666;">.</span>fill((<span style="color:#40a070;">0</span>, <span style="color:#40a070;">0</span>, <span style="color:#40a070;">0</span>))
    t<span style="color:#666666;">.</span>update()

    <span style="font-weight:bold;color:#007020;">for</span> event <span style="font-weight:bold;color:#007020;">in</span> pygame<span style="color:#666666;">.</span>event<span style="color:#666666;">.</span>get():
        <span style="font-weight:bold;color:#007020;">if</span> event<span style="color:#666666;">.</span>type <span style="color:#666666;">==</span> pygame<span style="color:#666666;">.</span>QUIT <span style="font-weight:bold;color:#007020;">or</span> event<span style="color:#666666;">.</span>type <span style="color:#666666;">==</span> pygame<span style="color:#666666;">.</span>KEYDOWN:
            sys<span style="color:#666666;">.</span>exit()

    <span style="font-weight:bold;color:#007020;">for</span> blobid <span style="font-weight:bold;color:#007020;">in</span> t<span style="color:#666666;">.</span>blobs:
        x <span style="color:#666666;">=</span> <span style="color:#007020;">int</span>(<span style="color:#007020;">round</span>(t<span style="color:#666666;">.</span>blobs[blobid]<span style="color:#666666;">.</span>xpos<span style="color:#666666;">*</span>screen_dimensions[<span style="color:#40a070;">0</span>]))
        y <span style="color:#666666;">=</span> <span style="color:#007020;">int</span>(<span style="color:#007020;">round</span>(t<span style="color:#666666;">.</span>blobs[blobid]<span style="color:#666666;">.</span>ypos<span style="color:#666666;">*</span>screen_dimensions[<span style="color:#40a070;">1</span>]))

        <span style="font-weight:bold;color:#007020;">if</span> blobid <span style="color:#666666;">%</span> <span style="color:#40a070;">2</span> <span style="color:#666666;">==</span> <span style="color:#40a070;">0</span>:
            pygame<span style="color:#666666;">.</span>draw<span style="color:#666666;">.</span>circle(screen, (<span style="color:#40a070;">232</span>, <span style="color:#40a070;">4</span>, <span style="color:#40a070;">40</span>), (x, y), <span style="color:#40a070;">50</span>)

        <span style="font-weight:bold;color:#007020;">else</span>:
            pygame<span style="color:#666666;">.</span>draw<span style="color:#666666;">.</span>circle(screen, (<span style="color:#40a070;">40</span>, <span style="color:#40a070;">232</span>, <span style="color:#40a070;">20</span>), (x, y), <span style="color:#40a070;">50</span>)

    pygame<span style="color:#666666;">.</span>display<span style="color:#666666;">.</span>flip()</pre>
<p>So, now we can go through this line by line.  Before I start explaining that, notice a few things:</p>
<ul>
<li>This program does not use any callbacks, unlike previous tutorials</li>
<li>To get touch events. we iterate the t.blobs dictionary</li>
<li>The main loop is most of the program, where it used to just be t.update()</li>
</ul>
<p>Each of these will be explained in more detail as the tutorial goes on.</p>
<blockquote>
<div class="highlight">
<pre><span style="font-weight:bold;color:#007020;">import</span> <span style="font-weight:bold;color:#0e84b5;">sys</span>

<span style="font-weight:bold;color:#007020;">import</span> <span style="font-weight:bold;color:#0e84b5;">pygame</span>
<span style="font-weight:bold;color:#007020;">from</span> <span style="font-weight:bold;color:#0e84b5;">touch</span> <span style="font-weight:bold;color:#007020;">import</span> touchpy</pre>
</div>
</blockquote>
<p>Here we import all the necessary libraries.  This is pretty self explanatory, but I will explain it anyway.  We import sys purely for sys.exit(), so we can exit whenever the user hits a key.  PyGame is the graphics library we use to draw the circles, so naturally we should import it.  If you have not played around with PyGame, you are missing out.  Check it out <a href="http://www.pygame.org/news.html">here</a>, its an awesome graphics library.  Next is the line you should be used to seeing by now, importing the TouchPy library.  In case you have not read PEP 008, you should always differentiate between built in libraries, third party installed libraries, and local file includes by spacing them with newlines.  I highly recommend you read PEP 008 for tips on style in Python coding.  It makes your code a lot easier to read, and 99% of Python coders follow this standard.  It can be found <a href="http://www.python.org/dev/peps/pep-0008/">here</a>.</p>
<blockquote>
<div class="highlight">
<pre>screen_dimensions <span style="color:#666666;">=</span> (<span style="color:#40a070;">1280</span>, <span style="color:#40a070;">1024</span>)</pre>
</div>
</blockquote>
<p>You should also be familiar with this line.  It is used to convert TouchPy coordinates into pixel coordinates.  Of course, set this to your own screen resolution.</p>
<div class="highlight">
<pre>t <span style="color:#666666;">=</span> touchpy()</pre>
</div>
<p>This line imports the TouchPy framework, and opens the network socket.  TouchPy should always be the first thing you initialize in your program, because sometime it can take a long time to initialize.  This way, it waits until TouchPy is ready to start the GUI.  If you put this after the PyGame initialization it would open a window before it was ready, and then &#8220;stack up&#8221; touch events, then release them all at once when TouchPy was ready.</p>
<blockquote>
<div class="highlight">
<pre>pygame<span style="color:#666666;">.</span>init()
screen <span style="color:#666666;">=</span> pygame<span style="color:#666666;">.</span>display<span style="color:#666666;">.</span>set_mode(screen_dimensions, pygame<span style="color:#666666;">.</span>FULLSCREEN <span style="color:#666666;">|</span> pygame<span style="color:#666666;">.</span>NOFRAME)</pre>
</div>
</blockquote>
<p>If you have had any experience with PyGame, this line should be very familiar, otherwise, Ill explain it.  The first line initializes PyGame by going through each imported module and initializing it.  The second line makes a screen for us to blit(copy images) onto.  The first argument is the size(in pixels) of the window you want.  We pass the screen size in, because we intend to make this program full screen.  Then next arguments are graphics options, you can pass nothing in and it will run fine, but we want it to be full screen and have no frame.  This is just fancy for saying override everything(panels, other windows), and hog mouse/keyboard input(don&#8217;t allow to lose focus until program exits).</p>
<blockquote>
<div class="highlight">
<pre><span style="font-weight:bold;color:#007020;">while</span> <span style="color:#40a070;">1</span>:
    screen<span style="color:#666666;">.</span>fill((<span style="color:#40a070;">0</span>, <span style="color:#40a070;">0</span>, <span style="color:#40a070;">0</span>))
    t<span style="color:#666666;">.</span>update()

    <span style="font-weight:bold;color:#007020;">for</span> event <span style="font-weight:bold;color:#007020;">in</span> pygame<span style="color:#666666;">.</span>event<span style="color:#666666;">.</span>get():
        <span style="font-weight:bold;color:#007020;">if</span> event<span style="color:#666666;">.</span>type <span style="color:#666666;">==</span> pygame<span style="color:#666666;">.</span>QUIT <span style="font-weight:bold;color:#007020;">or</span> event<span style="color:#666666;">.</span>type <span style="color:#666666;">==</span> pygame<span style="color:#666666;">.</span>KEYDOWN:
            sys<span style="color:#666666;">.</span>exit()

    <span style="font-weight:bold;color:#007020;">for</span> blobid <span style="font-weight:bold;color:#007020;">in</span> t<span style="color:#666666;">.</span>blobs:
        x <span style="color:#666666;">=</span> <span style="color:#007020;">int</span>(<span style="color:#007020;">round</span>(t<span style="color:#666666;">.</span>blobs[blobid]<span style="color:#666666;">.</span>xpos<span style="color:#666666;">*</span>screen_dimensions[<span style="color:#40a070;">0</span>]))
        y <span style="color:#666666;">=</span> <span style="color:#007020;">int</span>(<span style="color:#007020;">round</span>(t<span style="color:#666666;">.</span>blobs[blobid]<span style="color:#666666;">.</span>ypos<span style="color:#666666;">*</span>screen_dimensions[<span style="color:#40a070;">1</span>]))

        <span style="font-weight:bold;color:#007020;">if</span> blobid <span style="color:#666666;">%</span> <span style="color:#40a070;">2</span> <span style="color:#666666;">==</span> <span style="color:#40a070;">0</span>:
            pygame<span style="color:#666666;">.</span>draw<span style="color:#666666;">.</span>circle(screen, (<span style="color:#40a070;">232</span>, <span style="color:#40a070;">4</span>, <span style="color:#40a070;">40</span>), (x, y), <span style="color:#40a070;">50</span>)

        <span style="font-weight:bold;color:#007020;">else</span>:
            pygame<span style="color:#666666;">.</span>draw<span style="color:#666666;">.</span>circle(screen, (<span style="color:#40a070;">40</span>, <span style="color:#40a070;">232</span>, <span style="color:#40a070;">20</span>), (x, y), <span style="color:#40a070;">50</span>)

    pygame<span style="color:#666666;">.</span>display<span style="color:#666666;">.</span>flip()</pre>
</div>
</blockquote>
<p>This is our event loop.  All the action happens here, so, lets go through it.</p>
<blockquote>
<div class="highlight">
<pre>    screen<span style="color:#666666;">.</span>fill((<span style="color:#40a070;">0</span>, <span style="color:#40a070;">0</span>, <span style="color:#40a070;">0</span>))</pre>
</div>
</blockquote>
<p>This line clears the screen to black.  If we did not have this line, it would act more like a paint program.  Comment it out and try it.  If you have never dealt with computer animation this may seem strange, but it makes sense once you get it(doesn&#8217;t everything:D). If this is new to you,  I recommend you read <a href="http://www.pygame.org/docs/tut/intro/intro.html">this</a> for a really quick intro to PyGame/Computer animation.</p>
<blockquote><p>t.update()</p></blockquote>
<p>This line should be very familiar by now, but it deserves an explanation all the same.  This line calls the &#8220;update&#8221; method of theTtouchPy object.  In this method it clears the event queue, then checks for new TUIO events through server.recv(0).  If you were to comment out this line nothing would happen, because TouchPy would never check for new TUIO events.</p>
<blockquote>
<div class="highlight">
<pre>    <span style="font-weight:bold;color:#007020;">for</span> event <span style="font-weight:bold;color:#007020;">in</span> pygame<span style="color:#666666;">.</span>event<span style="color:#666666;">.</span>get():
        <span style="font-weight:bold;color:#007020;">if</span> event<span style="color:#666666;">.</span>type <span style="color:#666666;">==</span> pygame<span style="color:#666666;">.</span>QUIT <span style="font-weight:bold;color:#007020;">or</span> event<span style="color:#666666;">.</span>type <span style="color:#666666;">==</span> pygame<span style="color:#666666;">.</span>KEYDOWN:
            sys<span style="color:#666666;">.</span>exit()</pre>
</div>
</blockquote>
<p>This is the code that lets you quit the program.  It will call sys.exit() on two conditions:</p>
<p>1.  It was told to quit by the OS(kill system call, close button clicked, system shutdown imminent, etc)</p>
<p>2.  A key was pressed on the keyboard</p>
<blockquote>
<div class="highlight">
<pre><span style="font-weight:bold;color:#007020;">for</span> blobid <span style="font-weight:bold;color:#007020;">in</span> t<span style="color:#666666;">.</span>blobs:
        x <span style="color:#666666;">=</span> <span style="color:#007020;">int</span>(<span style="color:#007020;">round</span>(t<span style="color:#666666;">.</span>blobs[blobid]<span style="color:#666666;">.</span>xpos<span style="color:#666666;">*</span>screen_dimensions[<span style="color:#40a070;">0</span>]))
        y <span style="color:#666666;">=</span> <span style="color:#007020;">int</span>(<span style="color:#007020;">round</span>(t<span style="color:#666666;">.</span>blobs[blobid]<span style="color:#666666;">.</span>ypos<span style="color:#666666;">*</span>screen_dimensions[<span style="color:#40a070;">1</span>]))

        <span style="font-weight:bold;color:#007020;">if</span> blobid <span style="color:#666666;">%</span> <span style="color:#40a070;">2</span> <span style="color:#666666;">==</span> <span style="color:#40a070;">0</span>:
            pygame<span style="color:#666666;">.</span>draw<span style="color:#666666;">.</span>circle(screen, (<span style="color:#40a070;">232</span>, <span style="color:#40a070;">4</span>, <span style="color:#40a070;">40</span>), (x, y), <span style="color:#40a070;">50</span>)

        <span style="font-weight:bold;color:#007020;">else</span>:
            pygame<span style="color:#666666;">.</span>draw<span style="color:#666666;">.</span>circle(screen, (<span style="color:#40a070;">40</span>, <span style="color:#40a070;">232</span>, <span style="color:#40a070;">20</span>), (x, y), <span style="color:#40a070;">50</span>)</pre>
</div>
</blockquote>
<p>This is where the real magic happens.  Here it gets the coordinates of all the touches, and draws circles there.  The for loop is iterating through the list blobs, which is an attribute of the TouchPy object, t.  t. blobs is a dictionary of blobIDs and Tuio2DCursor Objects.  We iterate through the list of blobIDs, then use that as the index to get the actual Tuio2DCursor Object.  Then next two lines get the x and y position in coordinates.  If you don&#8217;t understand this, you should go back and (re)read <a href="http://xelapondsstuff.wordpress.com/2008/08/26/getting-started-with-multi-touch-development-in-python-part-2/#comments">part two</a>.</p>
<blockquote>
<div class="highlight">
<pre>        <span style="font-weight:bold;color:#007020;">if</span> blobid <span style="color:#666666;">%</span> <span style="color:#40a070;">2</span> <span style="color:#666666;">==</span> <span style="color:#40a070;">0</span>:
            pygame<span style="color:#666666;">.</span>draw<span style="color:#666666;">.</span>circle(screen, (<span style="color:#40a070;">232</span>, <span style="color:#40a070;">4</span>, <span style="color:#40a070;">40</span>), (x, y), <span style="color:#40a070;">50</span>)

        <span style="font-weight:bold;color:#007020;">else</span>:
            pygame<span style="color:#666666;">.</span>draw<span style="color:#666666;">.</span>circle(screen, (<span style="color:#40a070;">40</span>, <span style="color:#40a070;">232</span>, <span style="color:#40a070;">20</span>), (x, y), <span style="color:#40a070;">50</span>)</pre>
</div>
</blockquote>
<p>This is where the circles get painted.  All the if statement is for is just to add some pizazz to the program.  It just colors every other blob red or green.  You could replace the whole if statement with one of the circle paint statements and it would still work fine.  Speaking of circle paint statements, this is a PyGame function for drawing a circle.  It does not need an image to be blitted, you just pass it the screen you want it on, color, position, and radius.</p>
<blockquote><p>pygame.display.flip()</p></blockquote>
<p>In computer animation there are really two images of the screen.  The one that is being shown, and the one that you are modifying.  Every time you want something new to show up you flip them, so you show the one you modified, then modify the other one.  If this doesn&#8217;t make sense you should read the PyGame into <a href="http://www.pygame.org/docs/tut/intro/intro.html">here</a>.</p>
<p>That concludes this tutorial.  I think the rest of the tutorials will follow this form, except maybe the first few after Python-Lux comes out.  I appreciate all feedback, and would love to hear how well this tutorial went for you.  Also, if you have any ideas for a tutorial, let me know:)  I am going to try and do about one every two weeks, and see how that goes.  Thanks for reading!</p>
<p>Other interesting Python stuff you may want to read:</p>
<ul>
<li><a href="http://www.pygame.org/docs/tut/MoveIt.html">An Overview of how Computers handle Graphics</a></li>
<li><a href="http://www.pygame.org/docs/tut/intro/intro.html">A quick intro to Computer Animation and PyGame</a></li>
<li><a href="http://www.python.org/dev/peps/pep-0008/">Style guide for Python Code</a></li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xelapondsstuff.wordpress.com/192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xelapondsstuff.wordpress.com/192/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xelapondsstuff.wordpress.com/192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xelapondsstuff.wordpress.com/192/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xelapondsstuff.wordpress.com/192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xelapondsstuff.wordpress.com/192/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xelapondsstuff.wordpress.com/192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xelapondsstuff.wordpress.com/192/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xelapondsstuff.wordpress.com/192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xelapondsstuff.wordpress.com/192/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xelapondsstuff.wordpress.com/192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xelapondsstuff.wordpress.com/192/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xelapondsstuff.wordpress.com/192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xelapondsstuff.wordpress.com/192/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xelapondsstuff.wordpress.com&amp;blog=3595014&amp;post=192&amp;subd=xelapondsstuff&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xelapondsstuff.wordpress.com/2008/09/30/getting-started-with-multi-touch-development-in-python-part-3/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6c32a4f18b03a2e3acdfbdce7becccde?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">xelapondsstuff</media:title>
		</media:content>
	</item>
		<item>
		<title>Getting Started with Multi-Touch Development in Python: Part 2</title>
		<link>http://xelapondsstuff.wordpress.com/2008/08/26/getting-started-with-multi-touch-development-in-python-part-2/</link>
		<comments>http://xelapondsstuff.wordpress.com/2008/08/26/getting-started-with-multi-touch-development-in-python-part-2/#comments</comments>
		<pubDate>Tue, 26 Aug 2008 15:40:35 +0000</pubDate>
		<dc:creator>xelapondsstuff</dc:creator>
				<category><![CDATA[DIY]]></category>
		<category><![CDATA[Multi-Touch]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://xelapondsstuff.wordpress.com/?p=166</guid>
		<description><![CDATA[This is the second part in an endless series of tutorials dealing with Multi-Touch Development in Python.  If you have not read the first one yet, it can be found here. In the last tutorial we made a really useless example, where every time each TUIO event happened, it would print out &#8220;Something left the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xelapondsstuff.wordpress.com&amp;blog=3595014&amp;post=166&amp;subd=xelapondsstuff&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is the second part in an endless series of tutorials dealing with Multi-Touch Development in Python.  If you have not read the first one yet, it can be found <a href="http://xelapondsstuff.wordpress.com/2008/08/25/getting-started-with-multi-touch-development-in-python/">here</a>.</p>
<p>In the last tutorial we made a really useless example, where every time each TUIO event happened, it would print out &#8220;Something left the table&#8221;, &#8220;Something moved on the table&#8221;, or &#8220;Something was placed on the table&#8221;.  We are going to further extend this program to print out where it happened.</p>
<p><span id="more-166"></span></p>
<p>So, get started by firing up your editor and opening hellomt.py.  If you are particularly fond of your first program, you can copy it and name it hellomt2.py, or whatever you want for that matter.  No explanation of this program is needed, because you wrote it:)</p>
<p>If you noticed, common between all three callbacks is an argument that gets passed call blobID.  blobID itself in an integer, which contains the blobID of the blob the callback is referring too.  On every print line you wrote in the last tutorial, add this to the end:</p>
<blockquote><p>+ str(blobID)</p></blockquote>
<p>Now cd into the directory where the program lies, and run the program:</p>
<blockquote><p>python ./hellomt.py</p></blockquote>
<p>Now when you touch the surface it should print &#8220;Something was placed on the surface 1&#8243;.  And every time you touch that number should increase.  The blobID is the index of a list called blobs.  You access blobs through the Observer.  In this program the Observer is instantiated as &#8216;t&#8217;, so you would access it as t.blobs.  t.blobs is a list of TUIO2DCursor Objects.  If you were to print t.blobs, each entry would look something like this:</p>
<blockquote><p>&lt;touch.Tuio2DCursor object at 0x823f36c&gt;</p></blockquote>
<p>If we poke around TouchPy a bit(or just pass t.blobs[blobID] through the dir() function, we can figure out that it has the following attributes:</p>
<blockquote><p>['Height', 'Width', '__class__', '__delattr__', '__dict__', '__doc__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', '__weakref__', '_event_stack', '_get_handlers', '_raise_dispatch_exception', 'blobID', 'dispatch_event', 'event', 'mot_accel', 'move', 'oxpos', 'oypos', 'pop_handlers', 'push_handlers', 'register_event_type', 'remove_handler', 'remove_handlers', 'set_handler', 'set_handlers', 'xmot', 'xpos', 'ymot', 'ypos']</p></blockquote>
<p>The only ones we really care about right now are xpos and ypos.  In other tutorials we will get to more of them, such as Height, Width, xmot, ymot, and probably others as well.  So, how do we get the x and y position of a blob?  Like this:</p>
<blockquote><p>x = t.blobs[blobID].xpos<br />
y = t.blobs[blobID].ypos</p></blockquote>
<p>If you understand this line then skip this paragraph.  Otherwise, if you are still unclear(like I always was when I started Python), read on.  This line accesses the List &#8220;blobs&#8221;(which is a list of TUIO2DCursor Objects, or pretty much its a list of blobs), that is inside the observer(named &#8216;t&#8217;).  Because its a list, it has an index, and the index of the blob we want is blobID.  That returns a TUIO2DCursor Object, which we take the xpos attribute of.</p>
<p>So, to print the x and y position of each blob, lets do this:</p>
<p>Replace your print line in touch_up with:</p>
<blockquote><p>x = t.blobs[blobID].xpos<br />
y = t.blobs[blobID].ypos<br />
print &#8216;Touch Up at &#8216; + str(x) + &#8216; , &#8216; + str(y)</p></blockquote>
<p>Replace the print line in touch_move with:</p>
<blockquote><p>x = t.blobs[blobID].xpos<br />
y = t.blobs[blobID].ypos<br />
print &#8216;Touch Up at &#8216; + str(x) + &#8216; , &#8216; + str(y)</p></blockquote>
<p>You should be able to figure out how to do the last one(touch_down).</p>
<p>When you run this program, each line should look like this, substituting Touch Up for the right event:</p>
<blockquote><p>Touch Up at 0.478175550699 , 0.86176776886</p></blockquote>
<p>If you look at those coordinates, evidently they are not pixel locations.  To get decimal coordinates, multiply each x coordinate by the width of the screen, and each y coordinate by the height of the screen.  Because I am anticipating people reading this guide will be running many different Operating Systems, I will not show any specific way to get the screen resolution, and have people hard code their screen resolution into the program.  Make a global constant-tuple at the top of your program(anywhere before the callbacks is fine) with your screen dimensions.  Mine looks like this:</p>
<blockquote><p>screen_dimensions = (1280, 800)</p></blockquote>
<p>Then in your callbacks on the lines that you calculate the X value, add this to the end:</p>
<blockquote><p>*screen_dimensions[0]</p></blockquote>
<p>Which is simply, multiply by the screens X dimensions.  Do the same for the Y calculations, except multiply by the Height of the screen.  Run your program, and observe the output.</p>
<p>Each line should look like this, substituting the correct event:</p>
<blockquote><p>Touch Up at 832.000045776 , 49.9999940395</p></blockquote>
<p>Now you have More accurate pixel coordinates, but you can&#8217;t really put a dot half-way through a Pixel.  Solve this by int-rounding each calculation.  int-rounding is the name I made up for the process of rounding to the nearest whole floating number, then making this an integer.  You do this by passing your calculation through int(round()).  The X calculation would look like this:</p>
<blockquote><p>x = int(round(t.blobs[blobID].xpos*screen_dimensions[0]))</p></blockquote>
<p>Do this to all of the calculations, both x and y.  Now running your program should yield results similar to these, substituting the correct event:</p>
<blockquote><p>Touch Up at 922 , 492</p></blockquote>
<p>Congratulations!  You can now get X and Y position of events! In the next tutorial we will write a small program using Clutter to draw circles over all the blobs.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/xelapondsstuff.wordpress.com/166/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/xelapondsstuff.wordpress.com/166/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xelapondsstuff.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xelapondsstuff.wordpress.com/166/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xelapondsstuff.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xelapondsstuff.wordpress.com/166/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xelapondsstuff.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xelapondsstuff.wordpress.com/166/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xelapondsstuff.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xelapondsstuff.wordpress.com/166/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xelapondsstuff.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xelapondsstuff.wordpress.com/166/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xelapondsstuff.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xelapondsstuff.wordpress.com/166/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xelapondsstuff.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xelapondsstuff.wordpress.com/166/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xelapondsstuff.wordpress.com&amp;blog=3595014&amp;post=166&amp;subd=xelapondsstuff&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xelapondsstuff.wordpress.com/2008/08/26/getting-started-with-multi-touch-development-in-python-part-2/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6c32a4f18b03a2e3acdfbdce7becccde?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">xelapondsstuff</media:title>
		</media:content>
	</item>
		<item>
		<title>Getting Started with Multi-Touch Development in Python</title>
		<link>http://xelapondsstuff.wordpress.com/2008/08/25/getting-started-with-multi-touch-development-in-python/</link>
		<comments>http://xelapondsstuff.wordpress.com/2008/08/25/getting-started-with-multi-touch-development-in-python/#comments</comments>
		<pubDate>Mon, 25 Aug 2008 15:43:26 +0000</pubDate>
		<dc:creator>xelapondsstuff</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Multi-Touch]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://xelapondsstuff.wordpress.com/?p=153</guid>
		<description><![CDATA[I have noticed a lot of tutorials dealing with Multi-Touch in C++, C#, or AS3.  There seems be a lack of Python tutorials, but there is a growing number of people wanting to use Python for Multi-Touch apps.    I intend to change that with a set of tutorials to teach people how to write [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xelapondsstuff.wordpress.com&amp;blog=3595014&amp;post=153&amp;subd=xelapondsstuff&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have noticed a lot of tutorials dealing with Multi-Touch in C++, C#, or AS3.  There seems be a lack of Python tutorials, but there is a growing number of people wanting to use Python for Multi-Touch apps.    I intend to change that with a set of tutorials to teach people how to write Multi-Touch Apps in Python, starting with setting up the environment, all the way to writing a PhotoApp clone with Python-Lux(which is not released yet, and i&#8217;m not going to tell you when it will be released in any of these guides.  If thats all you came for, sorry I disappointed you).</p>
<p>These tutorials assume basic knowledge of Python, and at times may use some obscure feature of the Standard Library.  If you have any questions regarding something you don&#8217;t understand, or anything else about Python Development and such, feel free to email me at xelapond @ gmail . com, or PM me on nuigroup(username xelapond).  I also usually hang around IRC, #nuigroup, username xelapond.  I am happy to assist you with any problems you are having, and I would love feedback on how well this tutorial goes.</p>
<p><span id="more-153"></span></p>
<p>NOTE:  A lot of this is going to change soon with the release of Python-Lux.  Lux is a multimedia framework tuned for Multi-Touch Multi-Model interactions.  Once it is released you will not need to use the TouchPy callbacks for 90% of apps.  They are still nice to know though, for any application you don&#8217;t intend on using Python-Lux for.</p>
<p>NOTE 2:  WordPress appears to have killed the indentation on the code snippets.  In your code, follow standard Python tabbing and you should be fine.</p>
<p>This guide assume you have the following:</p>
<ul>
<li>Working TUIO Source(TUIO Sim, Touchlib, tbeta)</li>
<li>A working TouchPy installation.  Though there are many great TUIO parsers for Python out there, my favorite is TouchPy.  I think it is the most capable, and easiest to use in a client application.  It requires no knowledge of how TUIO works.</li>
<li>Python 2.5.2(I Haven&#8217;t tested it with any other version, let me know if it works)</li>
</ul>
<p>This guide was written from a GNU/Linux Standpoint, but most(if not all) if the code should work on Mac OS X or Windows.  I do not know if it is possible to install liblo(needed for TouchPy) on Windows, so if you managed to do it please let me know how:)</p>
<p>So, lets get started!</p>
<p>cd(or use a GUI if you like) into your TouchPy directory.  If you deleted it after you installed, no big deal, just check it out again.  If you do have one laying around, make sure it is svn revision 65 or later.  Copy(not move) the skeleton.py file to wherever you would like to keep your Multi-Touch programs.  I usually put programs I write as the result of a tutorial in ~/Programming/Practice.  But that is a matter of personal preference, it doesn&#8217;t matter where you put it.  Name it hellomt.py.</p>
<p>So, looking at this file, what do we see.</p>
<blockquote><p>#! /usr/bin/python -u<br />
&#8221;&#8217;<br />
This is a Skeleton file.  It provides a<br />
template to be used when writing a new<br />
TouchPy application.<br />
&#8221;&#8217;</p>
<p>from touch import *</p>
<p>class Observer(object):<br />
def __init__(self, subject):<br />
subject.push_handlers(self)</p>
<p>class touch_up(Observer):<br />
def TOUCH_UP(self,blobID, xpos, ypos):<br />
#Do something here</p>
<p>class touch_down(Observer):<br />
def TOUCH_DOWN(self,blobID):<br />
#Do something here</p>
<p>class touch_move(Observer):<br />
def TOUCH_MOVE(self,blobID):<br />
#Do something here</p>
<p>t = touchpy()<br />
tu = touch_up(t)<br />
td = touch_down(t)<br />
tm = touch_move(t)</p>
<p>try:<br />
while True:<br />
t.update()</p>
<p>except (KeyboardInterrupt, SystemExit):<br />
del t</p></blockquote>
<p>Some of this should already make sense to you, but I am going to explain it line by line anyway.</p>
<blockquote><p>from touch import *</p></blockquote>
<p>Imports the entire TouchPy library into the local namespace.</p>
<blockquote><p>class Observer(object):<br />
def __init__(self, subject):<br />
subject.push_handlers(self)</p></blockquote>
<p>You can safely ignore this for now.  We will get to it in later tutorials.</p>
<blockquote><p>class touch_up(Observer):<br />
def TOUCH_UP(self,blobID, xpos, ypos):<br />
#Do something here</p></blockquote>
<p>This is the code that will run when a blob is &#8220;upped&#8221;, or removed from the surface.</p>
<blockquote><p>class touch_down(Observer):<br />
def TOUCH_DOWN(self,blobID):<br />
#Do something here</p></blockquote>
<p>This is the code when a blob is &#8220;downed&#8221;, or placed on the surface.</p>
<blockquote><p>class touch_move(Observer):<br />
def TOUCH_MOVE(self,blobID):<br />
#Do something here</p></blockquote>
<p>This is the code that is run when a blob is moved.</p>
<blockquote><p>t = touchpy()<br />
tu = touch_up(t)<br />
td = touch_down(t)<br />
tm = touch_move(t)</p></blockquote>
<p>This code is there so that with one command(t.update()) you can dispatch any changes in blobs to the appropriate callbacks.  It will be explained in more detail in later parts of the tutorial.</p>
<blockquote><p>try:<br />
while True:<br />
t.update()</p>
<p>except (KeyboardInterrupt, SystemExit):<br />
del t</p></blockquote>
<p>This code pretty much says, &#8220;While the program is running, keep tracking and reporting blob data.  Otherwise, delete everything and exit&#8221;.  There are many different ways to do this same chunk of code, and in later parts we will change this to a gobject.timeout, and many other scheduling techniques.</p>
<p>Now that you [hopefully] understand at least some of the TouchPy front end, lets get coding!</p>
<p>In the touch_up callback, delete the comment and add:</p>
<blockquote><p>print &#8216;Something Left the Table!&#8217;</p></blockquote>
<p>in the touch_move callback, delete the comment and add:</p>
<blockquote><p>print &#8216;Something Moved on the Table!&#8217;</p></blockquote>
<p>and in the touch_down callback, delete the commend and add:</p>
<blockquote><p>print &#8216;Something was Placed on the Table!&#8217;</p></blockquote>
<p>Now open your TUIO source(Touchlib, TUIO Sim).  Open a terminal, cd into the directory with hellomt.py, and run:</p>
<blockquote><p>python ./hellomt.py</p></blockquote>
<p>Then touch the surface.  If all goes well it should display each message when each event happens.  If IPv6 is enabled on your liblo installation, then it may take a few seconds to start up.  Give it at least 15 seconds before deciding it doesn&#8217;t work.</p>
<p>Assuming all went well, now you have written your first Multi-Touch application in Python!  Its not terribly useful, but its a great basis for more useful apps.  In the next tutorial(probably going to be posted tomorrow), we will get into blobIDs and coordinates of where touch events occur, then write a program using Clutter to draw circles on each point.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/xelapondsstuff.wordpress.com/153/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/xelapondsstuff.wordpress.com/153/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xelapondsstuff.wordpress.com/153/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xelapondsstuff.wordpress.com/153/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xelapondsstuff.wordpress.com/153/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xelapondsstuff.wordpress.com/153/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xelapondsstuff.wordpress.com/153/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xelapondsstuff.wordpress.com/153/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xelapondsstuff.wordpress.com/153/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xelapondsstuff.wordpress.com/153/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xelapondsstuff.wordpress.com/153/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xelapondsstuff.wordpress.com/153/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xelapondsstuff.wordpress.com/153/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xelapondsstuff.wordpress.com/153/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xelapondsstuff.wordpress.com/153/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xelapondsstuff.wordpress.com/153/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xelapondsstuff.wordpress.com&amp;blog=3595014&amp;post=153&amp;subd=xelapondsstuff&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xelapondsstuff.wordpress.com/2008/08/25/getting-started-with-multi-touch-development-in-python/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6c32a4f18b03a2e3acdfbdce7becccde?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">xelapondsstuff</media:title>
		</media:content>
	</item>
		<item>
		<title>I got my Aixiz Lasers working!</title>
		<link>http://xelapondsstuff.wordpress.com/2008/08/24/i-got-my-aixiz-lasers-working/</link>
		<comments>http://xelapondsstuff.wordpress.com/2008/08/24/i-got-my-aixiz-lasers-working/#comments</comments>
		<pubDate>Sun, 24 Aug 2008 03:48:10 +0000</pubDate>
		<dc:creator>xelapondsstuff</dc:creator>
				<category><![CDATA[DIY]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Multi-Touch]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://xelapondsstuff.wordpress.com/?p=137</guid>
		<description><![CDATA[For those of you that have been keeping up with my blog, you would probably know that I ordered some Lasers from Aixiz, but have not gotten them to work.  Well, I was about to send them back, when I noticed a NUIgroup Member names AixiZ.  He said there was some misinformation about the voltages, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xelapondsstuff.wordpress.com&amp;blog=3595014&amp;post=137&amp;subd=xelapondsstuff&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>For those of you that have been keeping up with my blog, you would probably know that I ordered some Lasers from Aixiz, but have not gotten them to work.  Well, I was about to send them back, when I noticed a NUIgroup Member names AixiZ.  He said there was some misinformation about the voltages, and said they were 5v devices and not 3.2v.  Well, I found a 5v wall wart, cut off the end, hooked them up to a breadboard, and they work!  I am going to try and get them lined up so my setup will actually work, so in the meantime, some pics:</p>
<p>There are the 10mW 780nm Lasers from Aixiz.</p>

<a href='http://xelapondsstuff.wordpress.com/2008/08/24/i-got-my-aixiz-lasers-working/img_4647-1/' title='img_4647-1'><img data-attachment-id='144' data-orig-size='400,300' data-liked='0'width="150" height="112" src="http://xelapondsstuff.files.wordpress.com/2008/08/img_4647-1.jpg?w=150&#038;h=112" class="attachment-thumbnail" alt="Laser Dot" title="img_4647-1" /></a>
<a href='http://xelapondsstuff.wordpress.com/2008/08/24/i-got-my-aixiz-lasers-working/img_4648-1/' title='img_4648-1'><img data-attachment-id='145' data-orig-size='400,300' data-liked='0'width="150" height="112" src="http://xelapondsstuff.files.wordpress.com/2008/08/img_4648-1.jpg?w=150&#038;h=112" class="attachment-thumbnail" alt="120 Degree Laser Line" title="img_4648-1" /></a>
<a href='http://xelapondsstuff.wordpress.com/2008/08/24/i-got-my-aixiz-lasers-working/img_4658-1/' title='img_4658-1'><img data-attachment-id='146' data-orig-size='400,300' data-liked='0'width="150" height="112" src="http://xelapondsstuff.files.wordpress.com/2008/08/img_4658-1.jpg?w=150&#038;h=112" class="attachment-thumbnail" alt="Laser without Line Lens" title="img_4658-1" /></a>
<a href='http://xelapondsstuff.wordpress.com/2008/08/24/i-got-my-aixiz-lasers-working/img_4654-1/' title='img_4654-1'><img data-attachment-id='147' data-orig-size='300,400' data-liked='0'width="112" height="150" src="http://xelapondsstuff.files.wordpress.com/2008/08/img_4654-1.jpg?w=112&#038;h=150" class="attachment-thumbnail" alt="Laser without Line Lens" title="img_4654-1" /></a>
<a href='http://xelapondsstuff.wordpress.com/2008/08/24/i-got-my-aixiz-lasers-working/img_4659-1/' title='img_4659-1'><img data-attachment-id='148' data-orig-size='400,300' data-liked='0'width="150" height="112" src="http://xelapondsstuff.files.wordpress.com/2008/08/img_4659-1.jpg?w=150&#038;h=112" class="attachment-thumbnail" alt="Laser with 120D Line Lens" title="img_4659-1" /></a>

<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/xelapondsstuff.wordpress.com/137/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/xelapondsstuff.wordpress.com/137/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xelapondsstuff.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xelapondsstuff.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xelapondsstuff.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xelapondsstuff.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xelapondsstuff.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xelapondsstuff.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xelapondsstuff.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xelapondsstuff.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xelapondsstuff.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xelapondsstuff.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xelapondsstuff.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xelapondsstuff.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xelapondsstuff.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xelapondsstuff.wordpress.com/137/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xelapondsstuff.wordpress.com&amp;blog=3595014&amp;post=137&amp;subd=xelapondsstuff&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xelapondsstuff.wordpress.com/2008/08/24/i-got-my-aixiz-lasers-working/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6c32a4f18b03a2e3acdfbdce7becccde?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">xelapondsstuff</media:title>
		</media:content>

		<media:content url="http://xelapondsstuff.files.wordpress.com/2008/08/img_4647-1.jpg?w=150" medium="image">
			<media:title type="html">img_4647-1</media:title>
		</media:content>

		<media:content url="http://xelapondsstuff.files.wordpress.com/2008/08/img_4648-1.jpg?w=150" medium="image">
			<media:title type="html">img_4648-1</media:title>
		</media:content>

		<media:content url="http://xelapondsstuff.files.wordpress.com/2008/08/img_4658-1.jpg?w=150" medium="image">
			<media:title type="html">img_4658-1</media:title>
		</media:content>

		<media:content url="http://xelapondsstuff.files.wordpress.com/2008/08/img_4654-1.jpg?w=112" medium="image">
			<media:title type="html">img_4654-1</media:title>
		</media:content>

		<media:content url="http://xelapondsstuff.files.wordpress.com/2008/08/img_4659-1.jpg?w=150" medium="image">
			<media:title type="html">img_4659-1</media:title>
		</media:content>
	</item>
		<item>
		<title>I got a projector(+ Image warping)!</title>
		<link>http://xelapondsstuff.wordpress.com/2008/08/21/i-got-a-projector-image-warping/</link>
		<comments>http://xelapondsstuff.wordpress.com/2008/08/21/i-got-a-projector-image-warping/#comments</comments>
		<pubDate>Thu, 21 Aug 2008 04:41:44 +0000</pubDate>
		<dc:creator>xelapondsstuff</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Multi-Touch]]></category>

		<guid isPermaLink="false">http://xelapondsstuff.wordpress.com/?p=134</guid>
		<description><![CDATA[I was searching around Craigslist for a broken projector(read: working projector with dead bulb) so I could hack a different bulb into it, and not pay $400 for a $6 bulb.  I found one, a Proxima DP6850.  Its a really nice projector, 1024&#215;768(1280&#215;1024 max), Digital Keystoning and Zoom, two RGB inputs, S-Video, and built in [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xelapondsstuff.wordpress.com&amp;blog=3595014&amp;post=134&amp;subd=xelapondsstuff&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I was searching around Craigslist for a broken projector(read: working projector with dead bulb) so I could hack a different bulb into it, and not pay $400 for a $6 bulb.  I found one, a Proxima DP6850.  Its a really nice projector, 1024&#215;768(1280&#215;1024 max), Digital Keystoning and Zoom, two RGB inputs, S-Video, and built in speakers.  The only places it lacks are brightness(1500 lumens) and Bulb Life(1500 Hours).  Bulb life didn&#8217;t really matter to me, and I figured it would probably be brighter if I go sticking a huge metal halide bulb in there.  It is circa-2000, and retailed for $8500.  The Craigslist seller wanted $75 for it, so I figured I really had nothing to lose, and if it didn&#8217;t work at all at least I would end up with a lot of good lenses and LCD filters.</p>
<p>I bought it this morning, only to arrive home and find out the bulb works!  I don&#8217;t know how much longer it will last, so I am going to wait until I am ready to mount it in my table to play with it(excluding the image warping).</p>
<p>A while ago I saw that openFrameworks demo where he uses openGl shaders to warp a playing video onto a white board.  I could not find the code anywhere, so I used &#8220;The GIMP&#8221; to Perspective Transform an image.  I achieved the same effect, and was able to get a picture of the earth onto a piece of paper.  Video below:<br />
<span style="text-align:center; display: block;"><a href="http://xelapondsstuff.wordpress.com/2008/08/21/i-got-a-projector-image-warping/"><img src="http://img.youtube.com/vi/Hg-uxFe36GM/2.jpg" alt="" /></a></span></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/xelapondsstuff.wordpress.com/134/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/xelapondsstuff.wordpress.com/134/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xelapondsstuff.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xelapondsstuff.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xelapondsstuff.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xelapondsstuff.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xelapondsstuff.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xelapondsstuff.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xelapondsstuff.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xelapondsstuff.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xelapondsstuff.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xelapondsstuff.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xelapondsstuff.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xelapondsstuff.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xelapondsstuff.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xelapondsstuff.wordpress.com/134/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xelapondsstuff.wordpress.com&amp;blog=3595014&amp;post=134&amp;subd=xelapondsstuff&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xelapondsstuff.wordpress.com/2008/08/21/i-got-a-projector-image-warping/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6c32a4f18b03a2e3acdfbdce7becccde?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">xelapondsstuff</media:title>
		</media:content>
	</item>
		<item>
		<title>New video for Stack Test</title>
		<link>http://xelapondsstuff.wordpress.com/2008/08/07/new-video-for-stack-test/</link>
		<comments>http://xelapondsstuff.wordpress.com/2008/08/07/new-video-for-stack-test/#comments</comments>
		<pubDate>Thu, 07 Aug 2008 06:03:07 +0000</pubDate>
		<dc:creator>xelapondsstuff</dc:creator>
				<category><![CDATA[DIY]]></category>
		<category><![CDATA[Multi-Touch]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://xelapondsstuff.wordpress.com/?p=132</guid>
		<description><![CDATA[I noticed some people were disappointed with the poor speed my last video depicted, so I made a new one. This is take with my Canon digital camera, so there isn&#8217;t any Desktop Recording overhead. This demo is with 30 and 100 items, respectively.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xelapondsstuff.wordpress.com&amp;blog=3595014&amp;post=132&amp;subd=xelapondsstuff&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I noticed some people were disappointed with the poor speed my last video depicted, so I made a new one.  This is take with my Canon digital camera, so there isn&#8217;t any Desktop Recording overhead.  This demo is with 30 and 100 items, respectively.<br />
<span style="text-align:center; display: block;"><a href="http://xelapondsstuff.wordpress.com/2008/08/07/new-video-for-stack-test/"><img src="http://img.youtube.com/vi/-ffxaP3APeE/2.jpg" alt="" /></a></span></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/xelapondsstuff.wordpress.com/132/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/xelapondsstuff.wordpress.com/132/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xelapondsstuff.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xelapondsstuff.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xelapondsstuff.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xelapondsstuff.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xelapondsstuff.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xelapondsstuff.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xelapondsstuff.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xelapondsstuff.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xelapondsstuff.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xelapondsstuff.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xelapondsstuff.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xelapondsstuff.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xelapondsstuff.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xelapondsstuff.wordpress.com/132/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xelapondsstuff.wordpress.com&amp;blog=3595014&amp;post=132&amp;subd=xelapondsstuff&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xelapondsstuff.wordpress.com/2008/08/07/new-video-for-stack-test/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6c32a4f18b03a2e3acdfbdce7becccde?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">xelapondsstuff</media:title>
		</media:content>
	</item>
		<item>
		<title>New idea for Desktop Replacement</title>
		<link>http://xelapondsstuff.wordpress.com/2008/08/06/new-idea-for-desktop-replacement/</link>
		<comments>http://xelapondsstuff.wordpress.com/2008/08/06/new-idea-for-desktop-replacement/#comments</comments>
		<pubDate>Wed, 06 Aug 2008 05:12:05 +0000</pubDate>
		<dc:creator>xelapondsstuff</dc:creator>
				<category><![CDATA[DIY]]></category>
		<category><![CDATA[Multi-Touch]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://xelapondsstuff.wordpress.com/?p=125</guid>
		<description><![CDATA[I(and a few others) have been thinking about what to do with the desktop in multi-touch tables.  It is not optimal, because of small buttons, requirement for a second button on the mouse, and has a sense of direction(there is a defined up and down).  I was thinking, what if we threw all the stuff [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xelapondsstuff.wordpress.com&amp;blog=3595014&amp;post=125&amp;subd=xelapondsstuff&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I(and a few others) have been thinking about what to do with the desktop in multi-touch tables.  It is not optimal, because of small buttons, requirement for a second button on the mouse, and has a sense of direction(there is a defined up and down).  I was thinking, what if we threw all the stuff you would normal have on your[Linux] desktop on a big ZUI plane.  That way, objects(Text documents, code, pictures) would represent themselves as their content, so pictures would be the pictures they are, and you could manipulate them just like they were in the PhotoApp, rotating and zooming with Gestures.  It would get crowded, so I though if you could just circle a bunch if they would stack up, you could have a pretty cool interface.  A demo of the stacking is below, its entirely random.  It seams to work pretty well, so I am going to take this further with real pictures, apps, widgets, and some other sorting/searching methods(grid, line, flow).  Here is a discussion on NUIgroup about <a href="http://nuigroup.com/forums/viewthread/2538/">WIMP and how it doesn&#8217;t work for multi-touch</a>.</p>
<p>Also, I&#8217;m sorry for not commenting the code.  If you have any questions about the code just leave a question in the comments, and Ill probably get back to you within a day.<br />
At the moment the code is _really_ messy, but here is is for anyone that wants it.  I will be cleaning it up later, this is just something I hacked up in a few minutes to see if it would work.  You will need Python, PyGame and Rabbyt if you want to run it.  <a href="http://pastebin.com/f1608bcbb">Here is the code link.</a></p>
<p>NOTE:  Without the desktop record app(gtk-recordmydesktop) there was zero lag, even on my crappy graphics card(NVidia 7300) and 100 items.<br />
<span style="text-align:center; display: block;"><a href="http://xelapondsstuff.wordpress.com/2008/08/06/new-idea-for-desktop-replacement/"><img src="http://img.youtube.com/vi/xpDJisVEOeQ/2.jpg" alt="" /></a></span></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/xelapondsstuff.wordpress.com/125/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/xelapondsstuff.wordpress.com/125/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xelapondsstuff.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xelapondsstuff.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xelapondsstuff.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xelapondsstuff.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xelapondsstuff.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xelapondsstuff.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xelapondsstuff.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xelapondsstuff.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xelapondsstuff.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xelapondsstuff.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xelapondsstuff.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xelapondsstuff.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xelapondsstuff.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xelapondsstuff.wordpress.com/125/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xelapondsstuff.wordpress.com&amp;blog=3595014&amp;post=125&amp;subd=xelapondsstuff&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xelapondsstuff.wordpress.com/2008/08/06/new-idea-for-desktop-replacement/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6c32a4f18b03a2e3acdfbdce7becccde?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">xelapondsstuff</media:title>
		</media:content>
	</item>
	</channel>
</rss>
