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)
| 2931 | ############################## stamp stuff ############################### |
| 2932 | |
| 2933 | def stamp(self): |
| 2934 | """Stamp a copy of the turtleshape onto the canvas and return its id. |
| 2935 | |
| 2936 | No argument. |
| 2937 | |
| 2938 | Stamp a copy of the turtle shape onto the canvas at the current |
| 2939 | turtle position. Return a stamp_id for that stamp, which can be |
| 2940 | used to delete it by calling clearstamp(stamp_id). |
| 2941 | |
| 2942 | Example (for a Turtle instance named turtle): |
| 2943 | >>> turtle.color("blue") |
| 2944 | >>> turtle.stamp() |
| 2945 | 13 |
| 2946 | >>> turtle.fd(50) |
| 2947 | """ |
| 2948 | screen = self.screen |
| 2949 | shape = screen._shapes[self.turtle.shapeIndex] |
| 2950 | ttype = shape._type |
| 2951 | tshape = shape._data |
| 2952 | if ttype == "polygon": |
| 2953 | stitem = screen._createpoly() |
| 2954 | if self._resizemode == "noresize": w = 1 |
| 2955 | elif self._resizemode == "auto": w = self._pensize |
| 2956 | else: w =self._outlinewidth |
| 2957 | shape = self._polytrafo(self._getshapepoly(tshape)) |
| 2958 | fc, oc = self._fillcolor, self._pencolor |
| 2959 | screen._drawpoly(stitem, shape, fill=fc, outline=oc, |
| 2960 | width=w, top=True) |
| 2961 | elif ttype == "image": |
| 2962 | stitem = screen._createimage("") |
| 2963 | screen._drawimage(stitem, self._position, tshape) |
| 2964 | elif ttype == "compound": |
| 2965 | stitem = [] |
| 2966 | for element in tshape: |
| 2967 | item = screen._createpoly() |
| 2968 | stitem.append(item) |
| 2969 | stitem = tuple(stitem) |
| 2970 | for item, (poly, fc, oc) in zip(stitem, tshape): |
| 2971 | poly = self._polytrafo(self._getshapepoly(poly, True)) |
| 2972 | screen._drawpoly(item, poly, fill=self._cc(fc), |
| 2973 | outline=self._cc(oc), width=self._outlinewidth, top=True) |
| 2974 | self.stampItems.append(stitem) |
| 2975 | self.undobuffer.push(("stamp", stitem)) |
| 2976 | return stitem |
| 2977 | |
| 2978 | def _clearstamp(self, stampid): |
| 2979 | """does the work for clearstamp() and clearstamps() |
no test coverage detected