Roblox backend: recolored draw lists (same vertex positions, a few vertices' colour / uv changed, e.g. hover) skip HashTiles: CompareDrawList 4 lists them, PatchDrawList gives those primitives their real hashes (PrimHash / FlatTileHash) and redraws just their tiles, leaving the tiles exactly as the full path would; t_recolor_pixels (incremental vs forced, also parallel) in check_all
This commit is contained in:
1 parent
951d18fda2
commit
cef7a1209e
4 files changed
+249
-17
No files matched your search
@@ -170,7 +170,8 @@ function M.DestroyTiles(BackendData)
|
||||
end
|
||||
|
||||
-- Snapshot compared exactly with the next frame's list: 1 = identical (only restack), 2 = moved by whole pixels
|
||||
-- (only move the layers), 0 = changed. Per command: clip (4 f64), ElemCount, IdxOffset, VtxOffset (u32), tex id
|
||||
-- (only move the layers), 3 = moved with drifted vertices, 4 = same positions, a few vertices' uv / colour changed
|
||||
-- (both list those in Drift), 0 = changed. Per command: clip (4 f64), ElemCount, IdxOffset, VtxOffset (u32), tex id
|
||||
-- (f64), kind (u8), unclipped (u8), bounds of its primitives (4 x i32).
|
||||
local CMD_STRIDE = 70
|
||||
|
||||
@@ -291,17 +292,24 @@ function M.CompareDrawList(set, draw_list, ox, oy, ScreenWidth, ScreenHeight)
|
||||
-- translation from the first vertex: whole pixels only, and only with DisplayPos at 0 (so it stays exact)
|
||||
local dx, dy = readf64(vb, 0) - readf64(sv, 0), readf64(vb, 8) - readf64(sv, 8)
|
||||
if dx ~= dx or dy ~= dy then return 0 end
|
||||
local nd = 0
|
||||
if dx == 0 and dy == 0 then
|
||||
-- per vertex: x y u v as f64s + col, not readstring == (that allocated 2 vertex-buffer strings per list per
|
||||
-- frame: GC spikes) or 9 u32s (3x slower). Equal f64s have equal bits except +-0: their sign words decide.
|
||||
-- Same position, other uv / colour (hover, a changed colour): listed ("recolored"), up to MAX_DRIFT.
|
||||
for v = 0, nv - VTX_STRIDE, VTX_STRIDE do
|
||||
local x, y, u, w = readf64(vb, v), readf64(vb, v + 8), readf64(vb, v + 16), readf64(vb, v + 24)
|
||||
if x ~= readf64(sv, v) or y ~= readf64(sv, v + 8) or u ~= readf64(sv, v + 16)
|
||||
or w ~= readf64(sv, v + 24) or readu32(vb, v + 32) ~= readu32(sv, v + 32) then
|
||||
if x ~= readf64(sv, v) or y ~= readf64(sv, v + 8) then return 0 end
|
||||
if (x == 0 or y == 0)
|
||||
and (readu32(vb, v + 4) ~= readu32(sv, v + 4) or readu32(vb, v + 12) ~= readu32(sv, v + 12)) then
|
||||
return 0
|
||||
end
|
||||
if x == 0 or y == 0 or u == 0 or w == 0 then
|
||||
for p = v + 4, v + 28, 8 do if readu32(vb, p) ~= readu32(sv, p) then return 0 end end
|
||||
if u ~= readf64(sv, v + 16) or w ~= readf64(sv, v + 24) or readu32(vb, v + 32) ~= readu32(sv, v + 32)
|
||||
or ((u == 0 or w == 0)
|
||||
and (readu32(vb, v + 20) ~= readu32(sv, v + 20) or readu32(vb, v + 28) ~= readu32(sv, v + 28))) then
|
||||
if nd >= MAX_DRIFT then return 0 end
|
||||
nd += 1
|
||||
Drift[nd] = v
|
||||
end
|
||||
end
|
||||
else
|
||||
@@ -361,7 +369,9 @@ function M.CompareDrawList(set, draw_list, ox, oy, ScreenWidth, ScreenHeight)
|
||||
or draw_list._ContentClipY0 ~= set.SnapContentY0 or draw_list._ContentClipX1 ~= set.SnapContentX1
|
||||
or draw_list._ContentClipY1 ~= set.SnapContentY1 or draw_list._ScrollOriginX ~= set.SnapScrollX
|
||||
or draw_list._ScrollOriginY ~= set.SnapScrollY) then return 0 end
|
||||
return 1
|
||||
if nd == 0 then return 1 end
|
||||
M.DriftCount = nd
|
||||
return 4, 0, 0
|
||||
end
|
||||
if set.SnapHasContent and not (ShiftedExact(set.SnapContentX0, dx, draw_list._ContentClipX0)
|
||||
and ShiftedExact(set.SnapContentY0, dy, draw_list._ContentClipY0)
|
||||
@@ -372,7 +382,7 @@ function M.CompareDrawList(set, draw_list, ox, oy, ScreenWidth, ScreenHeight)
|
||||
-- vertices off the exact shift ("drift": trig-generated ones round differently, often when a coordinate crosses a
|
||||
-- power of two) are listed. All their floor / ceil / ceil(- 0.5) (CollectPrims' bounds) shifted: 3, only the tiles
|
||||
-- of their primitives change; else 0 (the full path still gets the list: tile hashes don't see an ulp)
|
||||
local nd, consistent = 0, true
|
||||
local consistent = true
|
||||
for v = 0, nv - VTX_STRIDE, VTX_STRIDE do
|
||||
if readf64(vb, v + 16) ~= readf64(sv, v + 16) or readf64(vb, v + 24) ~= readf64(sv, v + 24)
|
||||
or readu32(vb, v + 32) ~= readu32(sv, v + 32) then return 0 end
|
||||
|
||||
+86
-10
@@ -75,6 +75,54 @@ end
|
||||
-- their hashes get DriftMark* (new every frame) added, so their tiles are redrawn even when the hash doesn't see the ulp
|
||||
local DriftSet, DriftOn, DriftMark1, DriftMark2 = table.create(4096, false), false, 0, 0
|
||||
|
||||
-- One primitive's HashTiles entry hash, for PatchDrawList (the same math as HashTiles' inlined copy: keep both equal).
|
||||
-- Returns h1, h2 and the flat signature (>= 0: a flat rect, whose per-tile hash is FlatTileHash's)
|
||||
@native
|
||||
local function PrimHash(p, lx0, ly0, ox, oy)
|
||||
local vbuf, va, vd, tex_id = PrimVtxBuffer[p], PrimA[p], PrimD[p], PrimTexId[p]
|
||||
if PrimFlat[p] then
|
||||
local RectColor, RectUV = readu32(vbuf, va + 32), readf64(vbuf, va + 16) * 8192 + readf64(vbuf, va + 24)
|
||||
return 0, 0, ((RectColor * 8191 + RectUV * 4096) % P1 * 64 + tex_id) % P1
|
||||
end
|
||||
local cx0, cy0, cx1, cy1 = PrimBoundsX0[p] - lx0, PrimBoundsY0[p] - ly0, PrimBoundsX1[p] - lx0,
|
||||
PrimBoundsY1[p] - ly0
|
||||
local gk, v2, v3, nv = PrimGradient[p], PrimC[p], PrimB[p], 3
|
||||
local g = gk or 0
|
||||
local h1 = (((cx0 * 8191 + cy0) * 8191 + cx1) * 4 + g) % P1
|
||||
local h2 = (((cy1 * 8191 + cx1) * 8191 + cy0 + tex_id) * 4 + g) % P2
|
||||
local vax, vay = lx0 + ox, ly0 + oy
|
||||
if vd then
|
||||
nv = gk == 3 and 4 or 2
|
||||
else
|
||||
v2, v3 = v3, v2
|
||||
end
|
||||
local v = va
|
||||
for k = 1, nv do
|
||||
if k == 2 then v = v2 elseif k == 3 then v = v3 elseif k == 4 then v = vd end
|
||||
local x, y = readf64(vbuf, v) - vax, readf64(vbuf, v + 8) - vay
|
||||
local uv = readf64(vbuf, v + 16) * 8192 + readf64(vbuf, v + 24)
|
||||
local c = readu32(vbuf, v + 32)
|
||||
h1 = (h1 * 48271 + (x * 4096 + y) * 31 + uv * 4096 + c) % P1
|
||||
h2 = (h2 * 16807 + (y * 4093 + x) * 17 + uv * 65521 + c * 3) % P2
|
||||
end
|
||||
return h1, h2, -1
|
||||
end
|
||||
|
||||
-- A flat rect's hash in tile (tx, ty) (HashTiles' per-tile flat hash)
|
||||
@native
|
||||
local function FlatTileHash(p, lx0, ly0, tx, ty)
|
||||
local vbuf, va, tex_id = PrimVtxBuffer[p], PrimA[p], PrimTexId[p]
|
||||
local RectColor, RectUV = readu32(vbuf, va + 32), readf64(vbuf, va + 16) * 8192 + readf64(vbuf, va + 24)
|
||||
local cx0, cy0, cx1, cy1 = PrimBoundsX0[p] - lx0, PrimBoundsY0[p] - ly0, PrimBoundsX1[p] - lx0,
|
||||
PrimBoundsY1[p] - ly0
|
||||
local px0, py0 = tx * TILE, ty * TILE
|
||||
local ix0, iy0 = max(cx0 - px0, 0), max(cy0 - py0, 0)
|
||||
local ix1, iy1 = min(cx1 - px0, TILE), min(cy1 - py0, TILE)
|
||||
local r = ((ix0 * 131 + iy0) * 131 + ix1) * 131 + iy1
|
||||
return ((r * 48271 + RectColor) % P1 * 48271 + RectUV * 4096 + 7) % P1,
|
||||
((r * 16807 + RectColor + tex_id) % P2 * 16807 + RectUV * 65521 + 11) % P2
|
||||
end
|
||||
|
||||
-- HashTiles scratch, per touched tile (slot = its index in layer.Touched): tile key -> slot, its list, count, hashes
|
||||
local KeySlot, SlotCount, SlotHash1, SlotHash2 = {}, {}, {}, {}
|
||||
local SlotList, SlotListHash1, SlotListHash2, SlotListFlat = {}, {}, {}, {}
|
||||
@@ -797,16 +845,20 @@ local function LayerOrigin(draw_list, kind, ox, oy)
|
||||
return floor(draw_list._ScrollOriginX - ox), floor(draw_list._ScrollOriginY - oy)
|
||||
end
|
||||
|
||||
local PatchLayers, PatchKeys, PatchPrim = {}, {}, {}
|
||||
local PatchLayers, PatchKeys, PatchPrim, PatchH1, PatchH2, PatchSig = {}, {}, {}, {}, {}, {}
|
||||
|
||||
-- CompareDrawList 3: moved by whole pixels, but a few vertices drifted off the exact shift (same bounds). CollectPrims
|
||||
-- ran and gave the primitive sequence the tile lists were built from: the lists stay (indices moved to this frame's)
|
||||
-- and every tile keeps its pixels, except those with a primitive using a drifted vertex: those entries' hashes change
|
||||
-- (DriftMark), so the tile redraws just them. Changes nothing when it returns false (the caller takes the full path).
|
||||
-- recolor (CompareDrawList 4: not moved, a few vertices' uv / colour changed): the same, but those primitives get
|
||||
-- their real hashes (PrimHash, flat rects too), so the tiles end up exactly as HashTiles + DrawLayer would leave them.
|
||||
-- Their kind must be the same (so the same bounds and tiles; the other primitives' entries are equal by construction).
|
||||
@native
|
||||
local function PatchDrawList(BackendData, set, draw_list, n0, n, dx, dy, ox, oy, LimitX0, LimitY0, LimitX1, LimitY1)
|
||||
local function PatchDrawList(BackendData, set, draw_list, n0, n, dx, dy, ox, oy, LimitX0, LimitY0, LimitX1, LimitY1,
|
||||
recolor)
|
||||
table.clear(PatchPrim)
|
||||
local SigA, SigD = set.PrimSigA, set.PrimSigD
|
||||
local SigA, SigD, SigG = set.PrimSigA, set.PrimSigD, set.PrimSigG
|
||||
if not SigA or set.PrimN ~= n - n0 then return false end
|
||||
for m = 1, n - n0 do
|
||||
local p = n0 + m
|
||||
@@ -839,11 +891,15 @@ local function PatchDrawList(BackendData, set, draw_list, n0, n, dx, dy, ox, oy,
|
||||
for m = 1, count do
|
||||
local p = plist[m]
|
||||
local vd = PrimD[p]
|
||||
if PrimFlat[p]
|
||||
if (PrimFlat[p] and not recolor)
|
||||
or not (DriftSet[PrimA[p] // VTX_STRIDE + 1] or DriftSet[PrimB[p] // VTX_STRIDE + 1]
|
||||
or DriftSet[PrimC[p] // VTX_STRIDE + 1] or (vd and DriftSet[vd // VTX_STRIDE + 1])) then
|
||||
continue
|
||||
end
|
||||
if recolor then
|
||||
if PrimGradient[p] ~= SigG[p - n0] then return false end
|
||||
PatchH1[p], PatchH2[p], PatchSig[p] = PrimHash(p, lx0, ly0, ox, oy)
|
||||
end
|
||||
PatchPrim[p] = true
|
||||
local cx0, cy0, cx1, cy1 = PrimBoundsX0[p] - lx0, PrimBoundsY0[p] - ly0, PrimBoundsX1[p] - lx0,
|
||||
PrimBoundsY1[p] - ly0
|
||||
@@ -893,16 +949,28 @@ local function PatchDrawList(BackendData, set, draw_list, n0, n, dx, dy, ox, oy,
|
||||
table.move(tile.DrawnHash1, 1, count, 1, LH1)
|
||||
table.move(tile.DrawnHash2, 1, count, 1, LH2)
|
||||
table.move(tile.DrawnFlat, 1, count, 1, layer.TileListFlat[key])
|
||||
local lx0, ly0 = LayerOrigin(draw_list, kind, ox, oy)
|
||||
local LF = layer.TileListFlat[key]
|
||||
local h1, h2 = 0, 0
|
||||
for k = 1, count do
|
||||
if PatchPrim[list[k]] then
|
||||
local p = list[k]
|
||||
if not PatchPrim[p] then
|
||||
-- (unchanged entry)
|
||||
elseif not recolor then
|
||||
LH1[k], LH2[k] = (LH1[k] + DriftMark1) % P1, (LH2[k] + DriftMark2) % P2
|
||||
else
|
||||
local sig = PatchSig[p]
|
||||
if sig >= 0 then
|
||||
LH1[k], LH2[k] = FlatTileHash(p, lx0, ly0, layer.TileX[key], layer.TileY[key])
|
||||
else
|
||||
LH1[k], LH2[k] = PatchH1[p], PatchH2[p]
|
||||
end
|
||||
LF[k] = sig
|
||||
end
|
||||
h1 = (h1 * 48271 + LH1[k]) % P1
|
||||
h2 = (h2 * 16807 + LH2[k] + k) % P2
|
||||
end
|
||||
layer.TileHash1[key], layer.TileHash2[key] = h1, h2
|
||||
local lx0, ly0 = LayerOrigin(draw_list, kind, ox, oy)
|
||||
local x0, y0 = lx0 + layer.TileX[key] * TILE, ly0 + layer.TileY[key] * TILE
|
||||
local vx0, vy0, vx1, vy1 = 0, 0, TILE, TILE
|
||||
if layer.Root ~= layer.Frame then
|
||||
@@ -1002,19 +1070,26 @@ function M.RenderDrawData(draw_data)
|
||||
if nd > 0 then
|
||||
local Drift = Layers.Drift
|
||||
for k = 1, nd do DriftSet[Drift[k] // VTX_STRIDE + 1] = true end
|
||||
DriftOn, DriftMark1, DriftMark2 = true, (FrameNo * 7907 + 12345) % P1, (FrameNo * 7919 + 54321) % P2
|
||||
-- (recolored vertices, 4: only for PatchDrawList; the full path hashes them like any other)
|
||||
DriftOn, DriftMark1, DriftMark2 = same == 3, (FrameNo * 7907 + 12345) % P1, (FrameNo * 7919 + 54321) % P2
|
||||
end
|
||||
if same == 3 then
|
||||
if same == 3 or same == 4 then
|
||||
PB("ImGui drift patch")
|
||||
if EditableImages.StageTiming then EditableImages.BeginStage() end
|
||||
local patched = PatchDrawList(BackendData, set, draw_list, n0, n, sdx, sdy, ox, oy, LimitX0, LimitY0,
|
||||
LimitX1, LimitY1)
|
||||
LimitX1, LimitY1, same == 4)
|
||||
if EditableImages.StageTiming then EditableImages.EndStage("Raster") end
|
||||
PE()
|
||||
if patched then
|
||||
for k = 1, nd do DriftSet[Layers.Drift[k] // VTX_STRIDE + 1] = false end
|
||||
DriftOn = false
|
||||
z = ReuseDrawList(BackendData, set, draw_list, 2, sdx, sdy, z, ox, oy, ScreenWidth, ScreenHeight)
|
||||
if same == 4 then
|
||||
-- the snapshot: only vertex bytes changed
|
||||
buffer.copy(set.SnapVtx, 0, draw_list.VtxBuffer.Buf, 0, set.SnapVtxBytes)
|
||||
z = ReuseDrawList(BackendData, set, draw_list, 1, 0, 0, z, ox, oy, ScreenWidth, ScreenHeight)
|
||||
else
|
||||
z = ReuseDrawList(BackendData, set, draw_list, 2, sdx, sdy, z, ox, oy, ScreenWidth, ScreenHeight)
|
||||
end
|
||||
continue
|
||||
end
|
||||
end
|
||||
@@ -1036,6 +1111,7 @@ function M.RenderDrawData(draw_data)
|
||||
set.PrimBase, set.PrimN = n0, n - n0
|
||||
set.PrimSigA = table.move(PrimA, n0 + 1, n, 1, set.PrimSigA or {})
|
||||
set.PrimSigD = table.move(PrimD, n0 + 1, n, 1, set.PrimSigD or {})
|
||||
set.PrimSigG = table.move(PrimGradient, n0 + 1, n, 1, set.PrimSigG or {})
|
||||
end
|
||||
end
|
||||
if ListDeferred then AnyDeferred = true end
|
||||
|
||||
@@ -41,6 +41,7 @@ CHECKS=(
|
||||
"pixels|PIXELS SAME|a=\$($R --main tools/test/scripts/t_pixels.luau --frames 600 | grep -P '^PIX\t'); b=\$(RUN_FLAGS=ARG_FORCE=true $R --main tools/test/scripts/t_pixels.luau --frames 600 | grep -P '^PIX\t'); [ -n \"\$a\" ] && [ \"\$a\" = \"\$b\" ] && echo PIXELS SAME"
|
||||
"move_pixels|MOVEPIX SAME|a=\$($R --main tools/test/scripts/t_move_pixels.luau --frames 245 | grep -P '^PIX\t'); b=\$(RUN_FLAGS=ARG_FORCE=true $R --main tools/test/scripts/t_move_pixels.luau --frames 245 | grep -P '^PIX\t'); [ -n \"\$a\" ] && [ \"\$a\" = \"\$b\" ] && echo MOVEPIX SAME"
|
||||
"scene_pixels|SCENEPIX SAME|M='--module BenchScenes=tools/test/bench_scenes.luau'; [ -f extensions/implot-luau/ImPlot.lua ] && M=\"\$M --module ImPlot=extensions/implot-luau/ImPlot.lua\"; a=\$($R --main tools/test/scripts/t_scene_pixels.luau --frames 170 \$M | grep -P '^PIX\t'); b=\$(RUN_FLAGS=ARG_FORCE=true $R --main tools/test/scripts/t_scene_pixels.luau --frames 170 \$M | grep -P '^PIX\t'); [ -n \"\$a\" ] && [ \"\$a\" = \"\$b\" ] && echo SCENEPIX SAME"
|
||||
"recolor_pixels|RECOLORPIX SAME|a=\$($R --main tools/test/scripts/t_recolor_pixels.luau --frames 140 | grep -P '^PIX\t'); b=\$(RUN_FLAGS=ARG_FORCE=true $R --main tools/test/scripts/t_recolor_pixels.luau --frames 140 | grep -P '^PIX\t'); [ -n \"\$a\" ] && [ \"\$a\" = \"\$b\" ] && echo RECOLORPIX SAME"
|
||||
"rect_flip|RECTFLIP OK|$R --main tools/test/scripts/t_rect_flip.luau --frames 30"
|
||||
"tile_bound|TILEBOUND OK|$R --main tools/test/scripts/t_tile_bound.luau --frames 200"
|
||||
"parallel|PARALLEL OK|$R --main tools/test/scripts/t_parallel.luau --frames 620"
|
||||
|
||||
@@ -0,0 +1,145 @@
|
||||
-- Pixel oracle for the "recolored" path (CompareDrawList 4 + PatchDrawList recolor: same vertex positions, a few
|
||||
-- vertices' colour / uv changed, e.g. hover): animated style colours on buttons, text, frames, a colour button, a
|
||||
-- scrolled child, a wide button over several tiles and AddRectFilledMultiColor cycling flat <-> gradient (kind changes
|
||||
-- fall back to the full path), between still frames, structure changes, hover, a colour picker (too many changed
|
||||
-- vertices) and a tile limit (deferred tiles). Composites the ScreenGui every few frames and prints "PIX <frame> <hash>".
|
||||
-- Run with RUN_FLAGS="ARG_FORCE=true" for a full redraw every frame: incremental output must match it exactly (also with
|
||||
-- ARG_PAR=true: the parallel executor).
|
||||
-- python3 tools/test/run.py --main tools/test/scripts/t_recolor_pixels.luau --frames 140 --quiet --roblox
|
||||
local G = require(game:GetService("ReplicatedStorage"):WaitForChild("ImGui"))
|
||||
local ImGui, ImVec2, ImVec4 = G.ImGui, G.ImVec2, G.ImVec4
|
||||
ImGui.CreateContext()
|
||||
G.ImGui_ImplRoblox.Init()
|
||||
G.ImGui_ImplRoblox.SetRenderRate(0)
|
||||
if ARG_PAR then G.ImGui_ImplRoblox.EnableParallel({ Sync = true, Actors = 4 }) end
|
||||
local io = ImGui.GetIO()
|
||||
local Col = G.ImGuiCol
|
||||
local W, H = 1280, 760
|
||||
local SW, SH = 720, 560 -- composited area (the windows are inside it)
|
||||
local hsv = ImVec4(0.4, 0.7, 0.2, 1)
|
||||
|
||||
local function composite(gui)
|
||||
local screen = buffer.create(SW * SH * 3)
|
||||
local function walk(inst, ox, oy, kx0, ky0, kx1, ky1)
|
||||
local kids = inst:GetChildren()
|
||||
table.sort(kids, function(a, b) return (a.ZIndex or 1) < (b.ZIndex or 1) end)
|
||||
for _, c in ipairs(kids) do
|
||||
if c.Visible ~= false then
|
||||
local x, y = ox + (c.Position and c.Position.X or 0), oy + (c.Position and c.Position.Y or 0)
|
||||
local cx0, cy0, cx1, cy1 = kx0, ky0, kx1, ky1
|
||||
if c.ClipsDescendants then
|
||||
cx0, cy0 = math.max(cx0, x), math.max(cy0, y)
|
||||
cx1, cy1 = math.min(cx1, x + c.Size.X), math.min(cy1, y + c.Size.Y)
|
||||
end
|
||||
if c.ClassName == "ImageLabel" then
|
||||
local img = c.ImageContent.Object
|
||||
local px, sz = img.Pixels, img.Size.X
|
||||
for ty = 0, sz - 1 do
|
||||
local sy = y + ty
|
||||
if sy >= cy0 and sy < cy1 then
|
||||
for tx = 0, sz - 1 do
|
||||
local sx = x + tx
|
||||
if sx >= cx0 and sx < cx1 then
|
||||
local o = (ty * sz + tx) * 4
|
||||
local a = buffer.readu8(px, o + 3)
|
||||
if a > 0 then
|
||||
local d = (sy * SW + sx) * 3
|
||||
local fa = a / 255
|
||||
for ch = 0, 2 do
|
||||
local v = buffer.readu8(px, o + ch) * fa + buffer.readu8(screen, d + ch) * (1 - fa)
|
||||
buffer.writeu8(screen, d + ch, math.floor(v + 0.5))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
walk(c, x, y, cx0, cy0, cx1, cy1)
|
||||
end
|
||||
end
|
||||
end
|
||||
walk(gui, 0, 0, 0, 0, SW, SH)
|
||||
local h = 0
|
||||
for i = 0, SW * SH * 3 - 4, 4 do h = (h * 31 + buffer.readu32(screen, i)) % 2147483647 end
|
||||
return h
|
||||
end
|
||||
|
||||
-- phases: name, frames
|
||||
local PHASES = { { "recolor", 24 }, { "still", 6 }, { "grow", 8 }, { "recolor", 16 }, { "hover", 24 },
|
||||
{ "picker", 10 }, { "limit", 30 }, { "recolor", 12 }, { "still", 6 } }
|
||||
local frame, pi, pf, extra, t = 0, 1, 0, 0, 0
|
||||
game:GetService("RunService").Stepped:Connect(function()
|
||||
local ph = PHASES[pi]
|
||||
if not ph then return end
|
||||
frame += 1
|
||||
pf += 1
|
||||
local name = ph[1]
|
||||
G.ImGui_ImplRoblox.NewFrame()
|
||||
io.DeltaTime = 1 / 60
|
||||
io:AddMousePosEvent(1200, 740)
|
||||
io.BackendPlatformUserData.TileLimit = name == "limit" and 2 or nil
|
||||
if name == "recolor" or name == "limit" then t += 1 end
|
||||
if name == "grow" and pf % 3 == 0 then extra += 1 end
|
||||
if name == "hover" then io:AddMousePosEvent(50 + (pf * 37) % 420, 60 + (pf * 29) % 300) end
|
||||
if name == "picker" then hsv.x = (hsv.x + 0.03) % 1 end
|
||||
ImGui.NewFrame()
|
||||
local c1 = ImVec4(0.5 + 0.5 * math.sin(t * 0.3), 0.4, 0.5 + 0.5 * math.cos(t * 0.2), 1)
|
||||
local c2 = ImVec4(0.2, 0.5 + 0.5 * math.sin(t * 0.25), 0.3, 0.6 + 0.4 * math.cos(t * 0.4))
|
||||
ImGui.SetNextWindowPos(ImVec2(20, 20), G.ImGuiCond.Always)
|
||||
ImGui.SetNextWindowSize(ImVec2(470, 520), G.ImGuiCond.Always)
|
||||
ImGui.Begin("Recolor")
|
||||
ImGui.PushStyleColor(Col.Button, c1)
|
||||
ImGui.PushStyleColor(Col.FrameBg, c2)
|
||||
for i = 1, 6 do
|
||||
ImGui.Button("Button " .. i)
|
||||
if i % 3 ~= 0 then ImGui.SameLine() end
|
||||
end
|
||||
ImGui.Button("A wide button over several tiles", ImVec2(400, 40))
|
||||
ImGui.PopStyleColor(2)
|
||||
ImGui.TextColored(c1, "Coloured text %d", 7)
|
||||
ImGui.ColorButton("##cb", c2)
|
||||
ImGui.SameLine()
|
||||
local dl = ImGui.GetWindowDrawList()
|
||||
local p = ImGui.GetCursorScreenPos()
|
||||
-- flat (t % 8 < 2), horizontal / vertical gradient otherwise: kind changes take the full path
|
||||
local u1 = ImGui.GetColorU32(c1)
|
||||
local u2 = (t % 8 < 2) and u1 or ImGui.GetColorU32(c2)
|
||||
if t % 16 < 8 then
|
||||
dl:AddRectFilledMultiColor(p, ImVec2(p.x + 140, p.y + 30), u1, u2, u2, u1)
|
||||
else
|
||||
dl:AddRectFilledMultiColor(p, ImVec2(p.x + 140, p.y + 30), u1, u1, u2, u2)
|
||||
end
|
||||
ImGui.Dummy(ImVec2(140, 30))
|
||||
for i = 1, extra do ImGui.Text("Extra line %d", i) end
|
||||
ImGui.BeginChild("scrolled", ImVec2(0, 200), G.ImGuiChildFlags.Borders)
|
||||
ImGui.SetScrollY(37)
|
||||
ImGui.PushStyleColor(Col.Text, c1)
|
||||
for i = 1, 20 do ImGui.Text("Child line %d", i) end
|
||||
ImGui.PopStyleColor()
|
||||
ImGui.PushStyleColor(Col.Button, c2)
|
||||
ImGui.Button("Child button")
|
||||
ImGui.PopStyleColor()
|
||||
ImGui.EndChild()
|
||||
_ = ImGui.Checkbox("Check", true)
|
||||
ImGui.End()
|
||||
if name == "picker" or pi > 6 then
|
||||
ImGui.SetNextWindowPos(ImVec2(500, 20), G.ImGuiCond.Always)
|
||||
ImGui.SetNextWindowSize(ImVec2(210, 300), G.ImGuiCond.Always)
|
||||
ImGui.Begin("Picker")
|
||||
ImGui.ColorPicker4("##p", hsv, G.ImGuiColorEditFlags.PickerHueBar)
|
||||
ImGui.End()
|
||||
end
|
||||
ImGui.Render()
|
||||
G.ImGui_ImplRoblox.RenderDrawData(ImGui.GetDrawData())
|
||||
if ARG_PAR then G.ImGui_ImplRoblox.FinishParallel() end
|
||||
-- (checkpoints: exact as long as no tile is deferred, i.e. not during "limit"; the frame after it redraws them)
|
||||
if name ~= "limit" and (frame % 3 == 0 or pf == ph[2]) then
|
||||
print("PIX", name, frame, composite(game:GetService("Players").LocalPlayer.PlayerGui:FindFirstChild("ImGui")))
|
||||
end
|
||||
if pf == ph[2] then
|
||||
pi += 1
|
||||
pf = 0
|
||||
if not PHASES[pi] then print("RECOLORPIX DONE") end
|
||||
end
|
||||
end)
|
||||
Reference in new issue
Block a user