Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/Area.py
diff options
context:
space:
mode:
authorManuel QuiƱones <manuel.por.aca@gmail.com>2011-04-29 00:50:21 (GMT)
committer Manuel QuiƱones <manuel.por.aca@gmail.com>2011-04-29 00:50:21 (GMT)
commit7c6acbc9380e5e4136e11735600e58eba7cde29e (patch)
tree408baffa9d991a32c6fa82cb3203b276fd1a7995 /Area.py
parentb2f2d7e2c519504682236eba4cafa8287a777c59 (diff)
Stamp size different than brush size
Diffstat (limited to 'Area.py')
-rw-r--r--Area.py25
1 files changed, 15 insertions, 10 deletions
diff --git a/Area.py b/Area.py
index 7f49a63..2d14f7b 100644
--- a/Area.py
+++ b/Area.py
@@ -131,6 +131,7 @@ class Area(gtk.DrawingArea):
## with the following keys:
## - 'name' : a string
## - 'line size' : a integer
+ ## - 'stamp size' : a integer
## - 'fill color' : a gtk.gdk.Color object
## - 'stroke color' : a gtk.gdk.Color object
## - 'line shape' : a string - 'circle' or 'square', for now
@@ -140,6 +141,7 @@ class Area(gtk.DrawingArea):
self.tool = {
'name': 'pencil',
'line size': 4,
+ 'stamp size': 20,
'fill color': None,
'stroke color': None,
'line shape': 'circle',
@@ -288,10 +290,9 @@ class Area(gtk.DrawingArea):
"""
if self.tool['name'] in ['pencil', 'eraser', 'brush', 'rainbow', 'stamp']:
if not self.drawing:
- size = self.tool['line size']
-
# draw stamp border in widget.window
if self.tool['name'] == 'stamp':
+ size = self.tool['stamp size']
w = self.pixbuf_stamp.get_width()
h = self.pixbuf_stamp.get_height()
wr, hr = size, int(size * h * 1.0 / w)
@@ -299,11 +300,14 @@ class Area(gtk.DrawingArea):
self.x_cursor - wr / 2, self.y_cursor - hr / 2,
wr, hr)
+ # draw shape of the brush, square or circle
elif self.tool['line shape'] == 'circle':
+ size = self.tool['line size']
widget.window.draw_arc(self.gc_brush, False,
self.x_cursor - size / 2, self.y_cursor - size / 2,
size, size, 0, 360 * 64)
else:
+ size = self.tool['line size']
widget.window.draw_rectangle(self.gc_brush, False,
self.x_cursor - size / 2, self.y_cursor - size / 2,
size, size)
@@ -367,7 +371,7 @@ class Area(gtk.DrawingArea):
self.drawing = True
elif self.tool['name'] == 'stamp':
self.last = []
- self.d.stamp(widget, coords, self.last, self.tool['line size'])
+ self.d.stamp(widget, coords, self.last, self.tool['stamp size'])
self.last = coords
self.drawing = True
elif self.tool['name'] == 'rainbow':
@@ -441,7 +445,7 @@ class Area(gtk.DrawingArea):
self.last = coords
elif self.tool['name'] == 'stamp':
- self.d.stamp(widget, coords, self.last, self.tool['line size'])
+ self.d.stamp(widget, coords, self.last, self.tool['stamp size'])
self.last = coords
elif self.tool['name'] == 'rainbow':
@@ -672,10 +676,10 @@ class Area(gtk.DrawingArea):
gtk.gdk.colormap_get_system(), 0, 0, 0, 0, width, height)
self.stamp_size = 0
- self.resizeStamp(self.tool['line size'])
+ self.resizeStamp(self.tool['stamp size'])
return self.pixbuf_stamp
- def resizeStamp(self, size):
+ def resizeStamp(self, stamp_size):
"""Change stamping pixbuffer from the given size.
@param self -- the Area object (GtkDrawingArea)
@@ -687,11 +691,11 @@ class Area(gtk.DrawingArea):
return
# Resize stamp to fit brush size as the width:
- if self.stamp_size != size:
- self.stamp_size = size
+ if self.stamp_size != stamp_size:
+ self.stamp_size = stamp_size
w = self.pixbuf_stamp.get_width()
h = self.pixbuf_stamp.get_height()
- wr, hr = size, int(size * h * 1.0 / w)
+ wr, hr = stamp_size, int(stamp_size * h * 1.0 / w)
self.resized_stamp = self.pixbuf_stamp.scale_simple(wr, hr, gtk.gdk.INTERP_HYPER)
def undo(self):
@@ -1387,6 +1391,7 @@ class Area(gtk.DrawingArea):
self.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.CROSS))
widget.queue_draw()
+ # TODO: unused method?
def change_line_size(self, delta):
if self.tool['name'] in ['pencil', 'eraser', 'brush', 'rainbow', 'stamp']:
size = self.tool['line size'] + delta
@@ -1395,7 +1400,7 @@ class Area(gtk.DrawingArea):
self.tool['line size'] = size
self.configure_line(size)
self.queue_draw()
-
+
def _keep_selection_ratio(self, coords):
def sign(x):