Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/AnonR/smanonr..../lib64/python3....
File: turtle.py
titem = self.turtle._item
[3000] Fix | Delete
if self._shown and screen._updatecounter == 0 and screen._tracing > 0:
[3001] Fix | Delete
self._hidden_from_screen = False
[3002] Fix | Delete
tshape = shape._data
[3003] Fix | Delete
if ttype == "polygon":
[3004] Fix | Delete
if self._resizemode == "noresize": w = 1
[3005] Fix | Delete
elif self._resizemode == "auto": w = self._pensize
[3006] Fix | Delete
else: w =self._outlinewidth
[3007] Fix | Delete
shape = self._polytrafo(self._getshapepoly(tshape))
[3008] Fix | Delete
fc, oc = self._fillcolor, self._pencolor
[3009] Fix | Delete
screen._drawpoly(titem, shape, fill=fc, outline=oc,
[3010] Fix | Delete
width=w, top=True)
[3011] Fix | Delete
elif ttype == "image":
[3012] Fix | Delete
screen._drawimage(titem, self._position, tshape)
[3013] Fix | Delete
elif ttype == "compound":
[3014] Fix | Delete
for item, (poly, fc, oc) in zip(titem, tshape):
[3015] Fix | Delete
poly = self._polytrafo(self._getshapepoly(poly, True))
[3016] Fix | Delete
screen._drawpoly(item, poly, fill=self._cc(fc),
[3017] Fix | Delete
outline=self._cc(oc), width=self._outlinewidth, top=True)
[3018] Fix | Delete
else:
[3019] Fix | Delete
if self._hidden_from_screen:
[3020] Fix | Delete
return
[3021] Fix | Delete
if ttype == "polygon":
[3022] Fix | Delete
screen._drawpoly(titem, ((0, 0), (0, 0), (0, 0)), "", "")
[3023] Fix | Delete
elif ttype == "image":
[3024] Fix | Delete
screen._drawimage(titem, self._position,
[3025] Fix | Delete
screen._shapes["blank"]._data)
[3026] Fix | Delete
elif ttype == "compound":
[3027] Fix | Delete
for item in titem:
[3028] Fix | Delete
screen._drawpoly(item, ((0, 0), (0, 0), (0, 0)), "", "")
[3029] Fix | Delete
self._hidden_from_screen = True
[3030] Fix | Delete
[3031] Fix | Delete
############################## stamp stuff ###############################
[3032] Fix | Delete
[3033] Fix | Delete
def stamp(self):
[3034] Fix | Delete
"""Stamp a copy of the turtleshape onto the canvas and return its id.
[3035] Fix | Delete
[3036] Fix | Delete
No argument.
[3037] Fix | Delete
[3038] Fix | Delete
Stamp a copy of the turtle shape onto the canvas at the current
[3039] Fix | Delete
turtle position. Return a stamp_id for that stamp, which can be
[3040] Fix | Delete
used to delete it by calling clearstamp(stamp_id).
[3041] Fix | Delete
[3042] Fix | Delete
Example (for a Turtle instance named turtle):
[3043] Fix | Delete
>>> turtle.color("blue")
[3044] Fix | Delete
>>> turtle.stamp()
[3045] Fix | Delete
13
[3046] Fix | Delete
>>> turtle.fd(50)
[3047] Fix | Delete
"""
[3048] Fix | Delete
screen = self.screen
[3049] Fix | Delete
shape = screen._shapes[self.turtle.shapeIndex]
[3050] Fix | Delete
ttype = shape._type
[3051] Fix | Delete
tshape = shape._data
[3052] Fix | Delete
if ttype == "polygon":
[3053] Fix | Delete
stitem = screen._createpoly()
[3054] Fix | Delete
if self._resizemode == "noresize": w = 1
[3055] Fix | Delete
elif self._resizemode == "auto": w = self._pensize
[3056] Fix | Delete
else: w =self._outlinewidth
[3057] Fix | Delete
shape = self._polytrafo(self._getshapepoly(tshape))
[3058] Fix | Delete
fc, oc = self._fillcolor, self._pencolor
[3059] Fix | Delete
screen._drawpoly(stitem, shape, fill=fc, outline=oc,
[3060] Fix | Delete
width=w, top=True)
[3061] Fix | Delete
elif ttype == "image":
[3062] Fix | Delete
stitem = screen._createimage("")
[3063] Fix | Delete
screen._drawimage(stitem, self._position, tshape)
[3064] Fix | Delete
elif ttype == "compound":
[3065] Fix | Delete
stitem = []
[3066] Fix | Delete
for element in tshape:
[3067] Fix | Delete
item = screen._createpoly()
[3068] Fix | Delete
stitem.append(item)
[3069] Fix | Delete
stitem = tuple(stitem)
[3070] Fix | Delete
for item, (poly, fc, oc) in zip(stitem, tshape):
[3071] Fix | Delete
poly = self._polytrafo(self._getshapepoly(poly, True))
[3072] Fix | Delete
screen._drawpoly(item, poly, fill=self._cc(fc),
[3073] Fix | Delete
outline=self._cc(oc), width=self._outlinewidth, top=True)
[3074] Fix | Delete
self.stampItems.append(stitem)
[3075] Fix | Delete
self.undobuffer.push(("stamp", stitem))
[3076] Fix | Delete
return stitem
[3077] Fix | Delete
[3078] Fix | Delete
def _clearstamp(self, stampid):
[3079] Fix | Delete
"""does the work for clearstamp() and clearstamps()
[3080] Fix | Delete
"""
[3081] Fix | Delete
if stampid in self.stampItems:
[3082] Fix | Delete
if isinstance(stampid, tuple):
[3083] Fix | Delete
for subitem in stampid:
[3084] Fix | Delete
self.screen._delete(subitem)
[3085] Fix | Delete
else:
[3086] Fix | Delete
self.screen._delete(stampid)
[3087] Fix | Delete
self.stampItems.remove(stampid)
[3088] Fix | Delete
# Delete stampitem from undobuffer if necessary
[3089] Fix | Delete
# if clearstamp is called directly.
[3090] Fix | Delete
item = ("stamp", stampid)
[3091] Fix | Delete
buf = self.undobuffer
[3092] Fix | Delete
if item not in buf.buffer:
[3093] Fix | Delete
return
[3094] Fix | Delete
index = buf.buffer.index(item)
[3095] Fix | Delete
buf.buffer.remove(item)
[3096] Fix | Delete
if index <= buf.ptr:
[3097] Fix | Delete
buf.ptr = (buf.ptr - 1) % buf.bufsize
[3098] Fix | Delete
buf.buffer.insert((buf.ptr+1)%buf.bufsize, [None])
[3099] Fix | Delete
[3100] Fix | Delete
def clearstamp(self, stampid):
[3101] Fix | Delete
"""Delete stamp with given stampid
[3102] Fix | Delete
[3103] Fix | Delete
Argument:
[3104] Fix | Delete
stampid - an integer, must be return value of previous stamp() call.
[3105] Fix | Delete
[3106] Fix | Delete
Example (for a Turtle instance named turtle):
[3107] Fix | Delete
>>> turtle.color("blue")
[3108] Fix | Delete
>>> astamp = turtle.stamp()
[3109] Fix | Delete
>>> turtle.fd(50)
[3110] Fix | Delete
>>> turtle.clearstamp(astamp)
[3111] Fix | Delete
"""
[3112] Fix | Delete
self._clearstamp(stampid)
[3113] Fix | Delete
self._update()
[3114] Fix | Delete
[3115] Fix | Delete
def clearstamps(self, n=None):
[3116] Fix | Delete
"""Delete all or first/last n of turtle's stamps.
[3117] Fix | Delete
[3118] Fix | Delete
Optional argument:
[3119] Fix | Delete
n -- an integer
[3120] Fix | Delete
[3121] Fix | Delete
If n is None, delete all of pen's stamps,
[3122] Fix | Delete
else if n > 0 delete first n stamps
[3123] Fix | Delete
else if n < 0 delete last n stamps.
[3124] Fix | Delete
[3125] Fix | Delete
Example (for a Turtle instance named turtle):
[3126] Fix | Delete
>>> for i in range(8):
[3127] Fix | Delete
... turtle.stamp(); turtle.fd(30)
[3128] Fix | Delete
...
[3129] Fix | Delete
>>> turtle.clearstamps(2)
[3130] Fix | Delete
>>> turtle.clearstamps(-2)
[3131] Fix | Delete
>>> turtle.clearstamps()
[3132] Fix | Delete
"""
[3133] Fix | Delete
if n is None:
[3134] Fix | Delete
toDelete = self.stampItems[:]
[3135] Fix | Delete
elif n >= 0:
[3136] Fix | Delete
toDelete = self.stampItems[:n]
[3137] Fix | Delete
else:
[3138] Fix | Delete
toDelete = self.stampItems[n:]
[3139] Fix | Delete
for item in toDelete:
[3140] Fix | Delete
self._clearstamp(item)
[3141] Fix | Delete
self._update()
[3142] Fix | Delete
[3143] Fix | Delete
def _goto(self, end):
[3144] Fix | Delete
"""Move the pen to the point end, thereby drawing a line
[3145] Fix | Delete
if pen is down. All other methods for turtle movement depend
[3146] Fix | Delete
on this one.
[3147] Fix | Delete
"""
[3148] Fix | Delete
## Version with undo-stuff
[3149] Fix | Delete
go_modes = ( self._drawing,
[3150] Fix | Delete
self._pencolor,
[3151] Fix | Delete
self._pensize,
[3152] Fix | Delete
isinstance(self._fillpath, list))
[3153] Fix | Delete
screen = self.screen
[3154] Fix | Delete
undo_entry = ("go", self._position, end, go_modes,
[3155] Fix | Delete
(self.currentLineItem,
[3156] Fix | Delete
self.currentLine[:],
[3157] Fix | Delete
screen._pointlist(self.currentLineItem),
[3158] Fix | Delete
self.items[:])
[3159] Fix | Delete
)
[3160] Fix | Delete
if self.undobuffer:
[3161] Fix | Delete
self.undobuffer.push(undo_entry)
[3162] Fix | Delete
start = self._position
[3163] Fix | Delete
if self._speed and screen._tracing == 1:
[3164] Fix | Delete
diff = (end-start)
[3165] Fix | Delete
diffsq = (diff[0]*screen.xscale)**2 + (diff[1]*screen.yscale)**2
[3166] Fix | Delete
nhops = 1+int((diffsq**0.5)/(3*(1.1**self._speed)*self._speed))
[3167] Fix | Delete
delta = diff * (1.0/nhops)
[3168] Fix | Delete
for n in range(1, nhops):
[3169] Fix | Delete
if n == 1:
[3170] Fix | Delete
top = True
[3171] Fix | Delete
else:
[3172] Fix | Delete
top = False
[3173] Fix | Delete
self._position = start + delta * n
[3174] Fix | Delete
if self._drawing:
[3175] Fix | Delete
screen._drawline(self.drawingLineItem,
[3176] Fix | Delete
(start, self._position),
[3177] Fix | Delete
self._pencolor, self._pensize, top)
[3178] Fix | Delete
self._update()
[3179] Fix | Delete
if self._drawing:
[3180] Fix | Delete
screen._drawline(self.drawingLineItem, ((0, 0), (0, 0)),
[3181] Fix | Delete
fill="", width=self._pensize)
[3182] Fix | Delete
# Turtle now at end,
[3183] Fix | Delete
if self._drawing: # now update currentLine
[3184] Fix | Delete
self.currentLine.append(end)
[3185] Fix | Delete
if isinstance(self._fillpath, list):
[3186] Fix | Delete
self._fillpath.append(end)
[3187] Fix | Delete
###### vererbung!!!!!!!!!!!!!!!!!!!!!!
[3188] Fix | Delete
self._position = end
[3189] Fix | Delete
if self._creatingPoly:
[3190] Fix | Delete
self._poly.append(end)
[3191] Fix | Delete
if len(self.currentLine) > 42: # 42! answer to the ultimate question
[3192] Fix | Delete
# of life, the universe and everything
[3193] Fix | Delete
self._newLine()
[3194] Fix | Delete
self._update() #count=True)
[3195] Fix | Delete
[3196] Fix | Delete
def _undogoto(self, entry):
[3197] Fix | Delete
"""Reverse a _goto. Used for undo()
[3198] Fix | Delete
"""
[3199] Fix | Delete
old, new, go_modes, coodata = entry
[3200] Fix | Delete
drawing, pc, ps, filling = go_modes
[3201] Fix | Delete
cLI, cL, pl, items = coodata
[3202] Fix | Delete
screen = self.screen
[3203] Fix | Delete
if abs(self._position - new) > 0.5:
[3204] Fix | Delete
print ("undogoto: HALLO-DA-STIMMT-WAS-NICHT!")
[3205] Fix | Delete
# restore former situation
[3206] Fix | Delete
self.currentLineItem = cLI
[3207] Fix | Delete
self.currentLine = cL
[3208] Fix | Delete
[3209] Fix | Delete
if pl == [(0, 0), (0, 0)]:
[3210] Fix | Delete
usepc = ""
[3211] Fix | Delete
else:
[3212] Fix | Delete
usepc = pc
[3213] Fix | Delete
screen._drawline(cLI, pl, fill=usepc, width=ps)
[3214] Fix | Delete
[3215] Fix | Delete
todelete = [i for i in self.items if (i not in items) and
[3216] Fix | Delete
(screen._type(i) == "line")]
[3217] Fix | Delete
for i in todelete:
[3218] Fix | Delete
screen._delete(i)
[3219] Fix | Delete
self.items.remove(i)
[3220] Fix | Delete
[3221] Fix | Delete
start = old
[3222] Fix | Delete
if self._speed and screen._tracing == 1:
[3223] Fix | Delete
diff = old - new
[3224] Fix | Delete
diffsq = (diff[0]*screen.xscale)**2 + (diff[1]*screen.yscale)**2
[3225] Fix | Delete
nhops = 1+int((diffsq**0.5)/(3*(1.1**self._speed)*self._speed))
[3226] Fix | Delete
delta = diff * (1.0/nhops)
[3227] Fix | Delete
for n in range(1, nhops):
[3228] Fix | Delete
if n == 1:
[3229] Fix | Delete
top = True
[3230] Fix | Delete
else:
[3231] Fix | Delete
top = False
[3232] Fix | Delete
self._position = new + delta * n
[3233] Fix | Delete
if drawing:
[3234] Fix | Delete
screen._drawline(self.drawingLineItem,
[3235] Fix | Delete
(start, self._position),
[3236] Fix | Delete
pc, ps, top)
[3237] Fix | Delete
self._update()
[3238] Fix | Delete
if drawing:
[3239] Fix | Delete
screen._drawline(self.drawingLineItem, ((0, 0), (0, 0)),
[3240] Fix | Delete
fill="", width=ps)
[3241] Fix | Delete
# Turtle now at position old,
[3242] Fix | Delete
self._position = old
[3243] Fix | Delete
## if undo is done during creating a polygon, the last vertex
[3244] Fix | Delete
## will be deleted. if the polygon is entirely deleted,
[3245] Fix | Delete
## creatingPoly will be set to False.
[3246] Fix | Delete
## Polygons created before the last one will not be affected by undo()
[3247] Fix | Delete
if self._creatingPoly:
[3248] Fix | Delete
if len(self._poly) > 0:
[3249] Fix | Delete
self._poly.pop()
[3250] Fix | Delete
if self._poly == []:
[3251] Fix | Delete
self._creatingPoly = False
[3252] Fix | Delete
self._poly = None
[3253] Fix | Delete
if filling:
[3254] Fix | Delete
if self._fillpath == []:
[3255] Fix | Delete
self._fillpath = None
[3256] Fix | Delete
print("Unwahrscheinlich in _undogoto!")
[3257] Fix | Delete
elif self._fillpath is not None:
[3258] Fix | Delete
self._fillpath.pop()
[3259] Fix | Delete
self._update() #count=True)
[3260] Fix | Delete
[3261] Fix | Delete
def _rotate(self, angle):
[3262] Fix | Delete
"""Turns pen clockwise by angle.
[3263] Fix | Delete
"""
[3264] Fix | Delete
if self.undobuffer:
[3265] Fix | Delete
self.undobuffer.push(("rot", angle, self._degreesPerAU))
[3266] Fix | Delete
angle *= self._degreesPerAU
[3267] Fix | Delete
neworient = self._orient.rotate(angle)
[3268] Fix | Delete
tracing = self.screen._tracing
[3269] Fix | Delete
if tracing == 1 and self._speed > 0:
[3270] Fix | Delete
anglevel = 3.0 * self._speed
[3271] Fix | Delete
steps = 1 + int(abs(angle)/anglevel)
[3272] Fix | Delete
delta = 1.0*angle/steps
[3273] Fix | Delete
for _ in range(steps):
[3274] Fix | Delete
self._orient = self._orient.rotate(delta)
[3275] Fix | Delete
self._update()
[3276] Fix | Delete
self._orient = neworient
[3277] Fix | Delete
self._update()
[3278] Fix | Delete
[3279] Fix | Delete
def _newLine(self, usePos=True):
[3280] Fix | Delete
"""Closes current line item and starts a new one.
[3281] Fix | Delete
Remark: if current line became too long, animation
[3282] Fix | Delete
performance (via _drawline) slowed down considerably.
[3283] Fix | Delete
"""
[3284] Fix | Delete
if len(self.currentLine) > 1:
[3285] Fix | Delete
self.screen._drawline(self.currentLineItem, self.currentLine,
[3286] Fix | Delete
self._pencolor, self._pensize)
[3287] Fix | Delete
self.currentLineItem = self.screen._createline()
[3288] Fix | Delete
self.items.append(self.currentLineItem)
[3289] Fix | Delete
else:
[3290] Fix | Delete
self.screen._drawline(self.currentLineItem, top=True)
[3291] Fix | Delete
self.currentLine = []
[3292] Fix | Delete
if usePos:
[3293] Fix | Delete
self.currentLine = [self._position]
[3294] Fix | Delete
[3295] Fix | Delete
def filling(self):
[3296] Fix | Delete
"""Return fillstate (True if filling, False else).
[3297] Fix | Delete
[3298] Fix | Delete
No argument.
[3299] Fix | Delete
[3300] Fix | Delete
Example (for a Turtle instance named turtle):
[3301] Fix | Delete
>>> turtle.begin_fill()
[3302] Fix | Delete
>>> if turtle.filling():
[3303] Fix | Delete
... turtle.pensize(5)
[3304] Fix | Delete
... else:
[3305] Fix | Delete
... turtle.pensize(3)
[3306] Fix | Delete
"""
[3307] Fix | Delete
return isinstance(self._fillpath, list)
[3308] Fix | Delete
[3309] Fix | Delete
def begin_fill(self):
[3310] Fix | Delete
"""Called just before drawing a shape to be filled.
[3311] Fix | Delete
[3312] Fix | Delete
No argument.
[3313] Fix | Delete
[3314] Fix | Delete
Example (for a Turtle instance named turtle):
[3315] Fix | Delete
>>> turtle.color("black", "red")
[3316] Fix | Delete
>>> turtle.begin_fill()
[3317] Fix | Delete
>>> turtle.circle(60)
[3318] Fix | Delete
>>> turtle.end_fill()
[3319] Fix | Delete
"""
[3320] Fix | Delete
if not self.filling():
[3321] Fix | Delete
self._fillitem = self.screen._createpoly()
[3322] Fix | Delete
self.items.append(self._fillitem)
[3323] Fix | Delete
self._fillpath = [self._position]
[3324] Fix | Delete
self._newLine()
[3325] Fix | Delete
if self.undobuffer:
[3326] Fix | Delete
self.undobuffer.push(("beginfill", self._fillitem))
[3327] Fix | Delete
self._update()
[3328] Fix | Delete
[3329] Fix | Delete
[3330] Fix | Delete
def end_fill(self):
[3331] Fix | Delete
"""Fill the shape drawn after the call begin_fill().
[3332] Fix | Delete
[3333] Fix | Delete
No argument.
[3334] Fix | Delete
[3335] Fix | Delete
Example (for a Turtle instance named turtle):
[3336] Fix | Delete
>>> turtle.color("black", "red")
[3337] Fix | Delete
>>> turtle.begin_fill()
[3338] Fix | Delete
>>> turtle.circle(60)
[3339] Fix | Delete
>>> turtle.end_fill()
[3340] Fix | Delete
"""
[3341] Fix | Delete
if self.filling():
[3342] Fix | Delete
if len(self._fillpath) > 2:
[3343] Fix | Delete
self.screen._drawpoly(self._fillitem, self._fillpath,
[3344] Fix | Delete
fill=self._fillcolor)
[3345] Fix | Delete
if self.undobuffer:
[3346] Fix | Delete
self.undobuffer.push(("dofill", self._fillitem))
[3347] Fix | Delete
self._fillitem = self._fillpath = None
[3348] Fix | Delete
self._update()
[3349] Fix | Delete
[3350] Fix | Delete
def dot(self, size=None, *color):
[3351] Fix | Delete
"""Draw a dot with diameter size, using color.
[3352] Fix | Delete
[3353] Fix | Delete
Optional arguments:
[3354] Fix | Delete
size -- an integer >= 1 (if given)
[3355] Fix | Delete
color -- a colorstring or a numeric color tuple
[3356] Fix | Delete
[3357] Fix | Delete
Draw a circular dot with diameter size, using color.
[3358] Fix | Delete
If size is not given, the maximum of pensize+4 and 2*pensize is used.
[3359] Fix | Delete
[3360] Fix | Delete
Example (for a Turtle instance named turtle):
[3361] Fix | Delete
>>> turtle.dot()
[3362] Fix | Delete
>>> turtle.fd(50); turtle.dot(20, "blue"); turtle.fd(50)
[3363] Fix | Delete
"""
[3364] Fix | Delete
if not color:
[3365] Fix | Delete
if isinstance(size, (str, tuple)):
[3366] Fix | Delete
color = self._colorstr(size)
[3367] Fix | Delete
size = self._pensize + max(self._pensize, 4)
[3368] Fix | Delete
else:
[3369] Fix | Delete
color = self._pencolor
[3370] Fix | Delete
if not size:
[3371] Fix | Delete
size = self._pensize + max(self._pensize, 4)
[3372] Fix | Delete
else:
[3373] Fix | Delete
if size is None:
[3374] Fix | Delete
size = self._pensize + max(self._pensize, 4)
[3375] Fix | Delete
color = self._colorstr(color)
[3376] Fix | Delete
if hasattr(self.screen, "_dot"):
[3377] Fix | Delete
item = self.screen._dot(self._position, size, color)
[3378] Fix | Delete
self.items.append(item)
[3379] Fix | Delete
if self.undobuffer:
[3380] Fix | Delete
self.undobuffer.push(("dot", item))
[3381] Fix | Delete
else:
[3382] Fix | Delete
pen = self.pen()
[3383] Fix | Delete
if self.undobuffer:
[3384] Fix | Delete
self.undobuffer.push(["seq"])
[3385] Fix | Delete
self.undobuffer.cumulate = True
[3386] Fix | Delete
try:
[3387] Fix | Delete
if self.resizemode() == 'auto':
[3388] Fix | Delete
self.ht()
[3389] Fix | Delete
self.pendown()
[3390] Fix | Delete
self.pensize(size)
[3391] Fix | Delete
self.pencolor(color)
[3392] Fix | Delete
self.forward(0)
[3393] Fix | Delete
finally:
[3394] Fix | Delete
self.pen(pen)
[3395] Fix | Delete
if self.undobuffer:
[3396] Fix | Delete
self.undobuffer.cumulate = False
[3397] Fix | Delete
[3398] Fix | Delete
def _write(self, txt, align, font):
[3399] Fix | Delete
"""Performs the writing for write()
[3400] Fix | Delete
"""
[3401] Fix | Delete
item, end = self.screen._write(self._position, txt, align, font,
[3402] Fix | Delete
self._pencolor)
[3403] Fix | Delete
self.items.append(item)
[3404] Fix | Delete
if self.undobuffer:
[3405] Fix | Delete
self.undobuffer.push(("wri", item))
[3406] Fix | Delete
return end
[3407] Fix | Delete
[3408] Fix | Delete
def write(self, arg, move=False, align="left", font=("Arial", 8, "normal")):
[3409] Fix | Delete
"""Write text at the current turtle position.
[3410] Fix | Delete
[3411] Fix | Delete
Arguments:
[3412] Fix | Delete
arg -- info, which is to be written to the TurtleScreen
[3413] Fix | Delete
move (optional) -- True/False
[3414] Fix | Delete
align (optional) -- one of the strings "left", "center" or right"
[3415] Fix | Delete
font (optional) -- a triple (fontname, fontsize, fonttype)
[3416] Fix | Delete
[3417] Fix | Delete
Write text - the string representation of arg - at the current
[3418] Fix | Delete
turtle position according to align ("left", "center" or right")
[3419] Fix | Delete
and with the given font.
[3420] Fix | Delete
If move is True, the pen is moved to the bottom-right corner
[3421] Fix | Delete
of the text. By default, move is False.
[3422] Fix | Delete
[3423] Fix | Delete
Example (for a Turtle instance named turtle):
[3424] Fix | Delete
>>> turtle.write('Home = ', True, align="center")
[3425] Fix | Delete
>>> turtle.write((0,0), True)
[3426] Fix | Delete
"""
[3427] Fix | Delete
if self.undobuffer:
[3428] Fix | Delete
self.undobuffer.push(["seq"])
[3429] Fix | Delete
self.undobuffer.cumulate = True
[3430] Fix | Delete
end = self._write(str(arg), align.lower(), font)
[3431] Fix | Delete
if move:
[3432] Fix | Delete
x, y = self.pos()
[3433] Fix | Delete
self.setpos(end, y)
[3434] Fix | Delete
if self.undobuffer:
[3435] Fix | Delete
self.undobuffer.cumulate = False
[3436] Fix | Delete
[3437] Fix | Delete
def begin_poly(self):
[3438] Fix | Delete
"""Start recording the vertices of a polygon.
[3439] Fix | Delete
[3440] Fix | Delete
No argument.
[3441] Fix | Delete
[3442] Fix | Delete
Start recording the vertices of a polygon. Current turtle position
[3443] Fix | Delete
is first point of polygon.
[3444] Fix | Delete
[3445] Fix | Delete
Example (for a Turtle instance named turtle):
[3446] Fix | Delete
>>> turtle.begin_poly()
[3447] Fix | Delete
"""
[3448] Fix | Delete
self._poly = [self._position]
[3449] Fix | Delete
self._creatingPoly = True
[3450] Fix | Delete
[3451] Fix | Delete
def end_poly(self):
[3452] Fix | Delete
"""Stop recording the vertices of a polygon.
[3453] Fix | Delete
[3454] Fix | Delete
No argument.
[3455] Fix | Delete
[3456] Fix | Delete
Stop recording the vertices of a polygon. Current turtle position is
[3457] Fix | Delete
last point of polygon. This will be connected with the first point.
[3458] Fix | Delete
[3459] Fix | Delete
Example (for a Turtle instance named turtle):
[3460] Fix | Delete
>>> turtle.end_poly()
[3461] Fix | Delete
"""
[3462] Fix | Delete
self._creatingPoly = False
[3463] Fix | Delete
[3464] Fix | Delete
def get_poly(self):
[3465] Fix | Delete
"""Return the lastly recorded polygon.
[3466] Fix | Delete
[3467] Fix | Delete
No argument.
[3468] Fix | Delete
[3469] Fix | Delete
Example (for a Turtle instance named turtle):
[3470] Fix | Delete
>>> p = turtle.get_poly()
[3471] Fix | Delete
>>> turtle.register_shape("myFavouriteShape", p)
[3472] Fix | Delete
"""
[3473] Fix | Delete
## check if there is any poly?
[3474] Fix | Delete
if self._poly is not None:
[3475] Fix | Delete
return tuple(self._poly)
[3476] Fix | Delete
[3477] Fix | Delete
def getscreen(self):
[3478] Fix | Delete
"""Return the TurtleScreen object, the turtle is drawing on.
[3479] Fix | Delete
[3480] Fix | Delete
No argument.
[3481] Fix | Delete
[3482] Fix | Delete
Return the TurtleScreen object, the turtle is drawing on.
[3483] Fix | Delete
So TurtleScreen-methods can be called for that object.
[3484] Fix | Delete
[3485] Fix | Delete
Example (for a Turtle instance named turtle):
[3486] Fix | Delete
>>> ts = turtle.getscreen()
[3487] Fix | Delete
>>> ts
[3488] Fix | Delete
<turtle.TurtleScreen object at 0x0106B770>
[3489] Fix | Delete
>>> ts.bgcolor("pink")
[3490] Fix | Delete
"""
[3491] Fix | Delete
return self.screen
[3492] Fix | Delete
[3493] Fix | Delete
def getturtle(self):
[3494] Fix | Delete
"""Return the Turtleobject itself.
[3495] Fix | Delete
[3496] Fix | Delete
No argument.
[3497] Fix | Delete
[3498] Fix | Delete
Only reasonable use: as a function to return the 'anonymous turtle':
[3499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function