函数:ts.img.loadFile 从图片创建颜色表(仅支持 iOS)

函数名称:创建颜色表

函数功能:从图片文件创建颜色表

函数方法

color = ts.img.loadFile(imgPath)

参数 类型 必填 说明
imgPath string 图片路径
返回值 类型 说明
color table 颜色表

函数用例

local ts = require("ts")
snapshot("test_1.png", 0, 0, 200, 200)
ss = ts.img.loadFile(userPath().."/res/test_1.png")--不支持相对路径
--[[x、y 为颜色表中颜色值的位置
返回值为 ss[y][x].color,如果想获取 x、y 的值需要转换 x、y 的值
屏幕的(0,0)点坐标相当于为颜色表中的(1,1)点坐标
返回值中颜色表的颜色值为屏幕(10,0)点坐标的颜色值
]]
dialog(ss[1][11].color,3)
--将 color 转换成十六进制颜色值
dialog(string.format("颜色值为:0x%X",ss[1][11].color),3)

注意事项

  • 图片颜色表中颜色值的位置与实际位置坐标相反,需要转换下 x、y 的值。
Copyright 北京帮你玩科技有限公司 2023 all right reserved,powered by Gitbook该文章修订时间: 2024-03-06 17:50:18

results matching ""

    No results matching ""