Deutsch   English   

1. The graphics window

 

 

YOU LEARN HERE...

 

import the GPanel library and create a global graphics window with freely selected coordinates.

 

 

EXAMPLES

 

makeGPanel() creates a global graphics window with x- and y-coordinates from 0 to 1.

makeGPanel(xmin, xmax, ymin, ymax) creates a graphics window with user-defined coordinates (floats), i.e. the user can freely define the axes of the coordinate system in the graphics window with these four parameters.

The command line(x1, y1, x2, y2) draws a line from the point (x1, y1) to the point (x2, y2).

Program:

# Gp1a.py
from gpanel import *

makeGPanel()
line(0, 0, 1, 1)
► Copy to clipboard
 

Program:

# Gp1b.py
from gpanel import *

makeGPanel(0, 10, 0, 10)
line(0, 0, 10, 10)
► Copy to clipboard
 

Program: 

# Gp1c.py
from gpanel import *

makeGPanel(0, 20, 0, 20)
line(5, 5, 15, 5)
line(15, 5, 10, 15)
line(5, 5, 10, 15)
► Copy to clipboard
 

 

 

REMEMBER YOU...

 

You can use any whole or decimal numbers as coordinates. Python is case-sensitive. Keywords and commands are written with a lowercase initial letter. Comments are introduced with #.

 

 

TO SOLVE BY YOURSELF

 

1)


Write a program that creates a graphics window with the adjacent coordinates and draws two diagonal lines according to the template.

 

 

2)

Select the same Gpanel window and draw three lines to create a right-angled triangle.