MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / stamp

Method stamp

tools/python-3.11.9-amd64/Lib/turtle.py:3051–3094  ·  view source on GitHub ↗

Stamp a copy of the turtleshape onto the canvas and return its id. No argument. Stamp a copy of the turtle shape onto the canvas at the current turtle position. Return a stamp_id for that stamp, which can be used to delete it by calling clearstamp(stamp_id).

(self)

Source from the content-addressed store, hash-verified

3049############################## stamp stuff ###############################
3050
3051 def stamp(self):
3052 """Stamp a copy of the turtleshape onto the canvas and return its id.
3053
3054 No argument.
3055
3056 Stamp a copy of the turtle shape onto the canvas at the current
3057 turtle position. Return a stamp_id for that stamp, which can be
3058 used to delete it by calling clearstamp(stamp_id).
3059
3060 Example (for a Turtle instance named turtle):
3061 >>> turtle.color("blue")
3062 >>> turtle.stamp()
3063 13
3064 >>> turtle.fd(50)
3065 """
3066 screen = self.screen
3067 shape = screen._shapes[self.turtle.shapeIndex]
3068 ttype = shape._type
3069 tshape = shape._data
3070 if ttype == "polygon":
3071 stitem = screen._createpoly()
3072 if self._resizemode == "noresize": w = 1
3073 elif self._resizemode == "auto": w = self._pensize
3074 else: w =self._outlinewidth
3075 shape = self._polytrafo(self._getshapepoly(tshape))
3076 fc, oc = self._fillcolor, self._pencolor
3077 screen._drawpoly(stitem, shape, fill=fc, outline=oc,
3078 width=w, top=True)
3079 elif ttype == "image":
3080 stitem = screen._createimage("")
3081 screen._drawimage(stitem, self._position, tshape)
3082 elif ttype == "compound":
3083 stitem = []
3084 for element in tshape:
3085 item = screen._createpoly()
3086 stitem.append(item)
3087 stitem = tuple(stitem)
3088 for item, (poly, fc, oc) in zip(stitem, tshape):
3089 poly = self._polytrafo(self._getshapepoly(poly, True))
3090 screen._drawpoly(item, poly, fill=self._cc(fc),
3091 outline=self._cc(oc), width=self._outlinewidth, top=True)
3092 self.stampItems.append(stitem)
3093 self.undobuffer.push(("stamp", stitem))
3094 return stitem
3095
3096 def _clearstamp(self, stampid):
3097 """does the work for clearstamp() and clearstamps()

Callers 1

demo2Function · 0.80

Calls 10

_polytrafoMethod · 0.95
_getshapepolyMethod · 0.95
_ccMethod · 0.95
tupleClass · 0.85
_createpolyMethod · 0.80
_drawpolyMethod · 0.80
_createimageMethod · 0.80
_drawimageMethod · 0.80
appendMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected