Changes

1,552 bytes added ,  13:49, 3 April 2009
Line 77: Line 77:     
In Turtle Art Activity there already is a way to plug a python code to add new block's functions. The idea is add a similar feature to Oficina. Sugar has already a python editor called Pippy. Using this kids can developed or edit your own brush and import your custom code into Oficina using the Pippy button.
 
In Turtle Art Activity there already is a way to plug a python code to add new block's functions. The idea is add a similar feature to Oficina. Sugar has already a python editor called Pippy. Using this kids can developed or edit your own brush and import your custom code into Oficina using the Pippy button.
 +
 +
One example of a tool code (nowadays it is the current brush)
 +
 +
    def brush(self, widget, coords, last, size = 5, shape = 'circle'):
 +
        widget.desenha = False
 +
        if(shape == 'circle'):
 +
            widget.pixmap.draw_arc(widget.gc_brush, True, coords[0], coords[1], size, size, 0, 360*64)
 +
            if last:
 +
                widget.gc_brush.set_line_attributes(size, gtk.gdk.LINE_SOLID, gtk.gdk.CAP_ROUND, gtk.gdk.JOIN_ROUND)
 +
                widget.pixmap.draw_line(widget.gc_brush,last[0]+size/2,last[1]+size/2,coords[0]+size/2,coords[1]+size/2)
 +
                widget.gc_brush.set_line_attributes(0, gtk.gdk.LINE_SOLID, gtk.gdk.CAP_ROUND, gtk.gdk.JOIN_ROUND)
 +
        if(shape == 'square'):
 +
            widget.pixmap.draw_rectangle(widget.gc_brush, True, coords[0], coords[1], size, size)
 +
            if last:
 +
                points = [coords, last, (last[0]+size,last[1]+size), (coords[0]+size,coords[1]+size)]
 +
                widget.pixmap.draw_polygon(widget.gc_brush,True,points)
 +
                points = [(last[0]+size,last[1]), (coords[0]+size,coords[1]), (coords[0],coords[1]+size), (last[0],last[1]+size)]
 +
                widget.pixmap.draw_polygon(widget.gc_brush,True,points)
 +
 +
        if last:
 +
            x = min(coords[0], last[0])
 +
            width = max(coords[0], last[0]) - x
 +
            y = min(coords[1], last[1])
 +
            height = max(coords[1], last[1]) - y
 +
            widget.queue_draw_area(x, y, width+size, height+size) # We add size to avoid drawing dotted lines
 +
        else:
 +
            widget.queue_draw()
 +
    
Other important functionality is that children can share their brushes since Sugar 0.84 already allows users to take any item in the Journal and send it to anyone else. There are already some available tools for default but kids can modify or delete this.
 
Other important functionality is that children can share their brushes since Sugar 0.84 already allows users to take any item in the Journal and send it to anyone else. There are already some available tools for default but kids can modify or delete this.