Skip to main content

Scatter-Letters

A script to write letters with Matplotlib's scatter plots, create transitions from one plot to the other and build a GIF.

Why?

Because I tought it would be cool.

How?

It uses OpenCV to create a mask from an image, draw a plot filled with random x/y coordinates, and filter the points inside the mask.
Then it uses Matplotlib to draw the plots and transitions and ImageIO to build a gif.

How to use

Install:
pip install scatter_letters

Use:

from scatter_letters import sl
sl.text_to_gif('data_')

All parameters

from scatter_letters import sl

sl.text_to_gif('MAC[MAC]', # text to be converted to gif
            out_path='output', # relative path to save temp files and output
            repeat=True, # repeat first letter at the end
            intensity=40, # more info below*
            rand=True, # True=random points, false= evenly sparced
            gif_name='movie', # name of the output file. -> movie.gif
            n_frames=32, # number of frames in the transition
            bg_color='#ffb400', # background color
            marker='o', # marker style
            marker_color='#2b2300', # marker color 
            marker_size=3, # marker size
            fps=24, # frames per second
            alpha=0.7, # markers opacity
            axis_on=False, # plot spines and grid
            sort_coords=False, # sort points in the transition - options(False, 'x', 'y')
            sort_euclidean=False, # sort by distance (this is very heavy)
            sort_coords_asc=True, # True - sort ascending / False - sort descending
            in_path=None, # for custom input paths
            hold_frames=20,) # hold the complete letter for x frameS

*intensity:  
When plotting random points (rand=True), this is how many times it'll generate 500 points at the start (before applying the mask).  
With randoms, higher intensity means more points.  
When plotting evenly spaced points (rand=False), this is the distance between the points.  
A lower intensity means the points will be closer to each other with even points, so more points are plotted.

Other methods

get_masked_data() - Create a list of random x/y coordinates and uses an image/mask to filter them.

text_to_data() - Transform a text into a list of lists with the previous method.

build_gif() - Uses lists of coordinates to build the scatter plots and the transitions, then save the result in a gif.

Creating gif with custom images

  • Create a directory to store the masks, this will be your in_path argument;
  • Save a .png file with a mask at images/letters
    • The image should be 1000x1000 pixels;
    • The mask should be black with a white background. See the example below;
  • Run text_to_gif() with the name of the images and the parameter in_path pointing to the directory you stored the mask;
  • Files named with more than a character should be refered between brackets;
  • If you want to add just one mask and still use the rest of the letters, you can download the images to the directory you'll be using, add your custom mask, and refer to it with the argument in_path

Example:

- /current_dir
    - /images
        - a.png
        - b.png
        - c.png
        - star.png

text_to_gif('abc[star]', in_path='images')

More

Check out the Jupyter Notebook and the Script at the examples directory for more information.

You can find more images created with this package here

Docs

GitHub
PyPi
Medium Article - Basics of GIFs with Python’s Matplotlib

Metadata

Release files for scatter-letters 0.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for scatter-letters 0.0.7
File Size Uploaded Provenance
scatter_letters-0.0.7.tar.gz 328.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for scatter-letters 0.0.7
File Interpreter ABI Platform
scatter_letters-0.0.7-py3-none-any.whl Python 3 none any Details

Total release size: 705.3 kB

Release files / scatter_letters-0.0.7.tar.gz

Download URL scatter_letters-0.0.7.tar.gz
Size 328.5 kB
Tags Source
SHA-256 checksum
How to use checksums
535bbd201481b49270ea1fe4217b4c345f7b423f3d2dc6f6a70ebc2dfec891a2
BLAKE2b-256 checksum
How to use checksums
cc020ed2df4c22581c1d5206fe189f609d56135a8552a95077fbf153e866d3e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.7

Release files / scatter_letters-0.0.7-py3-none-any.whl

Download URL scatter_letters-0.0.7-py3-none-any.whl
Size 376.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e845e51c54a0e81cf986b2daca1273a8dcd854c6946b7383905914e009227199
BLAKE2b-256 checksum
How to use checksums
7d0f59f0bef77fd7d53fa750cf5e760ed2fe4219d5f1e118df3aa4893001a7ee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.7

Security for scatter-letters 0.0.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page