函数:toTableType 将颜色值 string 转换成 table
函数分类:TSLib(内置,无需下载)
TSLib 版本:仅支持 v1.2.8 及其以上
函数功能:将颜色值从 string 格式转换成 table 格式
函数方法
tb = toTableType(color,posandcolor,x,y)
| 参数 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
| color | number | 是 | — | 基准色,十六进制数字 |
| posandcolor | string | 是 | — | 参考色 |
| x | number | 否 | 0 | 基准点横坐标 |
| y | number | 否 | 0 | 基准点纵坐标 |
| 返回值 | 类型 | 说明 |
|---|---|---|
| tb | table | 转换后的结果 |
函数用例
require("TSLib")
local ts = require("ts")
local json = ts.json
local tb = toTableType(0xff5722,"-8|-4|0xfce6a8,6|-2|0xff5722",53,170)
--把 table 转换成 json 字符串
local jsonstring = json.encode(tb)
dialog(jsonstring, 0)
--返回值为 [[53,170,"0xff5722"],[45,166,"0xfce6a8"],[59,168,"0xff5722"]]
注意事项
- 雷电 9 系统模拟器分辨率为平板版时使用函数:getScreenSize 获取的屏幕宽高相反,获取到的宽度实际为屏幕高度,获取的高度实际为屏幕宽度,其他模拟器获取的屏幕宽高为实际屏幕宽高。