A wrapper for the Discord Python Pixels API.
Project description
DPYPX
A simple wrapper around Python Discord Pixels.
Requires Python 3.7+ (3.x where x >= 7).
Requires pillow and aiohttp from pip.
Example
import dpypx
# Create a client with your token.
client = dpypx.Client('my-auth-token')
# Download and save the canvas.
canvas = await client.get_canvas()
canvas.save('canvas.png')
# And access pixels from it.
print(canvas[4, 10])
# Or just fetch specific pixels.
print(await client.get_pixel(4, 10))
# Draw a pixel.
await client.put_pixel(50, 10, 'cyan')
await client.put_pixel(1, 5, dpypx.Colour.BLURPLE)
await client.put_pixel(100, 4, '93FF00')
await client.put_pixel(44, 0, 0xFF0000)
# Swap two pixels.
await client.swap_pixels((55, 1), (50, 3))
# Close the connection.
await client.close()
Auto-draw
Load an image:
from PIL import Image
im = Image.open('pretty.png')
ad = dpypx.AutoDrawer.load_image(client, (5, 40), im, scale=0.1)
await ad.draw()
To prefer fixing existing pixels to placing new ones:
await ad.draw_and_fix()
By default, this will also loop forever. To exit once the whole image is correct:
await ad.draw_and_fix(forever=False)
You can also manually specify each pixel:
ad = dpypx.AutoDrawer.load(client, '''0
0
3
2
ff0000
00ff00
0000ff
ff0000
00ff00
0000ff''')
await 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.
Logging
To see logs:
import logging
logging.basicConfig(level=logging.INFO)
Too see more logs:
logging.basicConfig(level=logging.DEBUG)
To see fewer logs:
logging.basicConfig(level=logging.WARNING)
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dpypx-0.7.6.tar.gz.
File metadata
- Download URL: dpypx-0.7.6.tar.gz
- Upload date:
- Size: 9.5 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 |
53f19217cd2f066b28d47023541daef2f10a504ad13020fde180b46e20f86b5c
|
|
| MD5 |
5e006f3349a61c5116066a5a86939343
|
|
| BLAKE2b-256 |
c4e7ec64b2ca28b82d14418d0ea69272440ae0fd4fa4a9b97b22ed872f33421f
|
File details
Details for the file dpypx-0.7.6-py3-none-any.whl.
File metadata
- Download URL: dpypx-0.7.6-py3-none-any.whl
- Upload date:
- Size: 10.5 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 |
fe030ab89b0fbb8c725f318cf2fb6734adaf416d34c27ef0464131e447440327
|
|
| MD5 |
4e6df1ffbf8f0864cc94e4ae23f08536
|
|
| BLAKE2b-256 |
064f9003846c242586d2bb01ed37e42dd4b7ef71c9bec26b250cc9147d4d54ac
|