SVGFileDC line and arch drawing support

ABC <[email protected]> Sat, 16 Mar 2019 14:49:24 -0700 (PDT)
Newsgroups gmane.comp.python.wxpython.devel
Message-ID <[email protected]>
When drawing to SVGFileDC,
DrawLine() last pixel is one pixel too far.
With the enclosed script, 
- left-most vertical red line should end ON the black horizontal line, but 
SVG shows it ending 1 pixel BELOW.
- 2nd from left vertical red line should end just ABOVE the bottom hor. 
line, but SVG shows it ending ON the hor. line.

DrawArc() with a transparent brush should NOT shows radiuses, but SVG does 
show them.
With the enclosed script, the left arch is drawn with transparent brush, 
while the right arch is not (shown correctly with SVG).

-- 
You received this message because you are subscribed to the Google Groups "wxPython-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.
screen_arch_line.png (image/png, 5.5 KB) - not displayed
svg_arch_line.png (image/png, 5 KB) - not displayed
svg_arch_line.py (text/x-python, 2 KB)
import wx

class DrawPanel(wx.Frame):
    def __init__(self, height_, width_):
        wx.Frame.__init__(self, None, title="Draw on Panel")
        self.Bind(wx.EVT_PAINT, self.OnPaint)
        self.height = height_
        self.width  = width_
        
    def draw(self, dc_):
        # hor lines
        dc_.SetPen(wx.Pen(wx.BLACK, 1, wx.SOLID))
        dc_.DrawLine(0,   0, 300,   0)   # x1,y1 upto but not incl. x2,y2
        dc_.DrawLine(0, 100, 300, 100)
        dc_.DrawLine(0, 200, 300, 200)

        # vert lines
        dc_.SetPen(wx.Pen(wx.RED, 1, wx.SOLID))
        dc_.DrawLine(25,   0, 25, 101)   # last pixel is ON the hor. line

        dc_.SetPen(wx.Pen(wx.RED, 1, wx.SOLID))
        dc_.DrawLine(50, 100, 50, 200)   # last pixel is ABOVE the hor. line

        dc_.SetPen(wx.Pen(wx.BLACK, 1, wx.SOLID))
        dc_.DrawLine(100, 0, 100, 100)
        dc_.DrawLine(200, 0, 200, 100)

        # arch, drawn counter-clockwise direction from x1,y1 to x2,y2
        dc_.SetPen(wx.Pen(wx.RED, 1))
        dc_.SetBrush(wx.TRANSPARENT_BRUSH)   # don't show radius lines!
        dc_.DrawArc(200,   0,  # x1, y1 start point
                    100, 100,  # x2, y2 end   point
                    200, 100)  # xc, yc circle center

        dc_.SetPen(wx.Pen(wx.RED, 1))
        dc_.SetBrush(wx.Brush(wx.YELLOW))   # show radius lines
        dc_.DrawArc(300,   0,  # x1, y1 start point
                    200, 100,  # x2, y2 end   point
                    300, 100)  # xc, yc circle center
    # end draw
    
    def OnPaint(self, event=None):
        dc = wx.PaintDC(self)
        dc.Clear()
        self.draw(dc)

        svgfile = wx.SVGFileDC('svg_arch_line.svg', width = self.width, height = self.height)
        self.draw(svgfile)
        svgfile.Destroy()   # to close the output file
    # end OnPaint

# main
app   = wx.App(False)
frame_h = 201
frame_w = 301
frame = DrawPanel(frame_h, frame_w)
frame.SetClientSize((frame.width, frame.height))   # sets the size of the INSIDE of a window
frame.Show()
app.MainLoop()