A wrapper for the Discord Python Pixels API.
Project description
PyDisPix
A simple wrapper around Python Discord Pixels.
Requires Python 3.9+ (3.x where x >= 9).
Requires requests
and pillow
from pip.
Example
import pydispix
# Create a client with your token.
client = pydispix.Client('my-auth-token')
# Let pydispix find your token from `TOKEN` environmental variable
client = pydispix.Client()
# Download and save the canvas.
canvas = client.get_canvas()
canvas.save('canvas.png')
# And access pixels from it.
print(canvas[4, 10])
# Or just fetch a specific pixel.
print(client.get_pixel(4, 10))
# Draw a pixel.
client.put_pixel(50, 10, 'cyan')
client.put_pixel(1, 5, pydispix.Color.BLURPLE)
client.put_pixel(100, 4, '93FF00')
client.put_pixel(44, 0, 0xFF0000)
client.put_pixel(8, 54, (255, 255, 255))
Auto-draw
Load an image:
from PIL import Image
im = Image.open('pretty.png')
ad = pydispix.AutoDraw.load_image(client, (5, 40), im, scale=0.1)
ad.draw()
Or specify each pixel:
ad = pydispix.AutoDraw.load(client, '''0
0
3
2
ff0000
00ff00
0000ff
ff0000
00ff00
0000ff''')
ad.draw()
Format of the drawing plan:
- Leftmost X coordinate
- Topmost Y coordinate
- Width
- Height
- Each pixel, left-to-right, top-to-bottom.
Auto-draw will avoid colouring already correct pixels, for efficiency.
You can also run this continually with guard=True
which makes sure that after your image
is drawn, this keeps running to check if it haven't been tampered with, and fixes all non-matching
pixels
ad.draw(guard=True)
Logging
To see logs, you can set the DEBUG
environment variable, which changes the loglevel from logging.INFO
to logging.DEBUG
You can also do this manually by executing:
import logging
logger = logging.getLogger("pydispix")
logger.setLevel(logging.DEBUG)
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 pydispix-0.2.0.tar.gz
.
File metadata
- Download URL: pydispix-0.2.0.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac81a5c3f185b2dae9d20b22a01251ef893bc20b4032d3ccc3df2ce50f73bd61 |
|
MD5 | 31df1357a10c06412cbadf8a7f701498 |
|
BLAKE2b-256 | e574c373a1c8e325c743c7ff1350fb2403baa95dddb1e20dda16153f7e2681e4 |
File details
Details for the file pydispix-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: pydispix-0.2.0-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 022ad21157b4525fb89630aeb12ee5987cab87310162b00f1cf0ac12449a8692 |
|
MD5 | 073b071846a8f95d9b6527f01cf0df62 |
|
BLAKE2b-256 | b02fe6ff7cb213617c620b1a6c92a8b11f46869b5ab463d3522f5e751a0c6924 |