• 大小: 93KB
    文件类型: .zip
    金币: 2
    下载: 1 次
    发布日期: 2021-06-17
  • 语言: Python
  • 标签:

资源简介

洛谷冬日绘板脚本

资源截图

代码片段和文件信息

from PIL import Image
import json
import sys

DataPath=“.\\board.json“
Data2Path=“.\\board2.json“

if len(sys.argv)<4:
    print(“ImageToData.py ImagePath LeftTopX LeftTopY“)
else:
    im = Image.open(sys.argv[1])
    if im.mode!=“P“:
        print(“Index image required.“)
    else:
        img_array=im.load()
        try:
            with open(DataPath‘r‘) as boardjson:
                board=json.load(boardjson)
        except:
            board=[]
        w h = im.size
        for i in range(w):
            for j in range(h):
                board.append([i+int(sys.argv[2])j+int(sys.argv[3])img_array[ij]])
        board = json.dumps(board)
        with open(DataPath‘w+‘) as f:
            f.write(board)
        with open(Data2Path‘w+‘) as f:
            f.write(“var board=“+board)
        print(“finished“)

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2019-01-01 11:37  LuoguPaintBoard-master\
     文件        1062  2019-01-01 11:37  LuoguPaintBoard-master\LICENSE
     文件         369  2019-01-01 11:37  LuoguPaintBoard-master\LuoguPaintBoard.gpl
     文件        1932  2019-01-01 11:37  LuoguPaintBoard-master\README.md
     文件          49  2019-01-01 11:37  LuoguPaintBoard-master\cookies.json
     目录           0  2019-01-01 11:37  LuoguPaintBoard-master\data\
     文件         827  2019-01-01 11:37  LuoguPaintBoard-master\data\ImageToData.py
     文件      249753  2019-01-01 11:37  LuoguPaintBoard-master\data\board.json
     文件      249763  2019-01-01 11:37  LuoguPaintBoard-master\data\board2.json
     文件          40  2019-01-01 11:37  LuoguPaintBoard-master\data\example.bat
     文件       16634  2019-01-01 11:37  LuoguPaintBoard-master\data\example.bmp
     文件          47  2019-01-01 11:37  LuoguPaintBoard-master\loopcount.bat
     文件        1490  2019-01-01 11:37  LuoguPaintBoard-master\preview.html
     文件          27  2019-01-01 11:37  LuoguPaintBoard-master\runcount.bat
     文件          37  2019-01-01 11:37  LuoguPaintBoard-master\runorder.bat
     文件          36  2019-01-01 11:37  LuoguPaintBoard-master\runrand.bat
     目录           0  2019-01-01 11:37  LuoguPaintBoard-master\src\
     文件         728  2019-01-01 11:37  LuoguPaintBoard-master\src\count.py
     文件        1343  2019-01-01 11:37  LuoguPaintBoard-master\src\order.py
     文件        1372  2019-01-01 11:37  LuoguPaintBoard-master\src\rand.py

评论

共有 条评论