Skip to main content

允许您使用 PixelPlanet.Fun API

项目描述

ppfun

ppfun 允许您在 Python 代码中使用 PixelPlanet.Fun 的(因此得名)API。除了自动绘图机器人,我个人没有想出任何用例。但你可以。如果您有任何想法,请给我发电子邮件,我真的很感兴趣。

示例代码:

# 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()))

安装

pip install ppfun

文件

PPFun_api 类

这就是旅程的开始。您可以通过创建此类的实例来创建客户端。然后库从服务器获取一些数据。它可通过以下功能获得:

  • list_canv()- 返回画布描述符列表。每个描述符都是一个包含titledescription和键size的字典identifier
  • get_canv(ident)- 返回具有特定标识符的画布的画布对象

PPFun_canv 类

此类包含创建杰作所需的所有功能。他们来了:

  • approx_color(rgb_tuple)- 返回最接近给定颜色的颜色索引
  • set_pixel(pos_tuple, color_index)- 在地图上放置一个像素。出错时抛出异常,成功时返回 True
  • remaining_cooldown()- 以秒为单位返回剩余的冷却时间

项目详情


下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。

源分布

ppfun-1.0.5.tar.gz (3.6 kB 查看哈希

已上传 source

内置分布

ppfun-1.0.5-py3-none-any.whl (4.1 kB 查看哈希

已上传 py3