python类Pen()的实例源码

plot.py 文件源码 项目:bonsu 作者: bonsudev 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def draw(self, dc, printerScale, coord=None):
        colour = self.attributes['colour']
        width = self.attributes['width'] * printerScale * self._pointSize[0]
        style = self.attributes['style']
        if not isinstance(colour, wx.Colour):
            colour = wx.Colour(colour)
        pen = wx.Pen(colour, width, style)
        pen.SetCap(wx.CAP_ROUND)
        dc.SetPen(pen)
        if coord == None:
            if len(self.scaled):  # bugfix for Mac OS X
                dc.DrawSpline(self.scaled)
        else:
            dc.DrawLines(coord)  # draw legend line
plot.py 文件源码 项目:bonsu 作者: bonsudev 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def _drawRubberBand(self, corner1, corner2):
        """Draws/erases rect box from corner1 to corner2"""
        ptx, pty, rectWidth, rectHeight = self._point2ClientCoord(
            corner1, corner2)
        # draw rectangle
        dc = wx.ClientDC(self.canvas)
        dc.SetPen(wx.Pen(wx.BLACK))
        dc.SetBrush(wx.Brush(wx.WHITE, wx.BRUSHSTYLE_TRANSPARENT))
        dc.SetLogicalFunction(wx.INVERT)
        dc.DrawRectangle(ptx, pty, rectWidth, rectHeight)
        dc.SetLogicalFunction(wx.COPY)
grabcut_tol.py 文件源码 项目:opencv-plgs 作者: Image-Py 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def draw(self, dc, f, **key):
        dc.SetPen(wx.Pen((255,0,0), width=2, style=wx.SOLID))
        for line in self.foreline: dc.DrawLines([f(*i) for i in line])
        dc.SetPen(wx.Pen((0,0,255), width=2, style=wx.SOLID))
        for line in self.backline: dc.DrawLines([f(*i) for i in line])
wx_2048_02.py 文件源码 项目:python_2048 作者: OATOMO 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def drawBg(self,dc):
        dc.SetBackground(wx.Brush((250,248,239)))   #????
        dc.Clear()
        dc.SetBrush(wx.Brush((187,173,160)))        #????
        dc.SetPen(wx.Pen((187,173,160)))            #??pen
        dc.DrawRoundedRectangle(15,150,475,475,5)   #??
RubberBand.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def DrawBoundingBoxes(self, bboxes, dc=None):
        """
        Draw a list of bounding box on Viewer in the order given using XOR
        logical function
        @param bboxes: List of bounding boxes to draw on viewer
        @param dc: Device Context of Viewer (default None)
        """
        # Get viewer Device Context if not given
        if dc is None:
            dc = self.Viewer.GetLogicalDC()

        # Save current viewer scale factors before resetting them in order to
        # avoid rubberband pen to be scaled
        scalex, scaley = dc.GetUserScale()
        dc.SetUserScale(1, 1)

        # Set DC drawing style
        dc.SetPen(wx.Pen(wx.WHITE, style=wx.DOT))
        dc.SetBrush(wx.TRANSPARENT_BRUSH)
        dc.SetLogicalFunction(wx.XOR)

        # Draw the bounding boxes using viewer scale factor
        for bbox in bboxes:
            if bbox is not None:
                dc.DrawRectangle(
                    bbox.x * scalex, bbox.y * scaley,
                    bbox.width * scalex, bbox.height * scaley)

        dc.SetLogicalFunction(wx.COPY)

        # Restore Viewer scale factor
        dc.SetUserScale(scalex, scaley)
GraphicCommons.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def MiterPen(colour, width=1, style=wx.SOLID):
    pen = wx.Pen(colour, width, style)
    pen.SetJoin(wx.JOIN_MITER)
    pen.SetCap(wx.CAP_PROJECTING)
    return pen


# -------------------------------------------------------------------------------
#                    Helpers for highlighting text
# -------------------------------------------------------------------------------
ovalroi.py 文件源码 项目:imagepy 作者: Image-Py 项目源码 文件源码 阅读 15 收藏 0 点赞 0 评论 0
def draw(self, dc, f):
        dc.SetPen(wx.Pen(RoiManager.get_color(), width=RoiManager.get_lw(), style=wx.SOLID))
        if len(self.body)>1:
            dc.DrawLines([f(*i) for i in self.body])
        for i in [self.lt, (self.lt+self.rt)/2, self.rt]:
            for j in [self.tp, (self.tp+self.bm)/2, self.bm]:
                dc.DrawCircle(f(i,j),2)
lineroi.py 文件源码 项目:imagepy 作者: Image-Py 项目源码 文件源码 阅读 15 收藏 0 点赞 0 评论 0
def draw(self, dc, f):
        dc.SetPen(wx.Pen(RoiManager.get_color(), width=RoiManager.get_lw(), style=wx.SOLID))
        for line in self.body:
            if len(line)>1:
                dc.DrawLines([f(*i) for i in line])
                for i in line:dc.DrawCircle(f(*i),2)
rectangleroi.py 文件源码 项目:imagepy 作者: Image-Py 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def draw(self, dc, f):
        dc.SetPen(wx.Pen(RoiManager.get_color(), width=RoiManager.get_lw(), style=wx.SOLID))
        if(len(self.body)>1):
            dc.DrawLines([f(*i) for i in self.body])
        for i in self.body:dc.DrawCircle(f(*i),2)
        dc.DrawCircle(f(self.lt, (self.tp+self.bm)/2),2)
        dc.DrawCircle(f(self.rt, (self.tp+self.bm)/2),2)
        dc.DrawCircle(f((self.lt+self.rt)/2, self.tp),2)
        dc.DrawCircle(f((self.lt+self.rt)/2, self.bm),2)
pointroi.py 文件源码 项目:imagepy 作者: Image-Py 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def draw(self, dc, f):
        dc.SetPen(wx.Pen(RoiManager.get_color(), width=RoiManager.get_lw(), style=wx.SOLID))
        for i in self.body:
            dc.DrawCircle(f(*i), 2)
polygonroi.py 文件源码 项目:imagepy 作者: Image-Py 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def draw(self, dc, f):
        dc.SetPen(wx.Pen(RoiManager.get_color(), width=RoiManager.get_lw(), style=wx.SOLID))
        for pg in self.body:
            dc.DrawLines([f(*i) for i in pg[0]])
            if self.issimple():
                for i in pg[0]: dc.DrawCircle(f(*i),2)
            for hole in pg[1]:
                dc.DrawLines([f(*i) for i in hole])
canvas.py 文件源码 项目:imagepy 作者: Image-Py 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def draw_ruler(self, dc):
        dc.SetPen(wx.Pen((255,255,255), width=2, style=wx.SOLID))
        x1 = max(self.imgbox[0], self.box[0])+5
        x2 = min(self.imgbox[2], self.box[2])+x1-10
        pixs = (x2-x1+10)*self.ips.size[1]/10.0/self.imgbox[2]
        h = min(self.imgbox[1]+self.imgbox[3],self.box[3])-5
        dc.DrawLineList([(x1,h,x2,h)])
        dc.DrawLineList([(i,h,i,h-8) for i in np.linspace(x1, x2, 3)])
        dc.DrawLineList([(i,h,i,h-5) for i in np.linspace(x1, x2, 11)])

        dc.SetTextForeground((255,255,255))
        k, unit = self.ips.unit
        text = 'Unit = %.1f %s'%(k*pixs, unit)
        dw,dh = dc.GetTextExtent(text)
        dc.DrawText(text, (x2-dw, h-10-dh))
plotwindow.py 文件源码 项目:imagepy 作者: Image-Py 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def draw_coord(self, dc, w, h, l, t, r, b):
        xs = [5, 10, 20, 40, 50, 100, 200, 400, 500, 1000, 2000, 4000, 10000]
        n, dx, dy = len(self.data), 0, 0
        left, low, right, high = self.extent
        for i in xs[::-1]: 
            if (right-left)*1.0/i<=10:dx=i
        for i in xs[::-1]: 
            if (high-low)*1.0/i<=10:dy=i
        dc.SetPen(wx.Pen((0, 0, 0), width=1, style=wx.SOLID))
        dc.DrawRectangle(l, t, w+1, h+1)
        dc.SetPen(wx.Pen((100, 100, 100), width=1, style=wx.SOLID))
        for i in range(int(ceil(left*1.0/dx)*dx), int(right)+1, dx):
            x = l+(i-left)*1.0/(right-left)*w
            dc.DrawLine(x, t, x, t+h)
            dc.DrawText(str(i), x-5, t+h)
        for i in range(int(ceil(low*1.0/dy)*dy), int(high)+1, dy):
            y = h+t-(i-low)*1.0/(high-low)*h
            dc.DrawLine(l, y, l+w, y)
            dc.DrawText(str(i), 5, y-5)

        titlefont = wx.Font(18, wx.FONTFAMILY_DEFAULT, 
                       wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False)
        dc.SetFont(titlefont)
        dw,dh = dc.GetTextExtent(self.title)
        dc.DrawText(self.title, l+w/2-dw/2, 3)

        lablelfont = wx.Font(14, wx.FONTFAMILY_DEFAULT, 
                       wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False)
        dc.SetFont(lablelfont)
        dw,dh = dc.GetTextExtent(self.labelx)
        dc.DrawText(self.labelx, l+w-dw, t+h+15)
        dc.DrawText(self.labely, 5, 10)
graph_plgs.py 文件源码 项目:imagepy 作者: Image-Py 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def draw(self, dc, f, **key):
        dc.SetPen(wx.Pen((255,255,0), width=3, style=wx.SOLID))
        dc.SetTextForeground((255,255,0))
        font = wx.Font(8, wx.FONTFAMILY_DEFAULT, 
                       wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False)
        dc.SetFont(font)

        ids = self.graph.nodes()
        pts = [self.graph.node[i]['o'] for i in ids]
        pts = [f(i[1], i[0]) for i in pts]
        dc.DrawPointList(pts)
        dc.DrawTextList([str(i) for i in ids], pts)
orthogonal_plg.py 文件源码 项目:imagepy 作者: Image-Py 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def draw(self, dc, f):
        print(self.x, self.y)
        dc.SetPen(wx.Pen((255,255,0), width=1, style=wx.SOLID))
        dc.DrawLines([f(0,self.y),f(self.w,self.y)])
        dc.DrawLines([f(self.x,0),f(self.x,self.h)])
rotate_tol.py 文件源码 项目:imagepy 作者: Image-Py 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def draw(self, dc, f, **key):
        dc.SetPen(wx.Pen((0,255,0), width=1, style=wx.SOLID))
        sox, soy = f(self.para['ox'], self.para['oy'])
        dc.DrawCircle((sox, soy), 5)
        a = np.linspace(0, 2*np.pi, 20)
        dc.DrawLines(list(zip(sox+np.cos(a)*40, soy+np.sin(a)*40)))
        a = self.para['ang']*np.pi/180
        dc.DrawCircle((sox+np.cos(a)*40, soy+np.sin(a)*40), 3)
scale_tol.py 文件源码 项目:imagepy 作者: Image-Py 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def draw(self, dc, f, **key):
        body = [(self.lt,self.bm),(self.rt,self.bm),
                (self.rt,self.tp),(self.lt,self.tp),(self.lt,self.bm)]
        dc.SetPen(wx.Pen((0,255,0), width=1, style=wx.SOLID))
        dc.DrawLines([f(*i) for i in body])
        for i in body:dc.DrawCircle(f(*i),2)
        dc.DrawCircle(f(self.lt, (self.tp+self.bm)/2),2)
        dc.DrawCircle(f(self.rt, (self.tp+self.bm)/2),2)
        dc.DrawCircle(f((self.lt+self.rt)/2, self.tp),2)
        dc.DrawCircle(f((self.lt+self.rt)/2, self.bm),2)
graphpen_tol.py 文件源码 项目:imagepy 作者: Image-Py 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def draw(self, dc, f, **key):
        dc.SetPen(wx.Pen((255,0,0), width=2, style=wx.SOLID))
        dc.DrawLines([f(*i) for i in self.line])
polygon_tol.py 文件源码 项目:imagepy 作者: Image-Py 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def draw(self, dc, f, **key):
        dc.SetPen(wx.Pen((0,255,0), width=1, style=wx.SOLID))
        if len(self.buf[0])>1:
            dc.DrawLines([f(*i) for i in self.buf[0]])
        for i in self.buf[0]: dc.DrawCircle(f(*i),2)
freeline_tol.py 文件源码 项目:imagepy 作者: Image-Py 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def draw(self, dc, f, **key):
        dc.SetPen(wx.Pen((0,255,255), width=1, style=wx.SOLID))
        if len(self.buf)>1:
            dc.DrawLines([f(*i) for i in self.buf])
        for i in self.buf:dc.DrawCircle(f(*i),2)


问题


面经


文章

微信
公众号

扫码关注公众号