允许您使用像素星球。有趣美国石油学会
ppfun的Python项目详细描述
ppfun公司
ppfun允许您使用像素星球。有趣在Python代码中使用的(因此得名)API。我个人没有想出除了自动绘图机器人以外的任何用例。但你可以。如果你有任何想法,请发电子邮件给我,我会很感兴趣的。
示例代码:
# import the libraryimportppfun# create an API objectpp=ppfun.PPFun_api()# print the list of available canvasesprint('---------')print('Canvases:')forcinpp.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 canvasprint('Lime color ID: '+str(canv.approx_color((0,255,0))))# set a pixel at (-1532, -550) and print the cooldown timecanv.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()
-返回画布描述符的列表。每个描述符都是一个字典,其中包含title
、description
、size
和identifier
键get_canv(ident)
-返回具有特定标识符的画布对象
PPFun_canv班
这个类包含创建杰作所需的所有函数。它们在这里:
approx_color(rgb_tuple)
-返回最接近给定颜色的颜色索引set_pixel(pos_tuple, color_index)
-在地图上放置一个像素。出错时引发异常,成功时返回Trueremaining_cooldown()
-返回剩余的冷却时间(以秒为单位)
- 项目
标签: