Return or set the pencolor. Arguments: Four input formats are allowed: - pencolor() Return the current pencolor as color specification string or as a tuple (see example). May be used as input to another color/pencolor/fillcolor/bgcolor
(self, *args)
| 2286 | return self._color(self._pencolor), self._color(self._fillcolor) |
| 2287 | |
| 2288 | def pencolor(self, *args): |
| 2289 | """ Return or set the pencolor. |
| 2290 | |
| 2291 | Arguments: |
| 2292 | Four input formats are allowed: |
| 2293 | - pencolor() |
| 2294 | Return the current pencolor as color specification string or |
| 2295 | as a tuple (see example). May be used as input to another |
| 2296 | color/pencolor/fillcolor/bgcolor call. |
| 2297 | - pencolor(colorstring) |
| 2298 | Set pencolor to colorstring, which is a Tk color |
| 2299 | specification string, such as "red", "yellow", or "#33cc8c". |
| 2300 | - pencolor((r, g, b)) |
| 2301 | Set pencolor to the RGB color represented by the tuple of |
| 2302 | r, g, and b. Each of r, g, and b must be in the range |
| 2303 | 0..colormode, where colormode is either 1.0 or 255 (see |
| 2304 | colormode()). |
| 2305 | - pencolor(r, g, b) |
| 2306 | Set pencolor to the RGB color represented by r, g, and b. |
| 2307 | Each of r, g, and b must be in the range 0..colormode. |
| 2308 | |
| 2309 | If turtleshape is a polygon, the outline of that polygon is drawn |
| 2310 | with the newly set pencolor. |
| 2311 | |
| 2312 | Example (for a Turtle instance named turtle): |
| 2313 | >>> turtle.pencolor('brown') |
| 2314 | >>> turtle.pencolor() |
| 2315 | 'brown' |
| 2316 | >>> colormode(255) |
| 2317 | >>> turtle.pencolor('#32c18f') |
| 2318 | >>> turtle.pencolor() |
| 2319 | (50.0, 193.0, 143.0) |
| 2320 | """ |
| 2321 | if args: |
| 2322 | color = self._colorstr(args) |
| 2323 | if color == self._pencolor: |
| 2324 | return |
| 2325 | self.pen(pencolor=color) |
| 2326 | else: |
| 2327 | return self._color(self._pencolor) |
| 2328 | |
| 2329 | def fillcolor(self, *args): |
| 2330 | """ Return or set the fillcolor. |