Colour bars/Display: Difference between revisions
Content added Content deleted
m (Commodore BASIC: Converted program to lower case, which aids when copy-pasting into emulators.) |
m (→{{header|Phix}}: simplified) |
||
Line 1,338: | Line 1,338: | ||
Ihandle dlg, canvas |
Ihandle dlg, canvas |
||
cdCanvas |
cdCanvas cdcanvas |
||
function redraw_cb(Ihandle /*ih*/, integer /*posx*/, |
function redraw_cb(Ihandle /*ih*/, integer /*posx*/, /*posy*/) |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
for i=1 to lc do |
for i=1 to lc do |
||
integer w = floor((width-x)/(lc-i+1)) |
integer w = floor((width-x)/(lc-i+1)) |
||
cdCanvasSetForeground( |
cdCanvasSetForeground(cdcanvas, colours[i]) |
||
cdCanvasBox( |
cdCanvasBox(cdcanvas, x, x+w, 0, height) |
||
x += w |
x += w |
||
end for |
end for |
||
cdCanvasFlush( |
cdCanvasFlush(cdcanvas) |
||
return IUP_DEFAULT |
return IUP_DEFAULT |
||
end function |
end function |
||
⚫ | |||
function map_cb(Ihandle ih) |
|||
canvas = IupCanvas(Icallback("redraw_cb"),"RASTERSIZE=600x400") -- initial size |
|||
⚫ | |||
⚫ | |||
cddbuffer = cdCreateCanvas(CD_DBUFFER, cdcanvas) |
|||
⚫ | |||
return IUP_DEFAULT |
|||
⚫ | |||
end function |
|||
IupShow(dlg) |
|||
⚫ | |||
function unmap_cb(Ihandle /*ih*/) |
|||
⚫ | |||
cdKillCanvas(cddbuffer) |
|||
⚫ | |||
cdKillCanvas(cdcanvas) |
|||
return IUP_DEFAULT |
|||
end function |
|||
procedure main() |
|||
⚫ | |||
canvas = IupCanvas(NULL) |
|||
IupSetAttribute(canvas, "RASTERSIZE", "600x400") -- initial size |
|||
IupSetCallback(canvas, "MAP_CB", Icallback("map_cb")) |
|||
IupSetCallback(canvas, "UNMAP_CB", Icallback("unmap_cb")) |
|||
⚫ | |||
IupSetAttribute(dlg, "TITLE", "Colour bars") |
|||
IupSetCallback(canvas, "ACTION", Icallback("redraw_cb")) |
|||
⚫ | |||
⚫ | |||
IupShowXY(dlg,IUP_CENTER,IUP_CENTER) |
|||
⚫ | |||
IupClose() |
|||
end procedure |
|||
⚫ | |||
=={{header|PHP}}== |
=={{header|PHP}}== |