A wrapper for the Discord Python Pixels API.

Overview

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)
You might also like...
Volt is yet another discord api wrapper for Python. It supports python 3.8 +

Volt Volt is yet another discord api wrapper for Python. It supports python 3.8 + How to install [Currently Not Supported.] pip install volt.py Speed

Anime-Discord-Bot - Lightweight anime searching Discord bot supported by the AnilistPython library (anilist.co APIv2 wrapper))
An API wrapper for Discord written in Python.

discord.py A modern, easy to use, feature-rich, and async ready API wrapper for Discord written in Python. Key Features Modern Pythonic API using asyn

DiscWrappy - A Python wrapper for the Discord bot API

DiscWrappy - A Python wrapper for the Discord bot API

🚀 A fast, flexible and lightweight Discord API wrapper for Python.
🚀 A fast, flexible and lightweight Discord API wrapper for Python.

Krema A fast, flexible and lightweight Discord API wrapper for Python. Installation Unikorn unikorn add kremayard krema -no-confirmation Pip pip insta

A simple API wrapper for Discord written in Python.

AIOCord This project is work in progress not for production use A simple asynchronous API wrapper around Discord API written in Python. Inspiration Th

Paginator for Dis-Snek Python Discord API wrapper

snek-paginator Paginator for Dis-Snek Python Discord API wrapper Installation: pip install -U snek-paginator Basic Example: from dis_snek.client impo

A modern, easy to use, feature-rich, and async ready API wrapper for Discord written in Python.
A modern, easy to use, feature-rich, and async ready API wrapper for Discord written in Python.

A modern, easy to use, feature-rich, and async ready API wrapper for Discord written in Python. Key Features Modern Pythonic API using async and await

A modern,feature-rich, and async ready API wrapper for Discord written in Python

discord.io A modern, easy to use, feature-rich, and async ready API wrapper for Discord written in Python. Key Features Modern Pythonic API using asyn

Comments
  • Support for transparent pixels

    Support for transparent pixels

    Description

    Transparent pixels in the image will not be drawn. Semi transparent pixels will be rounded to either fully transparent or opaque, because I wasn't exactly sure what to do with semi transparent pixels. I could technically draw a semi transparent pixel by looking at the previous pixel, but that would make draw_and_fix go forever since there isn't really a clear stop condition.

    Implementation

    The grid in AutoDrawer used be a 2D array of Pixels. I modified it to be an 2D array of tuples, each tuple containing a pixel and a boolean value. The boolean determines if the pixel is transparent or not i.e. if it's going to be drawn.

    Test

    I tested it with a few .pngs at scale=1 and it seems to work fine

    opened by Znunu 1
  • Update image filter

    Update image filter

    The image is loaded only once, so LANCZOS filter can be used. See https://pillow.readthedocs.io/en/stable/handbook/concepts.html#filters-comparison-table for details on the filters.

    opened by Theelx 1
Owner
Artemis
Enthusiastic hobbiest coder. Work in Python, web and JS mainly. She/her.
Artemis
Discord-Wrapper - Discord Websocket Wrapper in python

This does not currently work and is in development Discord Websocket Wrapper in

null 3 Oct 25, 2022
Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API

pycord A fork of discord.py. PyCord is a modern, easy to use, feature-rich, and async ready API wrapper for Discord written in Python. Key Features Mo

Pycord Development 2.3k Dec 31, 2022
An asyncio Python wrapper around the Discord API, forked off of Rapptz's Discord.py.

Novus A modern, easy to use, feature-rich, and async ready API wrapper for Discord written in Python. A full fork of Rapptz's Discord.py library, with

Voxel Fox 60 Jan 3, 2023
PyDiscord, a maintained fork of discord.py, is a python wrapper for the Discord API.

discord.py A modern, easy to use, feature-rich, and async ready API wrapper for Discord written in Python. The Future of discord.py Please read the gi

Omkaar 1 Jan 16, 2022
An API wrapper for discord; maintained and improved from discord.py

Fusion.py Documentation What is Fusion.py you might ask; Fusion.py is a Discord.py fork that has most of the good features from most of the big Discor

Senarc Studios 5 Apr 19, 2022
EpikCord.py - This is an API Wrapper for Discord's API for Python

EpikCord.py - This is an API Wrapper for Discord's API for Python! We've decided not to fork discord.py and start completely from scratch for a new, better structuring system!

EpikHost 28 Oct 10, 2022
An API wrapper around Discord API.

NeoCord This project is work in progress not for production use. An asynchronous API wrapper around Discord API written in Python. Features Modern API

Izhar Ahmad 14 Jan 3, 2022
Aws-lambda-requests-wrapper - Request/Response wrapper for AWS Lambda with API Gateway

AWS Lambda Requests Wrapper Request/Response wrapper for AWS Lambda with API Gat

null 1 May 20, 2022
A Python wrapper for discord slash-commands, designed to extend discord.py.

dislash.py An extending library for discord.py that allows to build awesome slash-commands. ⭐

null 173 Dec 19, 2022
A Anything goes Discord bot written in python and uses the wrapper Discord.py

GerardTheWizard A Anything goes Discord bot written in python and uses the wrapper Discord.py What can he do? Allow users to level up through typing,

null 1 May 5, 2022