draw_v3.py

Created by polettielio

Created on October 07, 2023

7.7 KB

draw_v3.1 - a script to precisely draw on the screen with the turtle module

Usage

Basic

Execute the main() function and it opens the interface. Every action is sent to the program thanks to key presses.

  • Movements
    • Move on the cardinal axes with the great arrow key.
    • Move relative to your position with alpha, ln for/backwards and exp, log left/right.
    • Change the scale of relative movements with keys 7, 4, 1 (length) and 8, 5, 2 (angle).
    • Enter absolute coordinates and angles with pi and square-root.
  • Pen management
    • Toggle pen with sin.
    • Change the line’s color with cos (presets) and tan (rgb).
    • Change the size with left parenthesis, plus and multiply.
    • Clear the screen and with backspace.
  • Miscellanous
    • Change ticking speed with right parenthesis, minus and divide.
    • Toggle turtle with square (x²).
    • Switch prompt with var (interface).

Note that turtle doesn’t use the ion coordinate system: the origin (0,0) is in the very center of the screen. When dealing with angles, turtle uses degrees and describes 0° as “looking to the right”.

Interface

The drawing area starts blank and fills up 90% of the screen (ion coordinates 0,0 to 320,202). There is a status bar, called the prompt, at the bottom which shows all the user values. There are 3 prompt modes ; switch the shown mode with var.

  • The position prompt logs the absolute coordinates (with turtle origin) and the heading/orientation.
  • The settings prompt logs the relative gaps (pixgap and deggap) alongside the tick speed.
  • The pen prompt logs the current color, the pen state (up/down) and its size/weight.

When you need to enter a value, a specific input-prompt gets showed. You can use the digits, minus and backspace to indicate the value and exe or ok to send. Escape it without making changes to any program-value with divide.


During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.