函数:toTableType 将颜色值 string 转换成 table

函数功能:将颜色值从 string 格式转换成 table 格式

TSLib 版本:仅 v1.2.8 及其以上版本支持

函数方法

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 获取的屏幕宽高相反,获取到的宽度实际为屏幕高度,获取的高度实际为屏幕宽度,其他模拟器获取的屏幕宽高为实际屏幕宽高。

Copyright 北京帮你玩科技有限公司 2023 all right reserved,powered by Gitbook该文章修订时间: 2024-03-06 17:50:18

results matching ""

    No results matching ""