diff options
author | scuri <scuri> | 2010-05-26 18:45:54 +0000 |
---|---|---|
committer | scuri <scuri> | 2010-05-26 18:45:54 +0000 |
commit | 7be3bd466f1787931df9be41c4927e6482231d8a (patch) | |
tree | fa513328a3bc128567b0312b88545a3956a08f6a | |
parent | c196148fb2fd001a16434c46427d7651e5abb7f2 (diff) |
*** empty log message ***
-rw-r--r-- | html/examples/rotate_transparent.lua | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/html/examples/rotate_transparent.lua b/html/examples/rotate_transparent.lua new file mode 100644 index 0000000..640826d --- /dev/null +++ b/html/examples/rotate_transparent.lua @@ -0,0 +1,77 @@ +-- Contribution by Gustavo Lyrio +require"imlua" +require"imlua_process" +require"cdlua" +require"cdluaim" +require"iuplua" +require"iupluacd" + +--IupCanvas Example in IupLua +cv = iup.canvas {rastersize="640x480"} +dg = iup.dialog{iup.frame{cv}; title="Rotate Test"} + +-- Simple parameters +width = 640 +height = 480 +screen_width = 1024 +screen_height = 768 + +image = im.FileImageLoad("flower.jpg") +Timage = {} +--Timage.x0 = (width/2) - (image:Width()/2) +--Timage.y0 = (height/2) - (image:Height()/2) +Timage.x0 = 0 +Timage.y0 = 0 + +function cv:action() + canvas:Activate() + canvas:Clear() + if (image2) then + image2:cdCanvasPutImageRect(canvas, Timage.x0, Timage.y0, image2:Width(), image2:Height(), 0,0,0,0) + end + return iup.DEFAULT +end + +function cv:motion_cb(x, y, status) + cd.Activate(canvas) + y = cd.UpdateYAxis(y) + if iup.isbutton1(status) == true then + end + return iup.DEFAULT +end + +function cv:button_cb(but, pressed, x, y, status) + if iup.isbutton1(status) == false then + end + return iup.DEFAULT +end + +dg:map() +canvas = cd.CreateCanvas(cd.IUP, cv.handle) + +dg:showxy(iup.CENTER, iup.CENTER) + +-- Rotation Test +image:AddAlpha() -- option 1: to avoid a black background +image:SetAlpha(255) + +local w, h = im.ProcessCalcRotateSize(image:Width(), image:Height(), math.cos(math.pi/4), math.sin(math.pi/4)) +image2 = im.ImageCreateBased(image, w, h) + +--image2 = im.ImageCreate(w, h, im.RGB, im.BYTE) -- option 2: to avoid a black background +--im.ProcessRenderConstant(image2, {255, 255, 255}) + +im.ProcessRotate(image, image2, math.cos(math.pi/4), math.sin(math.pi/4), 1) + +canvas:Activate() +canvas:Clear() + +--original +--image:cdCanvasPutImageRect(canvas, Timage.x0, Timage.y0, image:Width(), image:Height(), 0,0,0,0) + +--processed +image2:cdCanvasPutImageRect(canvas, Timage.x0, Timage.y0, image2:Width(), image2:Height(), 0,0,0,0) + +if (not iup.MainLoopLevel or iup.MainLoopLevel()==0) then + iup.MainLoop() +end |