Assignment 27 — coloring within the lines

Due Thursday April 26


Module crayon.py



Flooding visualization


Function flood( drawing, spot, c, bg=(255,255,255) )

 If the spot on the drawing is not empty

  return

 Color the spot using c

 Create a to-do list with spot as its element

 While the to-do list is not empty

  Pop an element from the to-do list and assign it to v

  If v’s left is empty, paint it and add to to-do list

  If v’s right is empty, paint it and add to to-do list

  If v’s above is empty, paint it and add to to-do list

  If v’s below is empty, paint it and add to to-do list


Function sweep( drawing, bg=(255,255,255) )


Coloring examples


usa         va


usa         usa


uva logo         uva logo


trex         trex


mandala         mandala


flower         flower


girl and dog         girl and dog

 



Warning: fopen(/l/cs1112/public_html/defs/htm/181-trailer): Failed to open stream: No such file or directory in /l/cs1112/public_html/defs/php/read.php on line 5
Unable to open file!