GeoLib/README.md

82 lines
2.0 KiB
Markdown
Raw Permalink Normal View History

2021-07-14 09:56:32 +02:00
# GeoLib
## Informations
### Presentation
GeoLib is a Python library to draw geometrical shapes on CG screen.
2021-07-14 10:22:35 +02:00
This little library was coded on the calculator directly, so I apologize 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 for `polygon`, `**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)` : black
- `color=(255, 255, 255)` : white
- `color=(255, 0, 0)` : red
- `color=(0, 255, 0)` : green
- `color=(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.