diff options
author | Gonzalo Odiard <godiard@gmail.com> | 2011-05-03 18:29:08 (GMT) |
---|---|---|
committer | Gonzalo Odiard <godiard@gmail.com> | 2011-05-03 18:29:08 (GMT) |
commit | 44ce7d95c33fc76078d88fc43e9c4453ca6522e9 (patch) | |
tree | 0974e2d8fe36e5c992e94f0e4fad4621fdf1e9a3 /Desenho.py | |
parent | 149d8ceb9bfd288c2ccdcff5f787305dc7332275 (diff) |
Implementation of Stamp functionality
The user can select a part of the image to use it like a stamp.
When the stamp is selected, can change the size, and use it to draw.
Signed-of: manuel quiƱones <manuel.por.aca@gmail.com>
Reviewed-by: Gonzalo Odiard <gonzalo@laptop.org>
Diffstat (limited to 'Desenho.py')
-rw-r--r-- | Desenho.py | 27 |
1 files changed, 24 insertions, 3 deletions
@@ -128,6 +128,28 @@ class Desenho: widget.desenha = False self._trace(widget, widget.gc_brush, coords, last, size, shape) + def stamp(self, widget, coords, last, stamp_size=20): + """Paint with stamp. + + @param self -- Desenho.Desenho instance + @param last -- last of oldx + @param widget -- Area object (GtkDrawingArea) + @param coords -- Two value tuple + @param stamp_size -- integer (default 20) + + """ + widget.desenha = False + gc = widget.gc_brush + + width = widget.resized_stamp.get_width() + height = widget.resized_stamp.get_height() + dx = coords[0] - width / 2 + dy = coords[1] - height / 2 + widget.pixmap.draw_pixbuf(gc, widget.resized_stamp, + 0, 0, dx, dy, width, height) + + widget.queue_draw() + def rainbow(self, widget, coords, last, color, size=5, shape='circle'): """Paint with rainbow. @@ -161,7 +183,7 @@ class Desenho: self._trace(widget, widget.gc_rainbow, coords, last, size, shape) def _trace(self, widget, gc, coords, last, size, shape): - if(shape == 'circle'): + if shape == 'circle': widget.pixmap.draw_arc(gc, True, coords[0] - size / 2, coords[1] - size / 2, size, size, 0, 360 * 64) @@ -172,7 +194,7 @@ class Desenho: last[0], last[1], coords[0], coords[1]) gc.set_line_attributes(0, gtk.gdk.LINE_SOLID, gtk.gdk.CAP_ROUND, gtk.gdk.JOIN_ROUND) - if(shape == 'square'): + elif shape == 'square': widget.pixmap.draw_rectangle(gc, True, coords[0] - size / 2, coords[1] - size / 2, size, size) if last: @@ -186,7 +208,6 @@ class Desenho: (coords[0] - size / 2, coords[1] + size / 2), (last[0] - size / 2, last[1] + size / 2)] widget.pixmap.draw_polygon(gc, True, points) - if last: x = min(coords[0], last[0]) width = max(coords[0], last[0]) - x |