Re: [Iup-users] canvas line
Hi, No problem. Keep going. BTW, those asymmetry are from the Win32 API, not much to do about it. Best, Scuri > -Original Message- > From: Karagy [mailto:kar...@mail.ru] > Sent: segunda-feira, 16 de dezembro de 2013 18:13 > To: IUP discussion list. > Subject: Re: [Iup-users] canvas line > > Hi, > > This is not about new bugs. No new bugs. This primitive demonstration > through xor overlay each other two lines - lines emulated through the points > and lines of the canvas. > Done in a hurry, the code is dirty. > Plus controls for changing parameters - thickness, position of the upper and > lower edge of the line, e.t.c. > Usage: set the parameters, click the mouse in the canvas - it will draw. > If necessary - repeat -) > > For example: > Skip WriteMode, any LineJoin, and set LineCap to CAPROUND and LineWidth > to 4. Click to canvas - it will make a redraw. Change only width to 6. > Noticeable asymmetry of half-circles on the edges of the line for an even > thickness. > I believe that if this was a bug - it is very low priority. > Sorry to take away your time. > > > -- > Regards, > > Karagy. > > -- > Rapidly troubleshoot problems before they affect your business. Most IT > organizations don't have a clear picture of how application performance > affects their revenue. With AppDynamics, you get 100% visibility into your > Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics > Pro! > http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clk > trk > ___ > Iup-users mailing list > Iup-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/iup-users -- Rapidly troubleshoot problems before they affect your business. Most IT organizations don't have a clear picture of how application performance affects their revenue. With AppDynamics, you get 100% visibility into your Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro! http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk ___ Iup-users mailing list Iup-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/iup-users
Re: [Iup-users] canvas line
Hi, This is not about new bugs. No new bugs. This primitive demonstration through xor overlay each other two lines - lines emulated through the points and lines of the canvas. Done in a hurry, the code is dirty. Plus controls for changing parameters - thickness, position of the upper and lower edge of the line, e.t.c. Usage: set the parameters, click the mouse in the canvas - it will draw. If necessary - repeat -) For example: Skip WriteMode, any LineJoin, and set LineCap to CAPROUND and LineWidth to 4. Click to canvas - it will make a redraw. Change only width to 6. Noticeable asymmetry of half-circles on the edges of the line for an even thickness. I believe that if this was a bug - it is very low priority. Sorry to take away your time. -- Regards, Karagy. -- Rapidly troubleshoot problems before they affect your business. Most IT organizations don't have a clear picture of how application performance affects their revenue. With AppDynamics, you get 100% visibility into your Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro! http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk ___ Iup-users mailing list Iup-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/iup-users
Re: [Iup-users] canvas line
Hi, Please could you describe more how to obtain the buggy situations? Best, Scuri > -Original Message- > From: Karagy [mailto:kar...@mail.ru] > Sent: sábado, 14 de dezembro de 2013 12:33 > To: iup-users@lists.sourceforge.net > Subject: Re: [Iup-users] canvas line > > Hi. > > More visual example in attach. > w/o debug printing. > On mouse click it draw 4 lines (from left to right): > 1. emulated line (via cd.Pixel) > 2. emulated line, then XOR cd.Line > 3. cd.Line, then XOR emulated line > 4. cd.Line in GUI-selected WriteMode > > For xored lines: WHITE fill BLACK xor CYAN = RED overlaps, BLACK underlaps -) > Emulated line always as CAPFLAT. > > Looks like that 1 missed pixel at the top - is center for square in CAPSQUARE > and, also, is center for half-circle for CAPROUND. > > Missed pixels at bottom - also missed in CAPSQUARE. But in CAPROUND - ok. > > Same bugs for horisontal lines. (not realised in this example) > > -- > Regards, > > Karagy. -- Rapidly troubleshoot problems before they affect your business. Most IT organizations don't have a clear picture of how application performance affects their revenue. With AppDynamics, you get 100% visibility into your Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro! http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk ___ Iup-users mailing list Iup-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/iup-users
Re: [Iup-users] canvas line
Hi. More visual example in attach. w/o debug printing. On mouse click it draw 4 lines (from left to right): 1. emulated line (via cd.Pixel) 2. emulated line, then XOR cd.Line 3. cd.Line, then XOR emulated line 4. cd.Line in GUI-selected WriteMode For xored lines: WHITE fill BLACK xor CYAN = RED overlaps, BLACK underlaps -) Emulated line always as CAPFLAT. Looks like that 1 missed pixel at the top - is center for square in CAPSQUARE and, also, is center for half-circle for CAPROUND. Missed pixels at bottom - also missed in CAPSQUARE. But in CAPROUND - ok. Same bugs for horisontal lines. (not realised in this example) -- Regards, Karagy. require "cdlua" require "iuplua" require "iupluacd" local cnv = iup.canvas { rastersize = "80x80", expand = "NO", --border = "NO", -- user-defined attrs line_width = 1, line_tpad = 4, line_bpad = 4, write_mode = cd.XOR, line_join = cd.MITER, line_cap = cd.CAPFLAT, line_color = cd.EncodeColor(0, 255, 255), } function cnv:map_cb() self.canvas = cd.CreateCanvas(cd.IUP, self) end function cnv:emulate_vline(x, y1, y2, w, mode, color) local c = self.canvas local dx_l = math.modf(w/2) local dx_r = math.modf((w-1)/2) c:WriteMode(mode) for _x = x-dx_l, x+dx_r do for _y=y1,y2 do c:Pixel(_x, _y, color) end end end function cnv:cd_vline(x, y1, y2, mode, color) local c = self.canvas c:WriteMode(mode) c:LineWidth(self.line_width) c:Foreground(color) c:LineJoin(self.line_join) c:LineCap(self.line_cap) c:Line(x,y1,x,y2) end -- draw vertical bar function cnv:draw_vline(x) local c = self.canvas c:Activate() c:Background(cd.WHITE) c:Clear() local w,h = c:GetSize() local y1 = 0 + self.line_bpad local y2 = h - 1 - self.line_tpad -- emulated line via cd.Pixel only local xx = x - 30 self:emulate_vline(xx, y1, y2, self.line_width, cd.REPLACE, cd.BLACK) -- emulated line via cd.Pixel local xx = x - 20 self:emulate_vline(xx, y1, y2, self.line_width, cd.REPLACE, cd.BLACK) -- and XOR cd.Line over emulated line self:cd_vline(xx, y1, y2, cd.XOR, cd.CYAN) -- and back to front -- FILL cd.Line local xx = x - 10 self:cd_vline(xx, y1, y2, cd.REPLACE, cd.BLACK) -- and xor emulated line over it self:emulate_vline(xx, y1, y2, self.line_width, cd.XOR, cd.CYAN) -- original self:cd_vline(x, y1, y2, self.write_mode, cd.CYAN) c:Deactivate() end function cnv:move_vline(x, y) local w,h = self.canvas:GetSize() if x >= 0 and x < w then local _x = self.old_x or x if _x ~= x then self:draw_vline(_x) _x = x end self:draw_vline(x) self.old_x = _x end end function cnv:button_cb(but, pressed, x, y, status) if but == iup.BUTTON1 then self.old_x = pressed == 1 and x self:draw_vline(x) end end function cnv:motion_cb(x, y, status) if status:sub(3,3) == "1" then self:move_vline(x) end end local dlg = iup.dialog { iup.frame{ iup.vbox{ margin = "2x2", -- canvas iup.hbox{ cnv, iup.vbox{ margin = "0x0", iup.frame{ title = "LineWidth", iup.vbox{ margin = "10x", iup.fill{}, iup.text{ visiblecolumns = 2, spin = "YES", spinmin = 1, spin_cb = function (self, pos) cnv.line_width = pos end, }, iup.fill{}, }, }, }, iup.vbox{ iup.frame{ title = "Top Pad", iup.vbox{ margin = "10x", iup.fill{}, iup.text{ visiblecolumns = 2, spin = "YES", spinmin = 0, spinvalue = 4, spin_cb = function (self, pos) cnv.line_tpad = pos end, }, iup.fill{}, }, }, iup.frame{ title = "Bottom Pad", iup.vbox{ margin = "10x", iup.fill{}, iup.text{ visiblecol
Re: [Iup-users] canvas line
Hi, Thanks to your very interesting sample code was very easy to identify the problem. There are two things happening. An extra pixel in white at the top. And missing pixels at bottom. The second case occurs in REPLACE and XOR modes. And it is inherent of the Win32 API. The extra pixel at the top was a bug in CD. We draw an extra pixel to complement the line drawn by the Win32 API. But when line width is more than one it looks odd. And when in XOR it looks worse. So I just add a test to avoid those situations. Fixed and committed to CVS. Thanks for the report and for the sample code. Best, Scuri > -Original Message- > From: Karagy [mailto:kar...@mail.ru] > Sent: quinta-feira, 12 de dezembro de 2013 16:30 > To: IUP discussion list. > Subject: [Iup-users] canvas line > > Hi, all! > > WinXP 32bit, iuplua 3.6 - 3.9. > Playing with iup.canvas, I found that the ends of the vertical lines near the > boundaries of the canvas looks strange. The effect becomes noticeable for a > line width of 2 or more. Unpainted point becomes visible at the upper end of > the line. At the lower end of the line appears vertical indentation height 1. > Effect does not depend on the presence of border canvas. > > See example in attach. > > > -- > Regards, > > Karagy -- Rapidly troubleshoot problems before they affect your business. Most IT organizations don't have a clear picture of how application performance affects their revenue. With AppDynamics, you get 100% visibility into your Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro! http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk ___ Iup-users mailing list Iup-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/iup-users
Re: [Iup-users] canvas line
Sorry, I forgot to explain - in this example, a line will appear if you press the left mouse button on canvas. -- Rapidly troubleshoot problems before they affect your business. Most IT organizations don't have a clear picture of how application performance affects their revenue. With AppDynamics, you get 100% visibility into your Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro! http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk ___ Iup-users mailing list Iup-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/iup-users
Re: [Iup-users] canvas line
In attach. Please send me a screenshot so I know what to expect here. WBR, Karagy <>-- Rapidly troubleshoot problems before they affect your business. Most IT organizations don't have a clear picture of how application performance affects their revenue. With AppDynamics, you get 100% visibility into your Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro! http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk___ Iup-users mailing list Iup-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/iup-users
Re: [Iup-users] canvas line
Please send me a screenshot so I know what to expect here. Best, Scuri > -Original Message- > From: Karagy [mailto:kar...@mail.ru] > Sent: quinta-feira, 12 de dezembro de 2013 16:30 > To: IUP discussion list. > Subject: [Iup-users] canvas line > > Hi, all! > > WinXP 32bit, iuplua 3.6 - 3.9. > Playing with iup.canvas, I found that the ends of the vertical lines near the > boundaries of the canvas looks strange. The effect becomes noticeable for a > line width of 2 or more. Unpainted point becomes visible at the upper end of > the line. At the lower end of the line appears vertical indentation height 1. > Effect does not depend on the presence of border canvas. > > See example in attach. > > > -- > Regards, > > Karagy -- Rapidly troubleshoot problems before they affect your business. Most IT organizations don't have a clear picture of how application performance affects their revenue. With AppDynamics, you get 100% visibility into your Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro! http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk ___ Iup-users mailing list Iup-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/iup-users
Re: [Iup-users] canvas line
Failed to specify: only for cd.XOR WriteMode. -- Rapidly troubleshoot problems before they affect your business. Most IT organizations don't have a clear picture of how application performance affects their revenue. With AppDynamics, you get 100% visibility into your Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro! http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk ___ Iup-users mailing list Iup-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/iup-users
[Iup-users] canvas line
Hi, all! WinXP 32bit, iuplua 3.6 - 3.9. Playing with iup.canvas, I found that the ends of the vertical lines near the boundaries of the canvas looks strange. The effect becomes noticeable for a line width of 2 or more. Unpainted point becomes visible at the upper end of the line. At the lower end of the line appears vertical indentation height 1. Effect does not depend on the presence of border canvas. See example in attach. -- Regards, Karagy require "cdlua" require "iuplua" require "iupluacd" local debug_width = iup.label{ size = "50x", } function debug_width:set(val) self.title = string.format("Width: %5i", val) end local debug_height = iup.label{ size = "50x", } function debug_height:set(val) self.title = string.format("Height: %5i", val) end local debug_x = iup.label{ size = "50x", } function debug_x:set(val) self.title = string.format("X: %5i", val) end local debug_y1 = iup.label{ size = "50x", } function debug_y1:set(val) self.title = string.format("Y: %5i", val) end local debug_y2 = iup.label{ size = "50x", } function debug_y2:set(val) self.title = string.format("Y: %5i", val) end local debug_write_mode = iup.label{ size = "100x", } function debug_write_mode:set(val) self.title = string.format("WriteMode: %s", val) end local debug_line_color = iup.label{ size = "100x", } function debug_line_color:set(val) self.title = string.format("COLOR: r:%i g:%i b:%i", cd.DecodeColor(val)) end local debug_line_join = iup.label{ size = "100x", } function debug_line_join:set(val) self.title = string.format("LineJoin: %i", val) end local debug_line_cap = iup.label{ size = "100x", } function debug_line_cap:set(val) self.title = string.format("LineCap: %i", val) end local cnv = iup.canvas { rastersize = "x24", expand = "HORIZONTAL", --border = "NO", -- user-defined attrs line_width = 1, write_mode = cd.XOR, line_join = cd.MITER, line_cap = cd.CAPFLAT, line_color = cd.EncodeColor(0, 255, 255), } function cnv:map_cb() self.canvas = cd.CreateCanvas(cd.IUP, self) end -- draw vertical bar function cnv:draw_vline(x) local c = self.canvas c:Activate() local w,h = c:GetSize() debug_width:set(w) debug_height:set(h) local y1, y2 = 0, h-1 debug_x:set(x) debug_y1:set(y1) debug_y2:set(y2) c:WriteMode(self.write_mode) c:LineWidth(self.line_width) c:Foreground(self.line_color) c:LineJoin(self.line_join) c:LineCap(self.line_cap) debug_line_color:set(c:Foreground(cd.QUERY)) debug_write_mode:set(c:WriteMode(cd.QUERY)) debug_line_join:set(c:LineJoin(cd.QUERY)) debug_line_cap:set(c:LineCap(cd.QUERY)) c:Line(x,y1,x,y2) c:Deactivate() end function cnv:move_vline(x) local w,h = self.canvas:GetSize() if x >= 0 and x < w then local _x = self.old_x or x if _x ~= x then self:draw_vline(_x) _x = x end self:draw_vline(x) self.old_x = _x end end function cnv:button_cb(but, pressed, x, y, status) if but == iup.BUTTON1 then self.old_x = pressed == 1 and x self:draw_vline(x) end end function cnv:motion_cb(x, y, status) if status:sub(3,3) == "1" then self:move_vline(x) end end local dlg = iup.dialog { iup.frame{ iup.vbox{ margin = "2x2", -- canvas iup.hbox{ cnv, }, iup.hbox{ iup.frame{ title = "LineWidth", iup.vbox{ margin = "10x", iup.fill{}, iup.text{ visiblecolumns = 2, spin = "YES", spinmin = 1, spin_cb = function (self, pos) cnv.line_width = pos end, }, iup.fill{}, }, }, iup.frame{ title = "WriteMode", iup.radio{ iup.vbox{ iup.toggle{ title="XOR", action = function (self, state) if state == 1 then cnv.write_mode = cd.XOR end end, }, iup.toggle{ title="REPLACE", action = function (self, state) if state == 1 then cnv.write_mode = cd.REPLACE end end, },