I’m trying to make a glitch effect where randomly colored squares tile the screen and rapidly change colors.
For that I started using EditableImages and set up this demo:
local AssetService = game:GetService('AssetService')
local Camera = workspace.CurrentCamera
function Render(FullSize: Vector2)
local Size = FullSize / 10
Size = Vector2.new(math.ceil(Size.X), math.ceil(Size.Y))
local Length = Size.X * Size.Y * 4
local ImageBuffer = buffer.create(Length)
for i = 1, Length do
buffer.writeu8(ImageBuffer, i - 1,
i % 4 == 0 and 255 or math.random(0, 255))
end
local EditableImage = AssetService:CreateEditableImage({Size = Size})
EditableImage:WritePixelsBuffer(Vector2.zero, Size, ImageBuffer)
script.Parent.ImageContent = Content.fromObject(EditableImage)
end
Render(Camera.ViewportSize)
My issue is that there’s a flicker every time I set the ImageContent
of the ImageLabel
.
I want the solution to be properly timed delays and associated pre-rendering bc that sounds like the most robust, and to properly time it I need like an event for when the image has appeared on the ImageLabel
or at the very least the ability to check if it’s finished conditionally.
So, do I have any access to know when the image rendered or to know when to wait for the image to render?