Boston Python workshop/Saturday/ColorWall: Difference between revisions

no edit summary
imported>Jesstess
imported>Jesstess
No edit summary
Line 44:
 
<b>Check your understanding</b>: what saturation and value would you guess firetruck red have?
 
 
=== 2. Examine <code>Effect</code> and the interface its subclasses provide ===
Line 64 ⟶ 65:
<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? (Try it!)
 
 
Line 74 ⟶ 75:
self.wall.set_pixel(x, y, hsv)</pre>
 
This code loops over every pixel in the ColorWall, setting the pixel to a particular <code>hsv</code> value. After that <code>for</code> loop is over, <code>self.wall.draw()</code> updates the display.
 
<b>Check your understanding</b>: what would happen if you moved the <code>self.wall.draw()</code> to inside the inner <code>for</code> loop, just under <code>self.wall.set_pixel(x, y, hsv)</code> in <code>SaturationTest</code>? (Try it!)
 
<b>Tip</b>: you can run individual tests by passing their names as command line arguments to <code>run.py</code>. For example, if you only wanted to run <code>SaturationTest</code>, you could:
 
<pre>python run.py SaturationTest</pre>
 
 
Anonymous user