This project implements a simple API of turtle to draw line, rectangle, circle, text and convert the process into gif.
Project description
Rabit
This project implements a simple API of turtle to draw line, rectangle, circle, text and convert the process into gif.
Install
- Install the package.
pip3 install rabit
- Install
python-tk
.
Usage
Rabit splits the drawing board into grids x grids. To create a Rabit object, you should choose the grids (in a row/column) you want to split and the size(default is 600) of drawing board.
import rabit
# The first argument is the number of grids in a row/column.
# The second argument is the size of the drawing board.
rabit = rabit.Rabit(11, 600)
Yuu can draw rectangle with draw_rect(row, col, rows=1, cols=1, color="black")
.
row
: row of the left up corner of the rectanglecol
: column of the left up corner of the rectanglerows
: length of the rectanglecols
: width of the rectanglecolor
: line color
Yuu can paint rectangle with paint_rect(row, col, rows=1, cols=1, color="black", cover=Flase)
.
row
: row of the left up corner of the rectanglecol
: column of the left up corner of the rectanglerows
: length of the rectanglecols
: width of the rectanglecolor
: line colorcover
: if cover the text on it
Yuu can draw text with draw_text(row, col, text, color="black", font=("Times", 24))
.
row
: row of the textcol
: column of texttext
: textcolor
: text colorfont
: text font
Yuu can draw line with draw_line(from_row, from_col, to_row, to_col, color="black")
.
from_row
: row of start pointfrom_col
: column of start pointto_row
: row of end pointto_col
: column of end pointcolor
: line color
You can convert the drawing process into gif with convert2gif(func, fps_for_eps, fps_for_gif)
.The conversion can split into two steps:
- Capturing pictures at a certain rate while drawing.
- convert all pictures(.eps) into a gif at a certain FPS by
imageio
.
import rabit
def your_draw_function():
...
# The first argument is the name of your draw function.
# The second argument is the FPS(or rate) of the capturing process.
# The third argument is the FPS of the final gif.
rabit.convert2gif(your_draw_function, 10, 5)
There are other functions you can use:
speed(speed)
: set the drawing speedpensize(pensize)
: set the pensizebegin_hide()
: hide the following drawing animationend_hide()
: end of the hidinghold()
: don't close the window after the drawing
Examples
There is an example in the example directory.
The converted gif is:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file rabit-0.2.tar.gz
.
File metadata
- Download URL: rabit-0.2.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.21.0 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b4b1e922e60d5756700503a8fcbf076535b12903ccd8c60c7a7f7d1c07ae3a77 |
|
MD5 | ac050801782dad78ecbb7599b667ce1d |
|
BLAKE2b-256 | 7d4e3f431b68392bbc4328c79d2179a8a4118a13392dc83a26cad76b2522092c |
File details
Details for the file rabit-0.2-py3-none-any.whl
.
File metadata
- Download URL: rabit-0.2-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.21.0 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6539b4c14427f427982a8fa1db38072034b8d2534fed93f0790810fc968f79af |
|
MD5 | 2ea29772c2488eb9d8b6212d66ff0960 |
|
BLAKE2b-256 | a995675aca13b37f7be727df2d9843ed101c9c44ab87614747f5899ffe8fe035 |