|
RGB 渐变基本实现,精度为 1 色度
本帖最后由 AndroidOL 于 2014-10-12 15:33 编辑
请麻烦测试以下脚本
目前存在的问题:
由于 Logitech Gaming Software 不提供多线程支持,无法检测结束条件,目前正在查找解决方案
关闭脚本的方式:
在脚本编辑器中按下 Ctrl + S 保存脚本或退出 Logitech Gaming Software,系统将重置脚本并停止死循环。
- function OnEvent(event, arg)
- if (event == "G_PRESSED" and arg == 1) then
- colorList = {}
- table.insert(colorList, {
- Name = "#FF1B1B",
- Red = 255,
- Green = 27,
- Blue = 27
- })
- table.insert(colorList, {
- Name = "#FF761B",
- Red = 255,
- Green = 118,
- Blue = 27
- })
- table.insert(colorList, {
- Name = "#FFA41B",
- Red = 255,
- Green = 164,
- Blue = 27
- })
- table.insert(colorList, {
- Name = "#FFD21B",
- Red = 255,
- Green = 210,
- Blue = 27
- })
- table.insert(colorList, {
- Name = "#FEFF1B",
- Red = 254,
- Green = 255,
- Blue = 27
- })
- table.insert(colorList, {
- Name = "#B1E819",
- Red = 177,
- Green = 232,
- Blue = 25
- })
- table.insert(colorList, {
- Name = "#17D21B",
- Red = 23,
- Green = 210,
- Blue = 27
- })
- table.insert(colorList, {
- Name = "#17A2D2",
- Red = 23,
- Green = 162,
- Blue = 210
- })
- table.insert(colorList, {
- Name = "#1763D2",
- Red = 23,
- Green = 99,
- Blue = 210
- })
- table.insert(colorList, {
- Name = "#3817D2",
- Red = 56,
- Green = 23,
- Blue = 210
- })
- table.insert(colorList, {
- Name = "#9717D2",
- Red = 151,
- Green = 23,
- Blue = 210
- })
- table.insert(colorList, {
- Name = "#DE1888",
- Red = 222,
- Green = 24,
- Blue = 136
- })
- colorTemp = {
- ["Red"] = 255,
- ["Green"] = 255,
- ["Blue"] = 255
- }
- SetBacklightColor(255, 255, 255)
- while true do
- for loop = 1, #colorList do
- OutputLogMessage("Color-No." .. loop .. ":\t" .. colorList[loop].Name .. "\n")
- r = colorTemp.Red
- g = colorTemp.Green
- b = colorTemp.Blue
- rIV = (colorList[loop].Red - r) / 50 - ((colorList[loop].Red - r) / 50) % 0.01
- gIV = (colorList[loop].Green - g) / 50 - ((colorList[loop].Green - g) / 50) % 0.01
- bIV = (colorList[loop].Blue - b) / 50 - ((colorList[loop].Blue - b) / 50) % 0.01
- OutputLogMessage("rIV.Red: " .. rIV .. ",\tgIV: " .. gIV .. ",\tbIV: " .. bIV .. "\n")
- for loopColor = 1, 50 do
- colorTemp.Red = colorTemp.Red + rIV
- colorTemp.Green = colorTemp.Green + gIV
- colorTemp.Blue = colorTemp.Blue + bIV
- SetBacklightColor(colorTemp.Red, colorTemp.Green, colorTemp.Blue)
- --OutputLogMessage("colorTemp.Red: " .. colorTemp.Red .. ",\tcolorTemp.Green: " .. colorTemp.Green .. ",\tcolorTemp.Blue: " .. colorTemp.Blue .. "\n")
- Sleep(50)
- --if (event == "G_PRESSED" and arg == 6) then
- --break
- --end
- end
- colorTemp.Red = math.ceil(colorTemp.Red)
- colorTemp.Green = math.ceil(colorTemp.Green)
- colorTemp.Blue = math.ceil(colorTemp.Blue)
- --OutputLogMessage("Loop: " .. loop .. ". Target. To. R: " .. colorTemp.Red .. "/G: " .. colorTemp.Green .. "/B: " .. colorTemp.Blue .. "\n")
- --OutputLogMessage("Loop: " .. loop .. ". Target. To. R: " .. colorList[loop].Red .. "/G: " .. colorList[loop].Green .. "/B: " .. colorList[loop].Blue .. "\n\n")
- colorTemp.Red = colorList[loop].Red
- colorTemp.Green = colorList[loop].Green
- colorTemp.Blue = colorList[loop].Blue
- SetBacklightColor(colorTemp.Red, colorTemp.Green, colorTemp.Blue)
- end
- end
- end
- end
复制代码 |
|