local imgui = require 'imgui'
local speed = imgui.ImInt(1)
local rb_line_size = imgui.ImInt(-50)
imgui.Process = true
function imgui.OnDrawFrame()
imgui.SetNextWindowSize(imgui.ImVec2(500, 180), main_window_state, imgui.Cond.FirstUseEver)
if not window_pos then
ScreenX, ScreenY = getScreenResolution()
imgui.SetNextWindowPos(imgui.ImVec2(0, 0), imgui.Cond.FirsUseEver, imgui.ImVec2(0.5, 0.5))
window_pos = true
end
imgui.Begin('##Window', main_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse + imgui.WindowFlags.NoScrollbar + imgui.WindowFlags.NoTitleBar)
imgui.Text('Line 1')
rainbow_line(250, 50)
imgui.Text('Line 2')
rainbow_line(500, 10)
imgui.SliderInt("rb_line_size", rb_line_size, -1000, 1000)
imgui.SliderInt("Speed", speed, 0, 10)
static_rainbow_line(250, 10)
imgui.End()
end
function join_argb(a, r, g, b) -- by FYP
local argb = b -- b
argb = bit.bor(argb, bit.lshift(g, 8)) -- g
argb = bit.bor(argb, bit.lshift(r, 16)) -- r
argb = bit.bor(argb, bit.lshift(a, 24)) -- a
return argb
end
function rainbow(speed, alpha, offset) -- by rraggerr
local clock = os.clock() + offset
local r = math.floor(math.sin(clock * speed) * 127 + 128)
local g = math.floor(math.sin(clock * speed + 2) * 127 + 128)
local b = math.floor(math.sin(clock * speed + 4) * 127 + 128)
return r,g,b,alpha
end
function rainbow_line(distance, size) -- by Fomikus
local op = imgui.GetCursorPos()
local p = imgui.GetCursorScreenPos()
for i = 0, distance do
r, g, b, a = rainbow(speed.v, 255, i / rb_line_size.v)
imgui.GetWindowDrawList():AddRectFilled(imgui.ImVec2(p.x + i, p.y), imgui.ImVec2(p.x + i + 1, p.y + size), join_argb(a, r, g, b))
end
imgui.SetCursorPos(imgui.ImVec2(op.x, op.y + size + imgui.GetStyle().ItemSpacing.y))
end
function static_rainbow_line(distance, size) -- by Fomikus
local op = imgui.GetCursorPos()
local p = imgui.GetCursorScreenPos()
for i = 0, distance do
r, g, b, a = rainbow_v2(speed.v, 255, i / rb_line_size.v)
imgui.GetWindowDrawList():AddRectFilled(imgui.ImVec2(p.x + i, p.y), imgui.ImVec2(p.x + i + 1, p.y + size), join_argb(a, r, g, b))
end
imgui.SetCursorPos(imgui.ImVec2(op.x, op.y + size + imgui.GetStyle().ItemSpacing.y))
end
function rainbow_v2(speed, alpha, offset) -- by rraggerr
local r = math.floor(math.sin(offset * speed) * 127 + 128)
local g = math.floor(math.sin(offset * speed + 2) * 127 + 128)
local b = math.floor(math.sin(offset * speed + 4) * 127 + 128)
return r,g,b,alpha
end