函数:image.setColor 设置图片色值

函数功能:设置图片对象指定坐标点的颜色值

函数方法

newimg = image.setColor(img,x,y,color)

参数 类型 必填 说明
img userdata 需要操作的图片对象
x number 需要设置颜色值的图片对象的横坐标
y number 需要设置颜色值的图片对象的纵坐标
color number 需要设置的十六进制颜色值
返回值 类型 说明
newimg userdata/nil 设置后的图片对象,失败返回 nil

函数用例

--函数用例不可直接使用
--相对路径,表示当前流程文件夹下的 1.png 文件
path = "1.png"
--决定路径,文件完整路径
--path = "/sdcard/LuaBox/Projects/流程名称/1.png"
flag = file.isExist(path)
if  flag then
    img,msg = image.load(path)
    if img then
        --将 20,20 点颜色值设置为 0xff00ff
        newimg = image.setColor(img,20,20,0xff00ff)
        if newimg then 
           dialog("设置颜色值成功",5000)
            --获取颜色值
            color = image.getColor(newimg,20,20)
            --转成十进制
            dialog("获取 "..string.format("20,20 颜色值为:0x%X",color),5000)
        else
            dialog("设置颜色值失败")
        end
    else
        dialog("转换失败:"..msg,5000)
    end
else
    dialog("图片不存在",5000)
end

注意事项

  • 目前积木编程函数和触动精灵函数不通用,请仔细查看本手册,此手册中函数仅支持积木编程,不支持触动精灵,同理请勿将触动精灵函数在积木编程运行。
Copyright 北京帮你玩科技有限公司 2022 all right reserved,powered by Gitbook该文章修订时间: 2023-08-09 17:19:31

results matching ""

    No results matching ""