From 7b52cc13af4e85f1ca2deb6b6c77de9c95ea0dcf Mon Sep 17 00:00:00 2001 From: scuri Date: Fri, 17 Oct 2008 06:10:33 +0000 Subject: First commit - moving from LuaForge to SourceForge --- test/lua/rubberband.wlua | 54 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 test/lua/rubberband.wlua (limited to 'test/lua/rubberband.wlua') diff --git a/test/lua/rubberband.wlua b/test/lua/rubberband.wlua new file mode 100644 index 0000000..595373a --- /dev/null +++ b/test/lua/rubberband.wlua @@ -0,0 +1,54 @@ +require("iupcdaux") -- utility module used in some samples + +dlg = iupcdaux.new_dialog(w, h) +cnv = dlg[1] -- retrieve the IUP canvas + + +function cnv:button_cb(button,pressed,x,y,r) + canvas = self.canvas -- retrieve the CD canvas from the IUP attribute + + -- start drag if button1 is pressed + if button ==iup.BUTTON1 and pressed == 1 then + y = canvas:UpdateYAxis(y) + + -- prepare for XOR + canvas:Foreground(cd.WHITE) + canvas:WriteMode(cd.XOR) + + xstart = x + ystart = y + drag = 1 + first = 1 + else + if (drag == 1) then + drag = 0 + canvas:Rect(xstart,xend,ystart,yend) + end + end +end + + +function cnv:motion_cb(x,y,r) + canvas = self.canvas -- retrieve the CD canvas from the IUP attribute + + if (drag == 1) then + y = canvas:UpdateYAxis(y) + + if (first == 1) then + first = 0 + else + canvas:Rect(xstart,xend,ystart,yend) + end + + canvas:Rect(xstart,x,ystart,y) + + xend = x + yend = y + end +end + +first = 1 +drag = 0 + +dlg:show() +iup.MainLoop() -- cgit v1.2.3