예제 #1
0
파일: points.py 프로젝트: thatpixguy/fab
    def draw(self, canvas):
        ''' Draws a free point on the canvas.
        
            The point is drawn with small handles showing the axes along
            which it can be dragged.
        '''
            
        x, y = canvas.pos_to_pixel(self.x, self.y)
        
        dark_grey   = (60, 60, 60)
        light_grey  = (100, 100, 100)

            
        # If the vertex is being dragged, draw small 
        # arrows to show in which ways it is free
        if self.valid and (self.dragging or self.hover):
                        
            canvas.SetPen(self.light_color if self._x_free else light_grey, 8)
            canvas.dc.DrawLine(x-10, y, x+10, y)

            canvas.SetPen(self.light_color if self._y_free else light_grey, 8)
            canvas.dc.DrawLine(x, y-10, x, y+10)
                
            canvas.SetPen(self.dark_color if self._x_free else dark_grey, 4)
            canvas.dc.DrawLine(x-10, y, x+10, y)
            
            canvas.SetPen(self.dark_color if self._y_free else dark_grey, 4)
            canvas.dc.DrawLine(x, y-10, x, y+10)
        
        Point.draw(self, canvas)
예제 #2
0
파일: points.py 프로젝트: thatpixguy/fab
    def draw(self, canvas):
    
        x, y = canvas.pos_to_pixel(self.x, self.y)

        dark_grey   = (60, 60, 60)
        light_grey  = (100, 100, 100)
    
        if self.valid:
            canvas.SetPen(self.dark_color, 4, wx.LONG_DASH)
            canvas.SetBrush(self.dark_color)
            self.arrow_from(self.parent)
    
        if self.valid and (self.dragging or self.hover):

            x0 = x - math.cos(self.angle)*10
            x1 = x + math.cos(self.angle)*10
            y0 = y + math.sin(self.angle)*10
            y1 = y - math.sin(self.angle)*10
            if self._offset_free:
                canvas.SetPen(self.light_color, 8)
                canvas.dc.DrawLine(x0, y0, x1, y1)
                canvas.SetPen(self.dark_color, 4)
                canvas.dc.DrawLine(x0, y0, x1, y1)
            else:
                canvas.SetPen(light_grey, 8)
                canvas.dc.DrawLine(x0, y0, x1, y1)
                canvas.SetPen(dark_grey, 4)
                canvas.dc.DrawLine(x0, y0, x1, y1)                
        
        Point.draw(self, canvas)