Рубрики

hues

How to hue a turtle

The x-coordinate of this turtle.


Turtle¶

A graphics turtle is a pen that is controlled by direction and movement. The Turtle is a cursor that that you control by moving it left, right, forward, or backward. As it moves, it draws a line of the same color as the Turtle .

Each turtle is attached to a Window upon creation, and this window cannot be change. If the window is closed or deleted, the turtle can no longer be used.

Because of the overhead, this class is not included in the top level of the introcs module. It must be imported separately as part of the introcs.turtle module.

Constructor¶

class introcs.turtle. Turtle ( screen , position = (0, 0) , color = ‘red’ , heading = 0 , speed = 10 ) ¶

An instance represents a graphics turtle.

The turtle is attached to a window on creation, and this window cannot be changed. If the window is closed or deleted, the turtle can no longer be used. Any attempt to call a graphics method after the window is disposed will result in an error.

  • screen ( Window ) – window object that turtle will draw on.
  • position (2D tuple ) – initial turtle position (origin is screen center)
  • color ( RGB , HSV or str ) – initial turtle color (default red)
  • heading ( int or float ) – initial turtle directions (default 0)
  • speed ( int 0..10) – initial turtle speed (default 10)


Mutable Attributes¶

Turtle. heading ¶

The heading of this turtle in degrees.

Heading is measured counter clockwise from due east.

Invariant: Value must be a float

The animation speed of this turtle.

The speed is an integer from 0 to 10. Speeds from 1 to 10 enforce increasingly faster animation of line drawing and cursor updates. Value 1 is the slowest speed while 10 is the fastest speed. Roughly, speed 1 draws 1 pixel per step, while speed 10 draws an entire line in a single step.

Speed 0 is special. Speed 0 means that no animation takes place at all. The drawing commands will be remembered, but not shown on the screen. To display the drawing, you must call the method flush() . When that method is called, all of the drawing commands will be displayed instantly. This is useful for fast drawing.

If the speed is currently 0, changing the speed will immediately flush any existing drawing commands.

Invariant: Value must be an int in the range 0..10.

The color of this turtle.

All subsequent draw commands (forward/back) draw using this color. If the color changes, it only affects future draw commands, not past ones.

Invariant: Value must be either an additive color model (e.g. RGB or HSV) or string representing a color name or a web color (e.g. ‘#f3CC02’ ).

The stroke width of this turtle.

By default, the turtle draws lines that are one pixel wide. Changing this value will increase (or decrease, if your implementation supports sub-pixel graphics) the stroke width.

Invariant: Value must be either a positive float

The dash pattern of this turtle.

A dash pattern is a tuple of integers that specifes the dash in pixels. Only odd values of the pattern are drawn. For example, if the pattern is (10,10), the turtle will draw 10 pixels, and then stop drawing for 10 pixels. After 20 pixels that patterns repeat. Similarly (10,5,5,10) will draw for 10 pixels, stop for 5 pixels, draw for 10 pixels and the stop for 5 pixels before repeating.

If this value is None , the line will be solid.

Invariant: Value must be None or a non-empty tuple of positive integers.

Whether the turtle’s icon is visible.

Drawing commands will still work while the turtle icon is hidden. There will just be no indication of the turtle’s current location on the screen.

Invariant: Value must be a bool

Whether the turtle is in draw mode.

All drawing calls are active if an only if this mode is True

Invariant: Value must be a bool


Rainbow Spiral Rainbow Spiral

02/25/2019 02/25/2019 | J & J Coding Adventure J & J Coding Adventure | 0 Comment | 4:05 pm

This is an extension to previous spiral project https://pythonturtle.academy/spiral/. Make the spiral more beautiful by setting colors gradually from hue value 0 to hue value 1.

Massive Chasing Game (with Source Code) Massive Chasing Game (with Source Code)

02/25/2019 02/25/2019 | J & J Coding Adventure J & J Coding Adventure | 0 Comment | 3:55 pm

In this Python Turtle project, you are going create a fun and beautiful animation. First, you are going to create a list of 100 turtles and put them into random

Rainbow Colored Tree with Python Turtle (with Solution) Rainbow Colored Tree with Python Turtle (with Solution)

02/25/2019 02/25/2019 | J & J Coding Adventure J & J Coding Adventure | 0 Comment | 2:35 am

In this python turtle project, you are going to draw a beautifully colored tree with recursion. Related Projects: Tree Rainbow Colored Tree Animation Solution

Colin Wynn
the authorColin Wynn

Leave a Reply