diff options
author | Marion <marion.zepf@gmail.com> | 2013-07-03 13:06:51 (GMT) |
---|---|---|
committer | Marion <marion.zepf@gmail.com> | 2013-07-03 13:06:51 (GMT) |
commit | 20795e5eb541fc5737b0f86b9328348416c227fd (patch) | |
tree | 2e2bd5cb1274efb05e1588fa5780f82caa03d2d8 /pysamples/forward_push.py | |
parent | df11c4c738135042a2d16dc12c8dff3da757bf5f (diff) | |
parent | c8f0b798b239eb67f50a8a018c87a4c1106c2d20 (diff) |
Merge remote-tracking branch 'mainline/turtle-centric-2'
Diffstat (limited to 'pysamples/forward_push.py')
-rw-r--r-- | pysamples/forward_push.py | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/pysamples/forward_push.py b/pysamples/forward_push.py index b98c726..ca527db 100644 --- a/pysamples/forward_push.py +++ b/pysamples/forward_push.py @@ -1,10 +1,13 @@ -#Copyright (c) 2012, Walter Bender +#Copyright (c) 2012-2013, Walter Bender # Usage: Import this code into a Python (user-definable) block; when -# this code is run, the turtle will draw a line of the length of the -# numeric argument block docked to the Python block. But before -# drawing the line, it pushes the rgb values of the destination to the -# FILO. +# this code is run, a new block will be added to the Turtle Palette. +# This block will be named 'name', the value of the argument block +# docked to the Python block. +# +# The new block will cause the turtle to draw a line of the +# length. But before drawing the line, it pushes the rgb values of the +# destination to the FILO. def myblock(tw, name): @@ -15,16 +18,16 @@ def myblock(tw, name): line_length = float(line_length) except ValueError: return - penstatus = tw.canvas.pendown - tw.canvas.setpen(False) - tw.canvas.forward(line_length) - r, g, b, a = tw.canvas.get_pixel() + penstatus = tw.turtles.get_active_turtle().get_pen_status() + tw.turtles.get_active_turtle().set_pen_state(False) + tw.turtles.get_active_turtle().forward(line_length) + r, g, b, a = tw.turtles.get_active_turtle().get_pixel() tw.lc.heap.append(b) tw.lc.heap.append(g) tw.lc.heap.append(r) - tw.canvas.forward(-line_length) - tw.canvas.setpen(penstatus) - tw.canvas.forward(line_length) + tw.turtles.get_active_turtle().forward(-line_length) + tw.turtles.get_active_turtle().set_pen_state(penstatus) + tw.turtles.get_active_turtle().forward(line_length) return from TurtleArt.tapalette import make_palette, palette_name_to_index |