Phoenix icon indicating copy to clipboard operation
Phoenix copied to clipboard

with negative size draw GCDC/DC DrawRoundedRectangle different.

Open yiyunzhi opened this issue 2 years ago • 3 comments

Operating system: Win10 wxPython version & source: v4.1.1 Python version & source: v3.8

Description of the problem: Hi, anyone found this difference?

with paintDC size=(100,-100):

class TestPanel(wx.Panel):
    def __init__(self, parent, wx_id=wx.ID_ANY, style=0):
        wx.Panel.__init__(self, parent, wx_id, style=style)
        # bind event
        self.Bind(wx.EVT_PAINT, self.on_paint)

    def on_paint(self, evt):
        _dc = wx.PaintDC(self)
        _dc .SetPen(wx.BLACK_PEN)
        _dc .DrawRoundedRectangle(200, 200, 100, -100, 10)

result looks like: image with GCDC size=(100,-100):

class TestPanel(wx.Panel):
    def __init__(self, parent, wx_id=wx.ID_ANY, style=0):
        wx.Panel.__init__(self, parent, wx_id, style=style)
        # bind event
        self.Bind(wx.EVT_PAINT, self.on_paint)

    def on_paint(self, evt):
        _dc = wx.PaintDC(self)
        _dc = wx.GCDC(_dc)
        _dc .SetPen(wx.BLACK_PEN)
        _dc .DrawRoundedRectangle(200, 200, 100, -100, 10)

image

yiyunzhi avatar May 06 '22 08:05 yiyunzhi

The documentation does not mention negative sizes. I would say, it's not supported and I don't see the motivation why anyone would like to use negative sizes. It's definitely a wxWidgets behaviour. I have compiled the wxWidgets "drawing" sample and it behaves the same. Whether you use GCDC or not you are using different graphics implementations which obviously behave differently.

DietmarSchwertberger avatar May 06 '22 20:05 DietmarSchwertberger

Thanks for replying. 1: the mention of negative Size actually exist in the docu, but for DrawRectangle only. https://wxpython.org/Phoenix/docs/html/wx.DC.html?highlight=setlayoutdirection#wx.DC.DrawRectangle image 2: the motivation. firstly I think also no neccesary to using the negative size, until I read the sourcecode of Floatcanvas. They need a transformvector (ScaleWorldToPixel()) and the to transforming the coordinate. Then the negative size was out given. ps: N is numpy.

 self.TransformVector = N.array( (1,-1), N.float)

image

yiyunzhi avatar May 07 '22 07:05 yiyunzhi

Coordinate transformations are doing exactly this: they transform coordinates. They do not transform widths or heights. They do not necessarily preserve angles. So transforming coordinates for a rectangle is pointless. You need a polygon and draw it yourself after the transformation. Anyway, this is a bug tracker, not a discussion forum. For this there is discuss.wxpython.org.

DietmarSchwertberger avatar May 07 '22 10:05 DietmarSchwertberger