Class 41 — April 26
Taking care of business
Take care of our world — For others need to follow — The path that you make
Look both ways
If you have not already done so, please fill out survey
Agenda
- Complete the 15 Puzzle
- Resolve any outstanding issues.
- Practice
Notices
- TA-lead review in Olsson 120 on Wednesday starting at 2 PM.
Links
- Test 1 artifacts are available
- Test 2 artifacts are available
Module reflect.py
- The module provides two functions
loc()
, andcreate_reflection()
. When run the module does a single test reflection
- Function
create_reflection( original )
is already implemented. The function makes use ofloc()
in returning a new image whose left side is that oforiginal
and whose right is a reflection of the left side.
- Function
loc( img, spot )
- If image coordinate
spot
lies on the lefthand side ofimg
, the function returnsspot
; otherwise, the function returns the reflection location of spot with respect to the vertical center axis ofimg
.
Module shift.py
- The module provides two functions
legal()
,offset()
, andcreate_color_shift()
. When run the module does a single test image color shifting.
Color shift with x = 25, y = -50, and y = 75 |
- Function
legal( v )
- Returns an integer based on integer
v
. Ifv
is negative, the function returns 0. If insteadv
exceeds 255, the function returns 255. Otherwise, the function returnsv
. Thus, the return value is always a legal value for an individual RGB level.
- Function
offset( pixel, x, y, z )
- Returns the new color
(legal(nr), legal(ng), legal(nb ))
, wherenr
,ng
, andnb
are the values gotten by decrementing the RGB values of pixel respectively by the amountsx
,y
, andz
.
- Function
create_color_shift( original, x, y, z )
- Returns a new image that is based on
original
, where a pixel in the new image is obtained by usingoffset()
on the corresponding pixel inoriginal
with offset amountsx
,y
, andz
.