Catalogue of Posts

Saturday, August 22, 2020

Basic Graphics #2 - Line

Using  -  The Python Computer Language
                Turtle Graphics Library


2.  LINE

FORWARD LINE


SAVE AS
 
>>> import turtle
>>>
>>> Pt = turtle.Turtle()
>>>
>>> Pt.forward(200)
>>>
>>> turtle.done()
>>> 
 
SAVE
 

Pt.forward(number of pixels)
    in the direction of the arrow head     
 
This line is  1  pixel wide

The length of the line is from the start    
    pixel to the pixel at the front point of 
    the arrow head
 
 

BACKWARD LINE


SAVE AS
 
>>> import turtle
>>>
>>> Pt = turtle.Turtle()
>>>
>>> Pt.backward(200)
>>>
>>> turtle.done()
>>> 
 
SAVE


Pt.backward(number of pixels)                                 
    in the opposite direction of the
    arrow head                                               
                                                                      ↓
This line is  1  pixel wide
The length of this line is from the start 
    pixel, to the pixel at the front point of
    the arrow head
 
 
 
FORWARD & BACKWARD LINE

 
SAVE AS
 
>>> import turtle
>>>
>>> Pt = turtle.Turtle()
>>>
>>> Pt.forward(200)
>>> Pt.backward(200)
>>>
>>> turtle.done()
>>> 
 
SAVE


Pt.forward(number of pixels)
    in the direction of the arrow head     
 
Pt.backward(number of pixels)                                 
    in the opposite direction of the
    arrow head                                            
                                                                      
 
 
LINE WIDTH


SAVE AS
 
>>> import turtle
>>>
>>> Pt = turtle.Turtle()
>>>
>>> Pt.width(10)
>>> Pt.forward(200)
>>>
>>> turtle.done()
>>> 

SAVE
 


Pt.width(number of pixels)
 
This line is 10 pixels wide



(c) Katherine Stuart 2020
Dochas Books Film 

No comments:

Post a Comment