(phixonline)--> -- demo\rosetta\Colour_bars.exw with javascript_semantics include pGUI.e constant colours = {CD_BLACK, CD_RED, CD_GREEN, CD_BLUE, CD_MAGENTA, CD_CYAN, CD_YELLOW, CD_WHITE} Ihandle dlg, canvas cdCanvas cdcanvas function redraw_cb(Ihandle /*ih*/, integer /*posx*/, /*posy*/) integer {width, height} = IupGetIntInt(canvas, "DRAWSIZE"), x = 0, lc = length(colours) cdCanvasActivate(cdcanvas) for i=1 to lc do integer w = floor((width-x)/(lc-i+1)) cdCanvasSetForeground(cdcanvas, colours[i]) cdCanvasBox(cdcanvas, x, x+w, 0, height) x += w end for cdCanvasFlush(cdcanvas) return IUP_DEFAULT end function IupOpen() canvas = IupCanvas(Icallback("redraw_cb"),"RASTERSIZE=600x400") -- initial size dlg = IupDialog(canvas,`TITLE="Colour bars"`) IupMap(dlg) cdcanvas = cdCreateCanvas(CD_IUP, canvas) IupShow(dlg) IupSetAttribute(canvas, "RASTERSIZE", NULL) -- release the minimum limitation if platform()!=JS then IupMainLoop() IupClose() end if