Skip to main content

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)

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''')
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, 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


Download files

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

Source Distribution

pydispix-0.1.1.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

pydispix-0.1.1-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file pydispix-0.1.1.tar.gz.

File metadata

  • Download URL: pydispix-0.1.1.tar.gz
  • Upload date:
  • Size: 7.8 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

Hashes for pydispix-0.1.1.tar.gz
Algorithm Hash digest
SHA256 002939446b48a9197e6ca628064be726da1cc84c15d4c8d21c896d6d474478b6
MD5 f4f3334643527db5e7b56f3948c8db59
BLAKE2b-256 93197c1fa7b61460e9d7e0146e13baad412ce1f0e5db165275681aa3a1ce1683

See more details on using hashes here.

File details

Details for the file pydispix-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pydispix-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.6 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

Hashes for pydispix-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 dcd9a30ebc93b0416d3dfd02b403a876f59a4375113574d72f6e8de1a5017456
MD5 ef3bac5bc97c8b6a07bc30d8f361a586
BLAKE2b-256 2ca9e7f013fa4ab0061791c3a5679f8a16888cd541eebca3583b1024699dbdf1

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