Task

Create a window and draw a pixel in it, subject to the following:

  the window is 320 x 240
  the color of the pixel must be red (255,0,0)
  the position of the pixel is x = 100, y = 100
with javascript_semantics
include pGUI.e
 
cdCanvas cdcanvas
 
function redraw_cb(Ihandle /*ih*/, integer /*posx*/, integer /*posy*/)
    cdCanvasActivate(cdcanvas)
    cdCanvasPixel(cdcanvas, 100, 100, CD_RED) 
    cdCanvasFlush(cdcanvas)
    return IUP_DEFAULT
end function
 
function map_cb(Ihandle ih)
    cdcanvas = cdCreateCanvas(CD_IUP, ih)
    return IUP_DEFAULT
end function
 
procedure main()
    IupOpen()
    Ihandle canvas = IupCanvas(NULL)
    IupSetAttribute(canvas, "RASTERSIZE", "320x240")
    IupSetCallback(canvas, "MAP_CB", Icallback("map_cb"))
    Ihandle dlg = IupDialog(canvas)
    IupSetAttribute(dlg, "TITLE", "Draw a pixel")
    IupSetCallback(canvas, "ACTION", Icallback("redraw_cb"))
    IupShow(dlg)
    if platform()!=JS then
        IupMainLoop()
        IupClose()
    end if
end procedure
 
main()
