Exemple #1
0
    def __init__(self, change_colors):
        page.Page.__init__(self)
        self.title = 'Line'

        # Simple line
        self.line = cccanvas.Line()
        self.line.move(5.0,5.0)
        self.line.line(95.0, 95.0)


        #circle
        self.circle = cccanvas.Circle()
        self.circle.set_anchor(50.0, 50.0)
        self.circle.set_radius(20)
        self.brush_green = cccanvas.BrushColor(cccanvas.color_new_rgb(0.0,1.0,0.0))
        self.circle.set_brush_border(cccanvas.BrushColor(cccanvas.color_new_rgb(0.0,1.0,0.0)))

        # colors for the line and the rect
        self.colors = [ cccanvas.color_new_rgb(1.0,0.0,0.0),
                        cccanvas.color_new_rgb(0.0,0.0,1.0) ]

        if change_colors:
            color_line = 0
            color_rect = 1
        else:
            color_rect = 0
            color_line = 1

        # brush for the line from that color
        self.brush_color1= cccanvas.BrushColor(self.colors[color_line])

        # apply the brush
        self.line.set_brush_border(self.brush_color1);

        # Simple Rectangle
        self.rect = cccanvas.Rectangle()

        # event for set the rect position when line is changed
        self.line.connect("all-bounds-changed", self.update_bounds, self.rect)
        
        # brush for the rect from that color
        self.brush_color2= cccanvas.BrushColor(self.colors[color_rect])

        # apply the brush
        self.rect.set_brush_border(self.brush_color2);

        self.circle.connect("enter-notify-event", self.enter_callback)
        self.circle.connect("leave-notify-event", self.leave_callback)

        # add line and rect to the item
        self.cc_item.append(self.line)
        self.cc_item.append(self.rect)
        self.cc_item.append(self.circle)
Exemple #2
0
    def __init__(self):
        cc.Item.__init__(self)

        demo_canvas_center = 200.0

        center = demo_canvas_center
        radius = 125.0

        color_border = cc.color_new_rgb(0.0, 0.0, 0.0)
        brush_border = cc.BrushColor(color_border)
            
        for i in range(12):
            item = cc.Rectangle()
            item.set_grid_aligned(True)

            item.set_brush_border(brush_border)
            
            color = cc.color_new_hsva(1.0 * i / 12, 0.75, 1.0, 0.5)
            brush = cc.BrushColor(color)
            item.set_brush_content(brush)
            
            self.append(item)

            item.set_position(center - 50.0 + sin(i*PI/6) * radius,
                              center - 50.0 + cos(i*PI/6) * radius,
                              100.0, 100.0)

        item = cc.Text("libccc 0.0.2");
        item.set_anchor(center, center)
        item.set_anchor_type(gtk.ANCHOR_CENTER)
        self.append(item)
Exemple #3
0
    def __init__(self, font_desc):
        global TITLE_SIZE 
        cccanvas.Rectangle.__init__(self)
        self.elements = []
        self.font_description = font_desc

        color = cccanvas.color_new_rgb(0,0,0)
        brush = cccanvas.BrushColor(color)

        self.set_brush_border (brush)

        self.set_position (0.0, 0.0, 4*TILE_SIZE, 4*TILE_SIZE)
        
        self.set_grid_aligned(True)

        for i in range(15):
            self.elements.append(fifteen_item.FifteenItem(i+1))

            self.elements[i].set_grid_aligned(True)
            self.elements[i].set_brush_border (brush)
            self.append(self.elements[i])
            
            self.elements[i].move(i, TILE_SIZE)

            self.elements[i].connect("button-press-event", self.fg_element_clicked)
            self.elements[i].set_font(self.font_description)
            

        self.elements.append(None)
Exemple #4
0
    def __init__(self):
        self.title = 'Crossing'
        
        self.colors = [ cccanvas.color_new_rgb(0.0,0.0,0.0),
                        cccanvas.color_new_rgb(1.0,0.0,0.0) ]

        self.brushs = []
        
        self.brushs.append(cccanvas.BrushColor(self.colors[0]))
        self.brushs.append(cccanvas.BrushColor(self.colors[1]))

        #self.brushs = [ cccanvas.BrushColor(self.colors[0]),
        #                cccanvas.BrushColor(self.colors[1]) ]

        # main widget
        self.widget = gtk.VBox(False, 6)
        self.widget.set_border_width(6)

        # Scroll
        #swin = gtk.ScrolledWindow()
        #self.widget.pack_start(swin)

        # Create CCCanvas item and widget with this item as root
        self.root = cccanvas.Item() 
        self.view = cccanvas.view_widget_new_root(self.root)
        self.view.show()

        self.widget.pack_start(self.view)

        # Label
        self.label = gtk.Label('Move the mouse over a circle')
        self.label.show()
        self.widget.pack_start(self.label)

        n_circles = 12
        center = 130.0
        radius = 125.0

        r = [ 25.5,
              15.0,
              9.0,
              5.4,
              3.24 ]
        r.append( r[4]*0.6 )
        r.append( r[5]*0.6 )
        r.append( r[6]*0.6 )
 
        
        for i in range(n_circles):
            out = 0
            for r_el in r:
                circle = cccanvas.Circle()
                out += r_el
                circle.set_anchor( center + (radius - out) * sin(2.0*pi*i/n_circles),
                                   center - (radius - out) * cos(2.0*pi*i/n_circles))
                circle.set_radius( r_el );
                circle.set_brush_border (self.brushs[0])
                
                circle.connect("enter-notify-event", self.enter_callback)
                circle.connect("leave-notify-event", self.leave_callback)

                self.root.append(circle)
                
        self.widget.show()