Galton box animation: Difference between revisions
Content added Content deleted
m (→{{header|REXX}}: elided text from the REXX section that is no longer true (concerning the name of the program to clear the terminal screen).) |
|||
Line 2,476: | Line 2,476: | ||
=={{header|Phix}}== |
=={{header|Phix}}== |
||
=== console === |
|||
First, a console version: |
First, a console version: |
||
<lang Phix>constant balls = 80 |
<lang Phix>constant balls = 80 |
||
Line 2,547: | Line 2,548: | ||
....................... |
....................... |
||
</pre> |
</pre> |
||
=== gui === |
|||
Also, here is a slightly nicer and resize-able gui version: |
Also, here is a slightly nicer and resize-able gui version: |
||
{{libheader|pGUI}} |
{{libheader|Phix/pGUI}} |
||
<lang Phix>-- |
<lang Phix>-- demo\rosetta\GaltonBox.exw |
||
-- demo\rosetta\GaltonBox.exw |
|||
-- |
|||
constant TITLE = "Galton Box" |
constant TITLE = "Galton Box" |
||
Line 2,629: | Line 2,629: | ||
cdCanvasSetBackground(cddbuffer, CD_GREY) |
cdCanvasSetBackground(cddbuffer, CD_GREY) |
||
return IUP_DEFAULT |
return IUP_DEFAULT |
||
end function |
|||
function esc_close(Ihandle /*ih*/, atom c) |
|||
if c=K_ESC then return IUP_CLOSE end if |
|||
return IUP_CONTINUE |
|||
end function |
end function |
||
Line 2,648: | Line 2,643: | ||
dlg = IupDialog(canvas) |
dlg = IupDialog(canvas) |
||
IupSetAttribute(dlg, "TITLE", TITLE) |
IupSetAttribute(dlg, "TITLE", TITLE) |
||
IupCloseOnEscape(dlg) |
|||
IupSetCallback(dlg, "K_ANY", Icallback("esc_close")) |
|||
IupShow(dlg) |
IupShow(dlg) |
||
IupSetAttribute(canvas, "RASTERSIZE", NULL) |
IupSetAttribute(canvas, "RASTERSIZE", NULL) |