Skip to main content

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)

You can draw rectangle with draw_rect(row, col, rows=1, cols=1, color="black").

  • row: row of the left up corner of the rectangle
  • col: column of the left up corner of the rectangle
  • rows: length of the rectangle
  • cols: width of the rectangle
  • color: line color

You 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 rectangle
  • col: column of the left up corner of the rectangle
  • rows: length of the rectangle
  • cols: width of the rectangle
  • color: line color
  • cover: if cover the text on it

You can clear rectangle with clear_rect(row, col, rows=1, cols=1, color="white").

  • row: row of the left up corner of the rectangle
  • col: column of the left up corner of the rectangle
  • rows: length of the rectangle
  • cols: width of the rectangle
  • color: line color

You can draw text with draw_text(row, col, text, color="black", font=("Times", 24)).

  • row: row of the text
  • col: column of text
  • text: text
  • color: text color
  • font: text font

You can draw line with draw_line(from_row, from_col, to_row, to_col, color="black") .

  • from_row: row of start point
  • from_col: column of start point
  • to_row: row of end point
  • to_col: column of end point
  • color: 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 speed
  • delay(time): set the delay time(ms)
  • pensize(pensize): set the pensize
  • begin_hide(): hide the following drawing animation
  • end_hide(): end of the hiding
  • hold(): don't close the window after the drawing

Examples

There is an example in the example directory.

The converted gif is:

example

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rabit-0.3.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

rabit-0.3-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file rabit-0.3.tar.gz.

File metadata

  • Download URL: rabit-0.3.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.0 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.7.0

File hashes

Hashes for rabit-0.3.tar.gz
Algorithm Hash digest
SHA256 00b36a6ce69d1835c3aa731ad82759ff51d04093838695edeb6e122338e82112
MD5 bc610cc57b66958447f8713e637596d8
BLAKE2b-256 6c846ed5962c99d12d3f608cefd20c5815e3fc0f6c7bcea3584d12eceebb1fa2

See more details on using hashes here.

File details

Details for the file rabit-0.3-py3-none-any.whl.

File metadata

  • Download URL: rabit-0.3-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.0 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.7.0

File hashes

Hashes for rabit-0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 29f0bcbaa674c84e84e3587324afaba40e8a1c5c8eeca1231a08e2e984afdcc4
MD5 a6169ec875872f04b59043480c590625
BLAKE2b-256 a22e60f88430a4ef9e46b8cea09baaa98bdb27ea2c6449db1da995451cc2f79d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page