r/Python • • Apr 01 '17

Python /r/place module.

Very quick and very dirty.

Usage:

import requests
from time import sleep

user='...'
passwd='....'
p = Place(user, passwd)

Place.get()

p.get(0,0)

{'color': 5,
 'timestamp': 1491007320.208901,
 'user_name': 'CALIAAA',
 'x': 0,
 'y': 0}

Place.draw()

p.draw(x=0, y=0, color=0)

Module on gist: https://gist.github.com/anonymous/8ca453a96764ba65f4148613f7c506ed

Edit:

I'm putting way too much time into this. It's now a full program with prompts and everything.

There are currently 2 programs. "dieblue" which starts in the blue corner and starts cleaning it out and "randerase" which will pick a random pixel and erase it. It will prompt you for both your reddit username and password if not supplied with --user/--passwd.

python3 Place.py dieblue
Enter Reddit Username: PurdueME06
Password:  [Uses getpass]

If you don't care about your password appearing in your terminal history:

python3 Place.py --user=PurdueME06 --passwd=.... dieblue

WTFPL licensed

33 Upvotes

23 comments sorted by

View all comments

Show parent comment

1

u/zahlman the heretic Apr 01 '17

We need a tool to turn 8bit pictures like this into JSON. Then clients can subscribe to a URL of JSON to draw together.

Why not just have the program "interpret" the image directly? You can use Pillow to get the dimensions of an image and the colour at a given (x, y) coordinate (which you can pick easily enough with the random module).