• 大小: 45.99MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-07-17
  • 语言: 其他
  • 标签: JavaScript  

资源简介

js编写的麻将源码,包括服务器源码。配置完后,可在本地运行

资源截图

代码片段和文件信息

#!python
import ossys
from xml.etree import ElementTree
from PIL import Image

def tree_to_dict(tree):
    d = {}
    for index item in enumerate(tree):
        if item.tag == ‘key‘:
            if tree[index+1].tag == ‘string‘:
                d[item.text] = tree[index + 1].text
            elif tree[index + 1].tag == ‘true‘:
                d[item.text] = True
            elif tree[index + 1].tag == ‘false‘:
                d[item.text] = False
            elif tree[index+1].tag == ‘dict‘:
                d[item.text] = tree_to_dict(tree[index+1])
    return d

def gen_png_from_plist(plist_filename png_filename):
    file_path = plist_filename.replace(‘.plist‘ ‘‘)
    big_image = Image.open(png_filename)
    root = ElementTree.fromstring(open(plist_filename ‘r‘).read())
    plist_dict = tree_to_dict(root[0])
    to_list = lambda x: x.replace(‘{‘‘‘).replace(‘}‘‘‘).split(‘‘)
    for kv in plist_dict[‘frames‘].items():
        rectlist = to_list(v[‘frame‘])
        width = int( rectlist[3] if v[‘rotated‘] else rectlist[2] )
        height = int( rectlist[2] if v[‘rotated‘] else rectlist[3] )
        box=( 
            int(rectlist[0])
            int(rectlist[1])
            int(rectlist[0]) + width
            int(rectlist[1]) + height
            )
        sizelist = [ int(x) for x in to_list(v[‘sourceSize‘])]
        rect_on_big = big_image.crop(box)

        if v[‘rotated‘]:
            rect_on_big = rect_on_big.rotate(90)

        result_image = Image.new(‘RGBA‘ sizelist (0000))
        if v[‘rotated‘]:
            result_box=(
                ( sizelist[0] - height )/2
                ( sizelist[1] - width )/2
                ( sizelist[0] + height )/2
                ( sizelist[1] + width )/2
                )
        else:
            result_box=(
                ( sizelist[0] - width )/2
                ( sizelist[1] - height )/2
                ( sizelist[0] + width )/2
                ( sizelist[1] + height )/2
                )
        result_image.paste(rect_on_big result_box mask=0)

        if not os.path.isdir(file_path):
            os.mkdir(file_path)
        outfile = (file_path+‘/‘ + k).replace(‘gift_‘ ‘‘)
        print outfile “generated“
        result_image.save(outfile)

if __name__ == ‘__main__‘:
    filename = sys.argv[1]
    plist_filename = filename + ‘.plist‘
    png_filename = filename + ‘.png‘
    if (os.path.exists(plist_filename) and os.path.exists(png_filename)):
        gen_png_from_plist( plist_filename png_filename )
    else:
        print “make sure you have boith plist and png files in the same directory“

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       1482  2016-12-02 00:32  ddmj_20161230\client\.gitignore

     文件       1594  2016-08-28 22:51  ddmj_20161230\client\assets\anims\angry.anim

     文件         88  2017-01-18 18:24  ddmj_20161230\client\assets\anims\angry.anim.meta

     文件        870  2016-12-25 12:55  ddmj_20161230\client\assets\anims\dingque_tuijian.anim

     文件         88  2017-01-18 18:24  ddmj_20161230\client\assets\anims\dingque_tuijian.anim.meta

     文件        939  2016-08-28 22:52  ddmj_20161230\client\assets\anims\fennu.anim

     文件         88  2017-01-18 18:24  ddmj_20161230\client\assets\anims\fennu.anim.meta

     文件       1601  2016-10-30 19:39  ddmj_20161230\client\assets\anims\guafeng.anim

     文件         88  2017-01-18 18:24  ddmj_20161230\client\assets\anims\guafeng.anim.meta

     文件        616  2016-08-28 22:52  ddmj_20161230\client\assets\anims\han.anim

     文件         88  2017-01-18 18:24  ddmj_20161230\client\assets\anims\han.anim.meta

     文件        618  2016-08-28 22:53  ddmj_20161230\client\assets\anims\happy.anim

     文件         88  2017-01-18 18:24  ddmj_20161230\client\assets\anims\happy.anim.meta

     文件       1597  2016-08-28 22:53  ddmj_20161230\client\assets\anims\huaixiao.anim

     文件         88  2017-01-18 18:24  ddmj_20161230\client\assets\anims\huaixiao.anim.meta

     文件       1258  2016-08-28 22:48  ddmj_20161230\client\assets\anims\jiong.anim

     文件         88  2017-01-18 18:24  ddmj_20161230\client\assets\anims\jiong.anim.meta

     文件       2402  2016-08-28 22:49  ddmj_20161230\client\assets\anims\lihai.anim

     文件         88  2017-01-18 18:24  ddmj_20161230\client\assets\anims\lihai.anim.meta

     文件       2802  2016-12-06 21:00  ddmj_20161230\client\assets\anims\play_gang.anim

     文件         88  2017-01-18 18:24  ddmj_20161230\client\assets\anims\play_gang.anim.meta

     文件       2630  2016-12-08 20:21  ddmj_20161230\client\assets\anims\play_guafeng.anim

     文件         88  2017-01-18 18:24  ddmj_20161230\client\assets\anims\play_guafeng.anim.meta

     文件       2812  2016-12-06 20:38  ddmj_20161230\client\assets\anims\play_hu.anim

     文件         88  2017-01-18 18:24  ddmj_20161230\client\assets\anims\play_hu.anim.meta

     文件       2802  2016-12-08 01:09  ddmj_20161230\client\assets\anims\play_peng.anim

     文件         88  2017-01-18 18:24  ddmj_20161230\client\assets\anims\play_peng.anim.meta

     文件       2783  2016-12-08 20:22  ddmj_20161230\client\assets\anims\play_xiayu.anim

     文件         88  2017-01-18 18:24  ddmj_20161230\client\assets\anims\play_xiayu.anim.meta

     文件       2587  2016-12-08 20:19  ddmj_20161230\client\assets\anims\play_zimo.anim

............此处省略8193个文件信息

评论

共有 条评论