Skip to main content

Allows you to use the PixelPlanet.Fun API

Project description

ppfun

ppfun allows you to use the PixelPlanet.Fun's (hence the name) API in your Python code. I personally didn't come up with any use case besides auto-drawing bots. But you may. Please e-mail me if you come up with any idea, I will truly be interested.

Example code:

# import the library
import ppfun

# create an API object
pp = ppfun.PPFun_api()
# print the list of available canvases
print('---------')
print('Canvases:')
for c in pp.list_canv():
    print(c['title'] + '\t\t' +
          c['description'] + '\t\t' +
          str(c['size']) + 'x' + str(c['size']) + '\t\t' +
          '(' + c['identifier'] + ')')
print('---------')
# get the main canvas (Earth)
canv = pp.get_canv('d')
# print the approximation of the lime color for this canvas
print('Lime color ID: ' + str(canv.approx_color((0, 255, 0))))
# set a pixel at (-1532, -550) and print the cooldown time
canv.set_pixel((-1532, -550), canv.approx_color((0, 255, 0)))
print('Cooldown after setting the pixel: ' + str(canv.remaining_cooldown()))

installation

pip install ppfun

documentation

PPFun_api class

This is where the journey starts. You create a client by creating an instance of this class. The library then fetches some data from the server. It is available through these functions:

  • list_canv() - returns a list of canvas descriptors. Each descriptor is a dictionary that contains the title, description, size and identifier keys
  • get_canv(ident) - returns a canvas object of the canvas with a specific identifier

PPFun_canv class

This class contains all the functions you need to create your masterpiece. Here they are:

  • approx_color(rgb_tuple) - returns a color index that approximates the given color the most
  • set_pixel(pos_tuple, color_index) - places a pixel on the map. Throws an exception on error, returns True on success
  • remaining_cooldown() - returns the remaining cooldown in seconds

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

ppfun-1.0.3.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ppfun-1.0.3-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file ppfun-1.0.3.tar.gz.

File metadata

  • Download URL: ppfun-1.0.3.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

File hashes

Hashes for ppfun-1.0.3.tar.gz
Algorithm Hash digest
SHA256 d3fb9ccca4eff48a4a31d616bb0eb36af14c6dd79fcf88e1877ec9ef93a216f2
MD5 7f838c9bb803db82771b3844de273c62
BLAKE2b-256 b9ea22f849e08d416821bbc31f38ccefa4caa440861e25dc387b5a3e0f003c90

See more details on using hashes here.

File details

Details for the file ppfun-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: ppfun-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

File hashes

Hashes for ppfun-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 8a07c47d86b28e4c897df7f38b672e193dcc97532babddaed71c0d68b0c1084d
MD5 7db23f85f06f3c2752737dd948ab2e60
BLAKE2b-256 5b855af3f97ea427895a4b3ac8f5778bf1b90b6944b9a2bfda8f5626cd9f153f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page