コード例 #1
0
    def draw_circle_filled(self, clr, pt, radius, angle=0):
        x, y = pt

        clr = tools.rgb2floats(clr)
        self.ctx.set_source_rgb(*clr)
        self.ctx.move_to(x, y)
        self.ctx.arc(x, y, radius, 0, 2 * 3.1415)
        self.ctx.fill()
コード例 #2
0
ファイル: drawing.py プロジェクト: alcemirfernandes/Pippy
    def draw_circle_filled(self, clr, pt, radius, angle=0):
        x, y = pt

        clr = tools.rgb2floats(clr)
        self.ctx.set_source_rgb(*clr)
        self.ctx.move_to(x, y)
        self.ctx.arc(x, y, radius, 0, 2*3.1415)
        self.ctx.fill()
コード例 #3
0
ファイル: drawing.py プロジェクト: alcemirfernandes/Pippy
    def draw_text(self, text, center, clr=(0,0,0), size=12, fontname="Georgia"):
        clr = tools.rgb2floats(clr)
        self.ctx.set_source_rgb(clr[0], clr[1], clr[2])

        self.ctx.select_font_face(fontname, self.cairo.FONT_SLANT_NORMAL, self.cairo.FONT_WEIGHT_NORMAL)
        self.ctx.set_font_size(size)
        x_bearing, y_bearing, width, height = self.ctx.text_extents(text)[:4]
        self.ctx.move_to(center[0] + 0.5 - width / 2 - x_bearing, center[1] + 0.5 - height / 2 - y_bearing)
        self.ctx.show_text(text)
コード例 #4
0
ファイル: drawing.py プロジェクト: alcemirfernandes/Pippy
    def draw_circle(self, clr, pt, radius, a=0):
        clr = tools.rgb2floats(clr)
    	self.gl.glColor3f(clr[0], clr[1], clr[2])

        x, y = pt
    	segs = 15
    	coef = 2.0*pi/segs;
    	
    	self.gl.glBegin(self.gl.GL_LINE_LOOP)
    	for n in range(segs):
    		rads = n*coef
    		self.gl.glVertex2f(radius*cos(rads + a) + x, radius*sin(rads + a) + y)
    	self.gl.glVertex2f(x,y)
    	self.gl.glEnd()
コード例 #5
0
    def draw_circle(self, clr, pt, radius, a=0):
        clr = tools.rgb2floats(clr)
        self.gl.glColor3f(clr[0], clr[1], clr[2])

        x, y = pt
        segs = 15
        coef = 2.0 * pi / segs

        self.gl.glBegin(self.gl.GL_LINE_LOOP)
        for n in range(segs):
            rads = n * coef
            self.gl.glVertex2f(radius * cos(rads + a) + x,
                               radius * sin(rads + a) + y)
        self.gl.glVertex2f(x, y)
        self.gl.glEnd()
コード例 #6
0
    def draw_text(self,
                  text,
                  center,
                  clr=(0, 0, 0),
                  size=12,
                  fontname="Georgia"):
        clr = tools.rgb2floats(clr)
        self.ctx.set_source_rgb(clr[0], clr[1], clr[2])

        self.ctx.select_font_face(fontname, self.cairo.FONT_SLANT_NORMAL,
                                  self.cairo.FONT_WEIGHT_NORMAL)
        self.ctx.set_font_size(size)
        x_bearing, y_bearing, width, height = self.ctx.text_extents(text)[:4]
        self.ctx.move_to(center[0] + 0.5 - width / 2 - x_bearing,
                         center[1] + 0.5 - height / 2 - y_bearing)
        self.ctx.show_text(text)
コード例 #7
0
ファイル: drawing.py プロジェクト: alcemirfernandes/Pippy
    def draw_polygon(self, clr, points):
        """ Draw a polygon
        
            Parameters:
              clr ....... color in rgb ((r), (g), (b))
              points .... polygon points in normal (x,y) positions
              
            Return: -
        """        
        clr = tools.rgb2floats(clr)
        self.ctx.set_source_rgb(clr[0], clr[1], clr[2])

        pt = points[0]
        self.ctx.move_to(pt[0], pt[1])
        for pt in points[1:]:
            self.ctx.line_to(pt[0], pt[1])
            
        self.ctx.fill()
コード例 #8
0
    def draw_polygon(self, clr, points):
        """ Draw a polygon
        
            Parameters:
              clr ....... color in rgb ((r), (g), (b))
              points .... polygon points in normal (x,y) positions
              
            Return: -
        """
        clr = tools.rgb2floats(clr)
        self.ctx.set_source_rgb(clr[0], clr[1], clr[2])

        pt = points[0]
        self.ctx.move_to(pt[0], pt[1])
        for pt in points[1:]:
            self.ctx.line_to(pt[0], pt[1])

        self.ctx.fill()
コード例 #9
0
ファイル: drawing.py プロジェクト: alcemirfernandes/Pippy
    def draw_polygon(self, clr, points):
        clr = tools.rgb2floats(clr)
    	self.gl.glColor3f(clr[0], clr[1], clr[2])
    	
        self.gl.glBegin(self.gl.GL_LINES)

        p1 = points[0]
        for p in points[1:]:
            x1, y1 = p1
            x2, y2 = p1 = p
            
            self.gl.glVertex2f(x1, y1)
            self.gl.glVertex2f(x2, y2)

        x1, y1 = points[0]
        
        self.gl.glVertex2f(x2, y2)
        self.gl.glVertex2f(x1, y1)

        self.gl.glEnd()
コード例 #10
0
    def draw_polygon(self, clr, points):
        clr = tools.rgb2floats(clr)
        self.gl.glColor3f(clr[0], clr[1], clr[2])

        self.gl.glBegin(self.gl.GL_LINES)

        p1 = points[0]
        for p in points[1:]:
            x1, y1 = p1
            x2, y2 = p1 = p

            self.gl.glVertex2f(x1, y1)
            self.gl.glVertex2f(x2, y2)

        x1, y1 = points[0]

        self.gl.glVertex2f(x2, y2)
        self.gl.glVertex2f(x1, y1)

        self.gl.glEnd()
コード例 #11
0
ファイル: drawing.py プロジェクト: alcemirfernandes/Pippy
    def draw_lines(self, clr, closed, points):
        """ Draw a polygon
        
            Parameters:
              clr ....... color in rgb ((r), (g), (b))
              closed .... whether or not to close the lines (as a polygon)
              points .... polygon points in normal (x,y) positions
            Return: -
        """        
        clr = tools.rgb2floats(clr)
        self.ctx.set_source_rgb(clr[0], clr[1], clr[2])

        pt = points[0]
        self.ctx.move_to(pt[0], pt[1])
        for pt in points[1:]:
            self.ctx.line_to(pt[0], pt[1])

        if closed:
            pt = points[0]
            self.ctx.line_to(pt[0], pt[1])

        self.ctx.stroke()
コード例 #12
0
    def draw_lines(self, clr, closed, points):
        """ Draw a polygon
        
            Parameters:
              clr ....... color in rgb ((r), (g), (b))
              closed .... whether or not to close the lines (as a polygon)
              points .... polygon points in normal (x,y) positions
            Return: -
        """
        clr = tools.rgb2floats(clr)
        self.ctx.set_source_rgb(clr[0], clr[1], clr[2])

        pt = points[0]
        self.ctx.move_to(pt[0], pt[1])
        for pt in points[1:]:
            self.ctx.line_to(pt[0], pt[1])

        if closed:
            pt = points[0]
            self.ctx.line_to(pt[0], pt[1])

        self.ctx.stroke()