Layering
Create a new sketch file. Name it part_4. Copy and paste your code from part 3 above as a
starting point, and use the following code as a guide. Follow the instructions in the TODOs that I've made in comments. There are a total of 5 TODOs. Parts of this are probably confusing since we haven't talked about setup()
and draw()
yet. But this will lead in to the main topic for next week:
# TODO 1: Put all your variable assignments here.
# You should have no indentation here - i.e. no spaces
# at the beginning of the line
def setup():
# size() goes inside setup() here. Like this:
size(600,600)
# Optional: If your sketch from the previous part used background(),
# put that here. It should have 4 spaces of indentation
def draw():
# TODO 2: Put each of your variables here on their own line
# and mark each as 'global'. (I will explain what this
# means next week.) And assign each one a random value
# using a low, high range that works reasonably within
# your composition. You should have 4 spaces of indendation.
# For example:
global treeHeight
treeHeight = random(50,250)
# Replace the global variable that I wrote as an example above with your own.
# TODO 3: Now put all your draw code here (ie, the code
# that uses those variables). All of the code here should
# have 4 spaces of indentation.
# NOTE: If you are using background(), remove it for now, or move
# it into the setup area, above.
# TODO 4: Go through your code and for every place you are setting
# a color, add some transparency. For example, if your code
# has this:
# fill(255,0,0)
# modify it to something like this:
# fill(255,0,0,10)
# TODO 5: run your sketch and see what happens!
# The idea here is that if you do the above, you should hopefully
# get something that looks like the Idris Khan image compositions.
# Do you? This is a lead-in to the topic for next week, and I will
# explain more about it then.