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/cdtext.wlua | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 test/lua/cdtext.wlua (limited to 'test/lua/cdtext.wlua') diff --git a/test/lua/cdtext.wlua b/test/lua/cdtext.wlua new file mode 100644 index 0000000..556d02f --- /dev/null +++ b/test/lua/cdtext.wlua @@ -0,0 +1,59 @@ +require("iupcdaux") -- utility module used in some samples + +--require"cdluacontextplus" +--cd.UseContextPlus(1) + +dlg = iupcdaux.new_dialog(w, h) +cnv = dlg[1] -- retrieve the IUP canvas + +function DrawTextBox(canvas, x, y, text) + canvas:Mark(x, y) + canvas:Text(x, y, text) + w, h = canvas:GetTextSize(text) + xmin = x - w/2 + ymin = y - h/2 + xmax = x + w/2 + ymax = y + h/2 + canvas:Line(xmin, ymin, xmax, ymin) + canvas:Line(xmin, ymin, xmin, ymax) + canvas:Line(xmin, ymax, xmax, ymax) + canvas:Line(xmax, ymin, xmax, ymax) +end + +-- custom function used in action callback +-- from the iupcdaux module +function cnv:Draw(canvas) + + -- Available in ContextPlus drivers or in IMAGERGB driver + -- canvas:SetAttribute("ANTIALIAS", "1") + + canvas:TextAlignment(cd.CENTER) + canvas:MarkSize(40) + + canvas:Font("Courier", cd.PLAIN, 12) + local aa = canvas:GetAttribute("ANTIALIAS") + if (aa == "1") then + DrawTextBox(canvas, 130, 30, "ANTIALIAS=1") + else + DrawTextBox(canvas, 130, 30, "ANTIALIAS=0") + end + + canvas:Font("Courier", cd.ITALIC, 34) + DrawTextBox(canvas, 130, 160, "xxxxxppx") + + canvas:Font("Times", cd.PLAIN, 12) + DrawTextBox(canvas, 130, 290, "taaaa") + + canvas:Font("Times", cd.BOLD, 14) + DrawTextBox(canvas, 130, 370, "gggggggg") +end + + +--tmpCanvas = cd.CreateCanvas(cd.PS, "cdtext.ps") +--tmpCanvas:Clear() +--cnv:Draw(tmpCanvas) +--tmpCanvas:Kill() + + +dlg:show() +iup.MainLoop() -- cgit v1.2.3