def turtle_fun(): """ Constructs a TurtleWindow, constructs a classic SimpleTurtle and asks it to do some things, and waits for the user to click anywhere in the window to close it. """ window = rg.TurtleWindow() alan = rg.SimpleTurtle() alan.pen = rg.Pen('blue', 30) alan.paint_bucket = rg.PaintBucket('yellow') alan.backward(3 * (47 + 16)) alan.begin_fill() alan.draw_circle(25) alan.end_fill() alan.forward(200) window.close_on_mouse_click()
def turtle4(): ajax = rg.SimpleTurtle('turtle') ajax.pen = rg.Pen('Blue2', 6) ajax.paint_bucket = rg.PaintBucket('grey22') ajax.right(90) ajax.pen_up() ajax.forward(180) ajax.left(180) ajax.pen_down() ajax.begin_fill() ajax.draw_regular_polygon(10, 50) ajax.end_fill() ajax.pen_up() ajax.right(90) ajax.forward(200) ajax.left(90) ajax.pen_down() ajax.begin_fill() ajax.draw_regular_polygon(10, 50) ajax.end_fill()
def turtle3(): """ Constructs a classic SimpleTurtle and asks it to draw a "ball on pole" shape. """ # ------------------------------------------------------------------------- # Students: # Do NOT touch this function - it has no TO-DO in it. # ------------------------------------------------------------------------- maja = rg.SimpleTurtle() maja.pen = rg.Pen('green', 10) maja.paint_bucket = rg.PaintBucket('black') maja.speed = 15 maja.right(135) maja.forward(300) maja.begin_fill() maja.draw_circle(50) maja.end_fill()
def turtle3(color="green", thickness=5): """ Constructs a classic SimpleTurtle and asks it to draw a "ball on pole" shape, using a Pen with the give color and thickness. """ # ------------------------------------------------------------------------- # Students: # Do NOT touch this function - it has no TO-DO in it. # ------------------------------------------------------------------------- maja = rg.SimpleTurtle() maja.pen = rg.Pen(color, thickness) maja.paint_bucket = rg.PaintBucket('black') maja.speed = 15 maja.right(135) maja.forward(300) maja.begin_fill() maja.draw_circle(50) maja.end_fill()
def turtle4(): """ Constructs a default SimpleTurtle. Makes a group of circles. """ blob = rg.SimpleTurtle('triangle') blob.pen = rg.Pen('green', 7) blob.pen_up() blob.forward(100) blob.pen_down() blob.paint_bucket = rg.PaintBucket('violet') blob.begin_fill() blob.draw_circle(50) blob.draw_circle(60) blob.draw_circle(70) blob.draw_circle(80) blob.draw_circle(90) blob.draw_circle(100) blob.end_fill()
def turtle4(): """ Constructs a turtle SimpleTurtle. Makes the turtle move turn and move backwards and then construct a square. """ zack = rg.SimpleTurtle('turtle') zack.speed = 6 zack.pen = rg.Pen('lime green', 4) zack.paint_bucket = rg.PaintBucket('salmon') zack.left(45) zack.pen_up() zack.backward(400) zack.right(45) zack.pen_down() zack.begin_fill() zack.draw_square(300) zack.end_fill() zack.left(45) zack.pen_up() zack.forward(200)
def turtle5(): """ Constructs two triangle SimpleTurtles. The first turtle moves in a zig zag pattern, while the second draws a triangle. """ katie = rg.SimpleTurtle('triangle') luke = rg.SimpleTurtle('triangle') katie.pen = rg.Pen('hot pink', 8) luke.pen = rg.Pen('orange', 15) katie.speed = 5 luke.speed = 10 luke.paint_bucket = rg.PaintBucket('yellow') katie.right(45) katie.pen_up() katie.backward(500) katie.pen_down() katie.left(45) katie.forward(100) katie.right(90) katie.forward(100) katie.left(90) katie.forward(100) katie.right(90) katie.forward(100) katie.left(90) katie.forward(100) katie.right(90) katie.forward(100) katie.left(90) katie.forward(100) luke.left(90) luke.backward(300) luke.begin_fill() luke.draw_regular_polygon(3, 200) luke.end_fill()
def turtle_fun(): """ Constructs a TurtleWindow, constructs a classic SimpleTurtle and asks it to do some things, and waits for the user to click anywhere in the window to close it. """ window = rg.TurtleWindow() alan = rg.SimpleTurtle() alan.pen = rg.Pen('blue', 30) alan.paint_bucket = rg.PaintBucket('yellow') alan.backward(3 * (47 + 16)) alan.begin_fill() alan.speed = 30 for k in range(0, 628, 1): alan.go_to(rg.Point(100 * math.cos(k / 100), 100 * math.sin(k / 100))) alan.end_fill() alan.forward(200) window.close_on_mouse_click()
print("The sine of PI is", y) def turtle_fun(): """ Constructs a TurtleWindow, constructs a classic SimpleTurtle and asks it to do some things, and waits for the user to click anywhere in the window to close it. """ window = rg.TurtleWindow() alan = rg.SimpleTurtle() alan.pen = rg.Pen('blue', 30) alan.paint_bucket = rg.PaintBucket('yellow') alan.backward(3 * (47 + 16)) alan.begin_fill() alan.draw_circle(25) alan.end_fill() alan.forward(200) window.close_on_mouse_click() # ----------------------------------------------------------------------------- # Calls main to start the ball rolling. # ----------------------------------------------------------------------------- main()
# Below this TO DO comment construct another SimpleTurtle object, # naming it whatever you want. # Names cannot have spaces or special characters, but they can have # digits and underscores like this_1_has (get it?). # # After you construct a SimpleTurtle, add a few more lines that # make YOUR SimpleTurtle move around a bit. # # ** Nothing fancy is required. ** # ** A SUBSEQUENT exercise will let you show your creativity. ** # # As always, test by running the module. # ######################################################################## toytle = rg.SimpleTurtle('turtle') toytle.paint_bucket = rg.PaintBucket('purple') toytle.begin_fill() toytle.draw_regular_polygon(10, 20) toytle.end_fill() ######################################################################## # # DONE: 5. # Run one more time to be sure that all is still OK. # Ensure that no blue bars on the scrollbar-thing to the right remain. # # Then COMMIT and Push your work using the VCS menu option. # # Reminder of those steps... # COMMIT your work by selecting VCS from the menu bar, then select Commit Changes
import rosegraphics as rg window = rg.TurtleWindow() # turtle_1 = rg.SimpleTurtle('turtle') # turtle_1 .pen = rg.Pen('midnight blue', 3) # turtle_1 .speed = 10 # Fast # size=80 colors = ["red", "orange", "yellow", "green", "blue", "violet", "red"] for k in range(6): # Makes the turtle and chose the fill color turtle_1 = rg.SimpleTurtle('turtle') turtle_1.paint_bucket = rg.PaintBucket(colors[k]) # Pen color and speed turtle_1.pen = rg.Pen(colors[k + 1], 3) turtle_1.speed = 10 # Fast # Begins fill turtle_1.begin_fill() # Makes the big squares turtle_1.left(60 * k) turtle_1.draw_square(180) # Ends fill turtle_1.end_fill() # Put the pen down again (so drawing resumes).
# (by moving, using its rg.Pen). ANYTHING is fine! # 3. Each rg.SimpleTurtle moves inside a LOOP. # # Be creative! Strive for way-cool pictures! Abstract pictures rule! # # If you make syntax (notational) errors, no worries -- get help # fixing them at either this session OR at the NEXT session. # # Don't forget to COMMIT your work by using VCS ~ Commit and Push. ######################################################################## import rosegraphics as rg window = rg.TurtleWindow() blue = rg.SimpleTurtle('turtle') blue.paint_bucket = rg.PaintBucket('blue') blue.speed = 40 black = rg.SimpleTurtle('turtle') black.paint_bucket = rg.PaintBucket('black') black.speed = 40 blue.forward(200) blue.left(90) blue.forward(200) blue.left(90) black.forward(200) black.left(90) black.forward(200) black.left(90) black.forward(10)