# CS111 Lab02 # Spring 2017 # Layers and Transformations # Written by: CS111 staff from cs1graphics import * from cs1graphicsHelper import * from graphicsState import * # treat is a Layer containing a single scoop ice cream cone # centered at (0,0) treat = Layer() scoop = Circle(50,Point(0,0)) # centered at (0,0) scoop.setFillColor('blue') scoop.setBorderColor('blue') cone = Polygon(Point(-50,0),Point(50,0),Point(0,180)) cone.setFillColor('tan') treat.add(cone) treat.add(scoop) # width height bkgd color title yum = Canvas(900,700,'ivory','i scream u scream') #dessert = treat.clone() # making a copy of the treat layer #yum.add(dessert) #dessert.move(450,350) # Testing out the cs1graphics helper functions #drawGrid(yum,100) #drawReferencePoints(yum) #markClicks(yum) # doubleTreat is a Layer containing a double scoop ice cream cone doubleTreat = Layer() single = treat.clone() doubleTreat.add(single) # Note how the extrascoop is added with the treat layer centered at (0,0), # then the entire doubleTreat layer is moved later as needed extraScoop = Circle(50,Point(0,-50)) # centered at (0,-50) extraScoop.setFillColor('pink') extraScoop.setBorderColor('pink') doubleTreat.add(extraScoop) # Testing out the doubleTreat layer #yum.add(doubleTreat) #doubleTreat.move(450,350) #drawReferencePoints(yum) # ------- CS111 Lab 02 Part 2 starts here -------- # TASK 1: Pinwheel # A pinwheel design of single cones (scoop in center first) topCone = treat.clone() rightCone = treat.clone() leftCone = treat.clone() bottomCone = treat.clone() pinwheel = Layer() pinwheel.add(topCone) pinwheel.add(rightCone) pinwheel.add(leftCone) pinwheel.add(bottomCone) rightCone.rotate(270) leftCone.rotate(90) bottomCone.rotate(180) # see the pinwheel centered in the canvas #yum.add(pinwheel) #pinwheel.moveTo(450,350) #drawGrid(yum,100) #drawReferencePoints(yum) # TASK 2 # A firework yum of single cones (scoops outward, cones inward) top = treat.clone() right = treat.clone() left = treat.clone() bottom = treat.clone() firework = Layer() firework.add(top) firework.add(right) firework.add(left) firework.add(bottom) right.rotate(90) right.moveTo(180,0) left.rotate(270) left.moveTo(-180,0) bottom.rotate(180) bottom.moveTo(0,180) top.moveTo(0,-180) # View the firework centered in the canvas #yum.add(firework) #firework.moveTo(450,350) #drawGrid(yum,100) #drawReferencePoints(yum) # Task 3: The Wheel # Building upon the firework, make a wheel wheel = Layer() spokes1 = firework.clone() spokes2 = firework.clone() spokes2.rotate(45) wheel.add(spokes1) wheel.add(spokes2) #yum.add(wheel) #wheel.moveTo(450,350) #drawGrid(yum,100) #drawReferencePoints(yum) # Task 4: That 70s design # Combine wheel and pinwheel together in one layer disco = Layer() center = pinwheel.clone() center.scale(1.25) corner = wheel.clone() corner.scale(0.40) c1 = corner.clone() c2 = corner.clone() c3 = corner.clone() c4 = corner.clone() c1.moveTo(150,150) c2.moveTo(-150,150) c3.moveTo(-150,-150) c4.moveTo(150,-150) disco.add(center) disco.add(c1) disco.add(c2) disco.add(c3) disco.add(c4) #yum.add(disco) #disco.moveTo(450,350) #drawGrid(yum,100) #drawReferencePoints(yum) # Task 5: Collage of 70s desgn + double scoop artwork = Layer() leftside = disco.clone() leftside.rotate(45) rightside = doubleTreat.clone() rightside.scale(1.5) artwork.add(leftside) artwork.add(rightside) rightside.moveTo(450,100) #yum.add(artwork) #artwork.moveTo(350,350) #drawReferencePoints(yum) #drawGrid(yum,100)