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)
| 3150 | ############################## stamp stuff ############################### |
| 3151 | |
| 3152 | def stamp(self): |
| 3153 | """Stamp a copy of the turtleshape onto the canvas and return its id. |
| 3154 | |
| 3155 | No argument. |
| 3156 | |
| 3157 | Stamp a copy of the turtle shape onto the canvas at the current |
| 3158 | turtle position. Return a stamp_id for that stamp, which can be |
| 3159 | used to delete it by calling clearstamp(stamp_id). |
| 3160 | |
| 3161 | Example (for a Turtle instance named turtle): |
| 3162 | >>> turtle.color("blue") |
| 3163 | >>> turtle.stamp() |
| 3164 | 13 |
| 3165 | >>> turtle.fd(50) |
| 3166 | """ |
| 3167 | screen = self.screen |
| 3168 | shape = screen._shapes[self.turtle.shapeIndex] |
| 3169 | ttype = shape._type |
| 3170 | tshape = shape._data |
| 3171 | if ttype == "polygon": |
| 3172 | stitem = screen._createpoly() |
| 3173 | if self._resizemode == "noresize": w = 1 |
| 3174 | elif self._resizemode == "auto": w = self._pensize |
| 3175 | else: w =self._outlinewidth |
| 3176 | shape = self._polytrafo(self._getshapepoly(tshape)) |
| 3177 | fc, oc = self._fillcolor, self._pencolor |
| 3178 | screen._drawpoly(stitem, shape, fill=fc, outline=oc, |
| 3179 | width=w, top=True) |
| 3180 | elif ttype == "image": |
| 3181 | stitem = screen._createimage("") |
| 3182 | screen._drawimage(stitem, self._position, tshape) |
| 3183 | elif ttype == "compound": |
| 3184 | stitem = [] |
| 3185 | for element in tshape: |
| 3186 | item = screen._createpoly() |
| 3187 | stitem.append(item) |
| 3188 | stitem = tuple(stitem) |
| 3189 | for item, (poly, fc, oc) in zip(stitem, tshape): |
| 3190 | poly = self._polytrafo(self._getshapepoly(poly, True)) |
| 3191 | screen._drawpoly(item, poly, fill=self._cc(fc), |
| 3192 | outline=self._cc(oc), width=self._outlinewidth, top=True) |
| 3193 | self.stampItems.append(stitem) |
| 3194 | self.undobuffer.push(("stamp", stitem)) |
| 3195 | return stitem |
| 3196 | |
| 3197 | def _clearstamp(self, stampid): |
| 3198 | """does the work for clearstamp() and clearstamps() |
no test coverage detected