Anonymous user
Boston Python Workshop/Saturday/ColorWall: Difference between revisions
Boston Python Workshop/Saturday/ColorWall (view source)
Revision as of 18:27, 13 May 2011
, 13 years agono edit summary
imported>Jesstess (→Layout) |
imported>Jesstess No edit summary |
||
Line 1:
Program graphical effects for a ColorWall using the Tkinter GUI toolkit. See the ColorWall in action [http://vimeo.com/16522975 here].
==Setup==
See the [http://openhatch.org/wiki/Boston_Python_workshop_2/Friday_setup#Goal_.236:_get_dependencies_installed_for_the_Saturday_projects| Friday setup instructions].
==Goals==
* Have fun experiment with and creating graphical effects.
* Practice using functions and classes.
* Get experience with graphics programming using the Tkinter GUI toolkit.
==Suggested exercises==
<ul>
<li>
Find and change the colors used in the <code>Checkerboards</code> effect, and re-run the effect:
<pre>
python run.py Checkerboards
</pre>
Then change the line
<pre>
if (x + y + i) % 2 == 0:
</pre>
to
<pre>
if (x + y + i) % 3 == 0:
</pre>
re-run the effect, and see what changed.
</li>
<li>
Find and change the color of the columns in the <code>Matrix</code> effect, and re-run the effect:
<pre>
python run.py Matrix
</pre>
Each column that we see on the wall corresponds to a <code>Column</code> object. Add some randomness to the color used by each column (the variable whose value you changed above) using the <code>random.random</code> function, re-run the effect, and see what happens.
</li>
<li>
Walk through <code>Twinkle</code>. Find explanations of the <code>random.randint</code> and <code>random.uniform</code> functions in the online documentation at
http://docs.python.org/library/random.html.
Experiment with these functions at a Python prompt:
<pre>
import random
random.randint(0, 1)
random.randint(0, 5)
random.uniform(-1, 1)
</pre>
Then experiment with the numbers that make up the hue and re-run the effect:
<pre>
python run.py Twinkle
</pre>
</li>
<li>
Write your own effects!
</li>
</ul>
[[Boston Python workshop 2/Saturday projects|« Back to the Saturday project page]]
|