Posted 04 January 2013 - 03:59 AM
I have a similar program to the one I am gonna post below. Basically, when doing A LOT of clearing of the terminal and writing, you can manage a flicker effect on stuff. I am not sure how to explain this but basically, what the program does it it is doing a lot of drawing and it causes a flicker. I was wondering, how do you go about stopping this flickering?
I am coding a OS atm and the os has a topbar you click and it slides down nice and smooth. Now, when it slides down it has to reprint everything because if you don't, it starts to have a sorta, drag effect. As it slides down, it has to clear the terminal, print the background, print the topbar, and then print icons and basically, it starts flickering. Just wondering how someone would achieve a non-flicker on something like this.
EDIT: Edited code to show a bit better what I am having a problem with.
Spoiler
mw, mh = term.getSize()
function pixel(x,y,color)
term.setCursorPos(x,y)
term.setBackgroundColor(color)
term.write(" ")
end
function drawRect(minx,miny,maxx,maxy,color)
for x = minx, maxx do
for y = miny, maxy do
pixel(x,y,color)
end
end
end
function clear()
term.setBackgroundColor(colors.black)
term.clear()
end
while true do
clear()
for y=1,9 do
--clear()
drawRect(1,1,mw,mh,colors.red)
drawRect(1,1,mw,y,colors.blue)
sleep(0.005)
end
end
I am coding a OS atm and the os has a topbar you click and it slides down nice and smooth. Now, when it slides down it has to reprint everything because if you don't, it starts to have a sorta, drag effect. As it slides down, it has to clear the terminal, print the background, print the topbar, and then print icons and basically, it starts flickering. Just wondering how someone would achieve a non-flicker on something like this.
EDIT: Edited code to show a bit better what I am having a problem with.