Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
39
Task/Image-noise/Julia/image-noise.julia
Normal file
39
Task/Image-noise/Julia/image-noise.julia
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
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)
|
||||
Loading…
Add table
Add a link
Reference in a new issue