Jump to content

Image noise: Difference between revisions

(Added Perl example)
Line 1,614:
</body></lang>
About 59 frames/second on Firefox 4.
 
=={{header|Julia}}==
<lang julia>using Gtk, GtkUtilities
 
function randbw(ctx, w, h)
pic = zeros(Int64, w, h)
for i in 1:length(pic)
pic[i] = rand([1, 0])
end
copy!(ctx, pic)
end
 
const can = @GtkCanvas()
const win = GtkWindow(can, "Image Noise", 320, 240)
 
@guarded draw(can) do widget
ctx = getgc(can)
h = height(can)
w = width(can)
randbw(ctx, w, h)
end
 
show(can)
const cond = Condition()
endit(w) = notify(cond)
signal_connect(endit, win, :destroy)
 
while true
frames = 0
t = time()
for _ in 1:100
draw(can)
show(can)
sleep(0.0001)
frames += 1
end
fps = round(frames / (time() - t), digits=1)
set_gtk_property!(win, :title, "Image Noise: $fps fps")
end
 
wait(cond)
</lang>
 
=={{header|Kotlin}}==
4,105

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.