Boston Python Workshop 4/ColorWall: Difference between revisions

From OpenHatch wiki
Content added Content deleted
imported>Jesstess
(Created page with '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/wi…')
 
imported>Brittag
(removing spam)
 
(3 intermediate revisions by 2 users not shown)
Line 4: Line 4:
See the [http://openhatch.org/wiki/Boston_Python_Workshop_4/Friday Friday setup instructions].
See the [http://openhatch.org/wiki/Boston_Python_Workshop_4/Friday Friday setup instructions].


==Goals==
==Handout==


[[Boston_Python_Workshop_4/ColorWall_handout| ColorWall handout]]: goals and cheat sheet.
* Have fun experiment with and creating graphical effects.
* Practice using functions and classes.
* Get experience with graphics programming using the Tkinter GUI toolkit.


<hr />
==Suggested exercises==


[[Boston Python Workshop 4/Saturday projects|&laquo; Back to the Saturday Projects page]]
<ul>
<li>
Find and change the colors used in the <code>Checkerboards</code> effect, and re-run the effect:


[[Boston Python Workshop 4|&laquo; to the Workshop home page]]
<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>

==Some Useful Links==

If you choose to use HSV colors you define instead of the dictionary, you may find some of the following useful:
* [http://www.yafla.com/yaflaColor/ColorRGBHSL.aspx A graphical HSV color picking website]
* [http://en.wikipedia.org/wiki/HSL_and_HSV HSV on Wikipedia]
* [http://docs.python.org/library/random.html Python random library]
* [http://docs.python.org/library/time.html Python time library]

[[Boston Python Workshop 4/Saturday projects|&laquo; Back to the Saturday project page]]

Latest revision as of 06:28, 18 August 2013

Program graphical effects for a ColorWall using the Tkinter GUI toolkit. See the ColorWall in action here.

Setup

See the Friday setup instructions.

Handout

ColorWall handout: goals and cheat sheet.


« Back to the Saturday Projects page

« to the Workshop home page