e1841721d4 | ||
---|---|---|
Geolib.py | ||
LICENSE.md | ||
README.md |
README.md
GeoLib
Informations
Presentation
GeoLib is a Python library to draw geometrical shapes on CG screen.
This little library was coded on the calculator directly, so I apolagize for the code quality (such as space, indentation etc). ^^'
Licence
The project are under licence GNU General Public Licence v3.0
Available functions
Circle
An implementation of Bresenham's algorythm
circle(x_center, y_center, radius, color)
Line
It's also Bresenham
line(x_start, y_start, x_end, y_end, color)
Polygon
Allow to draw a polygon on the screen
polygon(*coordinates, **kwargs)
*coordinates
is the coordinates of the verticies of the polygon**kwargs
match to two arguments : the fill pattern and the color
Exemple :
polygone((1, 1), (10, 1), (1, 10), color=(150, 0, 0), fill='full')
will draw a triangle fill with red
Progress bar
It's a funny functions but I don't think it's really useful
progress_bar(x, y, width, height, percentage, color)
Rectangle
It's an optimized version of polygon
for rectangle
rectangle(x, y, width, height, **kwargs)
**kwargs
as it is forpolygon
,**kwargs
correspond to the fill pattern and the color
Arguments
This section will give you some details about tricky arguments
Color
Color correspond to the color of the shape you want to draw. This is a tuple of three elements that corresponding to the RGB. The default value is black.
Some exemples :
color=(0, 0, 0)
: blackcolor=(255, 255, 255)
: whitecolor=(255, 0, 0)
: redcolor=(0, 255, 0)
: greencolor=(0, 0, 255)
: blue
Fill pattern
For some shapes you can decide to fill them with a pattern. The syntax is quiet easy : fill='my_pattern'
(don't forget to quote the choosen pattern)
Now let see the available patterns :
'full'
: will totally fill the shape with the given color'squared'
: will fill one pixel out of two'opaque'
: will erase the background under the shape
Per default, your shape is transparent.