Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
63
Task/Image-noise/Phix/image-noise.phix
Normal file
63
Task/Image-noise/Phix/image-noise.phix
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
-- demo\rosetta\ImageNoise.exw
|
||||
include pGUI.e
|
||||
|
||||
Ihandle dlg, canvas, timer
|
||||
cdCanvas cddbuffer, cdcanvas
|
||||
|
||||
constant TITLE = "Image noise"
|
||||
|
||||
integer fps = 129 -- (typical value)
|
||||
|
||||
function redraw_cb(Ihandle /*ih*/, integer /*posx*/, integer /*posy*/)
|
||||
integer {w, h} = IupGetIntInt(canvas, "DRAWSIZE")
|
||||
cdCanvasActivate(cddbuffer)
|
||||
sequence bw = repeat(0,w*h)
|
||||
for x=0 to w-1 do
|
||||
for y=0 to h-1 do
|
||||
if rand(2)=2 then bw[x*h+y+1] = 255 end if
|
||||
end for
|
||||
end for
|
||||
cdCanvasPutImageRectRGB(cddbuffer, w, h, {bw,bw,bw})
|
||||
cdCanvasFlush(cddbuffer)
|
||||
fps += 1
|
||||
return IUP_DEFAULT
|
||||
end function
|
||||
|
||||
atom t1 = time()
|
||||
|
||||
function timer_cb(Ihandle /*ih*/)
|
||||
if time()>t1 then
|
||||
IupSetStrAttribute(dlg, "TITLE", "%s [%g FPS])",{TITLE,fps})
|
||||
fps = 0
|
||||
t1 = time()+1
|
||||
end if
|
||||
IupUpdate(canvas)
|
||||
return IUP_IGNORE
|
||||
end function
|
||||
|
||||
function map_cb(Ihandle ih)
|
||||
cdcanvas = cdCreateCanvas(CD_IUP, ih)
|
||||
cddbuffer = cdCreateCanvas(CD_DBUFFER, cdcanvas)
|
||||
return IUP_DEFAULT
|
||||
end function
|
||||
|
||||
procedure main()
|
||||
IupOpen()
|
||||
|
||||
canvas = IupCanvas(NULL)
|
||||
IupSetAttribute(canvas, "RASTERSIZE", "320x240")
|
||||
IupSetCallback(canvas, "MAP_CB", Icallback("map_cb"))
|
||||
IupSetCallback(canvas, "ACTION", Icallback("redraw_cb"))
|
||||
|
||||
timer = IupTimer(Icallback("timer_cb"), 10)
|
||||
|
||||
dlg = IupDialog(canvas)
|
||||
IupSetAttribute(dlg, "TITLE", TITLE)
|
||||
|
||||
IupShow(dlg)
|
||||
IupSetAttribute(canvas, "RASTERSIZE", NULL)
|
||||
IupMainLoop()
|
||||
IupClose()
|
||||
end procedure
|
||||
|
||||
main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue