Boston Python workshop/Saturday/ColorWall: Difference between revisions

no edit summary
imported>Jesstess
No edit summary
imported>Jesstess
No edit summary
Line 23:
<pre>python run.py -a</pre>
 
You should see a window pop up and start cycling through colorful effects. If you don't, let a staff member know so you can debug this together.
 
== Project steps ==
Line 38:
* SaturationTest
* ValueTest
 
In all of these effects, a tuple <code>hsv</code> containing the hue, saturation, and value describing a color are passed to <code>self.wall.set_pixel</code> to change the color of a single pixel on the wall.
 
What are the differences between these tests? Given these difference and how they are expressed visually, how does varying hue, saturation, or value change a color?
 
<b>Check your understanding</b>: what range of values can hue, saturation, or value have?
 
 
=== 2. Examine <code>Effect</code> and the interface its subclasses provide ===
 
All of the effects inherit from the <code>Effect</code> class. Examine this class and its <code>__init__</code> and <code>run</code> methods.
 
What is the purpose of the <code>__init__</code> method?
 
What is the purpose of the <code>run</code> method?
 
Open up <code>run.py</code> and look at this chunk of code at the bottom of the file:
 
<pre>
for effect in effects_to_run:
new_effect = effect(wall)
print new_effect.__class__.__name__
new_effect.run()
</pre>
 
<code>effects.py</code> exports and <code>Effects</code> list at the bottom of the file. <code>run.py</code> goes through every effect in that list, creates a new instance of the effect, and invokes its <code>run</code> method.
 
<b>Check your understanding</b>: what would happen if you added an effect to the <code>Effects</code> list that didn't implement a <code>run</code> method?
 
 
 
=== 3. Examine the nested <code>for</code> loop in <code>SolidColorTest</code> ===
 
<pre>for x in range(self.wall.width):
for y in range(self.wall.height):
self.wall.set_pixel(x, y, hsv)</pre>
 
 
 
Anonymous user