Skip to content

Instantly share code, notes, and snippets.

@onnowhere
onnowhere / image_to_particles.py
Last active May 8, 2022 11:37
[Image to Particles] Quick tool that generates a function that displays particles for an input image using local coordinates. Drop images in the `images` folder in the same directory as the script. You'll also need to `pip install opencv-python`. Edit generation options at the bottom of the file.
import cv2
import os
class ImageToParticle:
def __init__(self, image_file, resolution=(40, 40), scale=0.25, max_size=5, replace_transparent=[], animation=0, commands=[], show_display=False):
self.image_file = image_file # Source file
self.resolution = resolution # Shrinks image to fit within x,y dimensions without changing aspect ratio (1 pixel = 1 particle)
self.scale = scale # Scale the size of image displayed in game
self.max_size = max_size # Maximum particle size, alpha scales this if replace_transparent is not defined
self.replace_transparent = replace_transparent # RGB value to replace 0 alpha with
// Discord all events!
// A quick and dirty fleshing out of the discord.js event listeners (not tested at all!)
// listed here -> https://discord.js.org/#/docs/main/stable/class/Client
// Learn from this, do not just copy it mofo!
//
// Saved to -> https://gist.github.com/koad/316b265a91d933fd1b62dddfcc3ff584
// Last Updated -> Halloween 2022
/*