[Sugar-devel] [PATCH v2 Paint Activity] Fixed aspect ratio mode for Shape tools (OLPC#3705)

2010-10-28 Thread Ayush Goyal
Added fixed aspect ratio mode for line,ellipse and rectangle tool using Shift
key as mask or using a keep aspect ratio checkbox from palette.This allows
drawing of straight lines  45 degree lines from line tool,circle from
ellipse tool and square from rectangle tool

Signed-off-by: Ayush Goyal ay...@seeta.in
---
 Area.py|   40 +++-
 toolbox.py |   11 +++
 2 files changed, 50 insertions(+), 1 deletions(-)
 v1-v2:Added checkbox for keep aspect in shape menu palette

diff --git a/Area.py b/Area.py
index ba06758..db84e65 100644
--- a/Area.py
+++ b/Area.py
@@ -173,6 +173,10 @@ class Area(gtk.DrawingArea):
 self.last = []
 self.rainbow_counter = 0
 self.keep_aspect_ratio = False
+self.keep_ratio = {
+'line': False,
+'rectangle': False,
+'ellipse': False}
 
 self.font = pango.FontDescription('Sans 9')
 self._set_selection_bounds(0, 0, 0, 0)
@@ -411,6 +415,13 @@ class Area(gtk.DrawingArea):
 self.x_cursor, self.y_cursor = int(x), int(y)
 
 coords = int(x), int(y)
+if self.tool['name'] in ['rectangle', 'ellipse', 'line']:
+if (state  gtk.gdk.SHIFT_MASK) or \
+self.keep_ratio[self.tool['name']]:
+if self.tool['name'] in ['rectangle', 'ellipse']:
+coords = self._keep_selection_ratio(coords)
+elif self.tool['name'] == 'line':
+coords = self._keep_line_ratio(coords)
 
 if state  gtk.gdk.BUTTON1_MASK and self.pixmap != None:
 if self.tool['name'] == 'pencil':
@@ -530,11 +541,19 @@ class Area(gtk.DrawingArea):
 @param  event -- GdkEvent
 
 coords = int(event.x), int(event.y)
+if self.tool['name'] in ['rectangle', 'ellipse', 'line']:
+if (event.state  gtk.gdk.SHIFT_MASK) or \
+self.keep_ratio[self.tool['name']]:
+if self.tool['name'] in ['rectangle', 'ellipse']:
+coords = self._keep_selection_ratio(coords)
+if self.tool['name'] == 'line':
+coords = self._keep_line_ratio(coords)
+
 width, height = self.window.get_size()
 if self.desenha or self.sel_get_out:
 if self.tool['name'] == 'line':
 self.pixmap.draw_line(self.gc_line, self.oldx, self.oldy,
-int(event.x), int(event.y))
+coords[0], coords[1])
 widget.queue_draw()
 self.enableUndo(widget)
 
@@ -1411,3 +1430,22 @@ class Area(gtk.DrawingArea):
 
 return (self.oldx + sign(dx) * size,
 self.oldy + sign(dy) * size)
+
+def _keep_line_ratio(self, coords):
+
+def sign(x):
+return x and x / abs(x) or 0
+
+dx = int(coords[0]) - self.oldx
+dy = int(coords[1]) - self.oldy
+size = max(abs(dx), abs(dy))
+
+if abs(dx)  0.5 * size and abs(dy)  0.5 * size:
+return (self.oldx + sign(dx) * size,
+   self.oldy + sign(dy) * size)
+elif abs(dx)  0.5 * size and abs(dy)  0.5 * size:
+return (self.oldx,
+   self.oldy + sign(dy) * size)
+elif abs(dx)  0.5 * size and abs(dy)  0.5 * size:
+return (self.oldx + sign(dx) * size,
+   self.oldy)
diff --git a/toolbox.py b/toolbox.py
index 3c8ab92..e8569c8 100644
--- a/toolbox.py
+++ b/toolbox.py
@@ -855,6 +855,10 @@ class ShapesToolbar(gtk.Toolbar):
 tool['fill'] = checkbutton.get_active()
 self.set_tool(tool=tool)
 
+def _on_keep_aspect_checkbutton_toggled(self, checkbutton, tool):
+self._activity.area.keep_ratio[tool['name']] = checkbutton.get_active()
+self.set_tool(tool=tool)
+
 def _configure_palette_shape_ellipse(self):
 logging.debug('Creating palette to shape ellipse')
 self._create_simple_palette(self._shape_ellipse, self._SHAPE_ELLIPSE)
@@ -960,6 +964,13 @@ class ShapesToolbar(gtk.Toolbar):
 palette.content_box = gtk.VBox()
 palette.set_content(palette.content_box)
 
+if tool['name'] in ['rectangle', 'ellipse', 'line']:
+keep_aspect_checkbutton = gtk.CheckButton(_('Keep Aspect'))
+ratio = self._activity.area.keep_ratio[tool['name']]
+keep_aspect_checkbutton.set_active(ratio)
+keep_aspect_checkbutton.connect('toggled',
+self._on_keep_aspect_checkbutton_toggled, tool)
+palette.content_box.pack_start(keep_aspect_checkbutton)
 # Fill option
 if not line_size_only:
 fill_checkbutton = gtk.CheckButton(_('Fill'))
-- 
1.7.1

___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


[Sugar-devel] [PATCH Paint Activity] Fixed aspect ratio mode for Shape tools (OLPC#3705)

2010-10-27 Thread Ayush Goyal
Added fixed aspect ratio mode for line,ellipse and rectangle tool using Shift
key as mask.This allows drawing of straight lines  45 degree lines from line 
tool,circle from ellipse tool and square from rectangle tool

Signed-off-by: Ayush Goyal ay...@seeta.in
---
 Area.py |   33 -
 1 files changed, 32 insertions(+), 1 deletions(-)

diff --git a/Area.py b/Area.py
index ba06758..0bef28b 100644
--- a/Area.py
+++ b/Area.py
@@ -412,6 +412,12 @@ class Area(gtk.DrawingArea):
 
 coords = int(x), int(y)
 
+if state  gtk.gdk.SHIFT_MASK:
+if self.tool['name'] in ['rectangle', 'ellipse']:
+coords = self._keep_selection_ratio(coords)
+elif self.tool['name'] == 'line':
+coords = self._keep_line_ratio(coords)
+
 if state  gtk.gdk.BUTTON1_MASK and self.pixmap != None:
 if self.tool['name'] == 'pencil':
 self.d.brush(widget, coords, self.last,
@@ -530,11 +536,17 @@ class Area(gtk.DrawingArea):
 @param  event -- GdkEvent
 
 coords = int(event.x), int(event.y)
+if event.state  gtk.gdk.SHIFT_MASK:
+if self.tool['name'] in ['rectangle', 'ellipse']:
+coords = self._keep_selection_ratio(coords)
+if self.tool['name'] == 'line':
+coords = self._keep_line_ratio(coords)
+
 width, height = self.window.get_size()
 if self.desenha or self.sel_get_out:
 if self.tool['name'] == 'line':
 self.pixmap.draw_line(self.gc_line, self.oldx, self.oldy,
-int(event.x), int(event.y))
+  coords[0], coords[1])
 widget.queue_draw()
 self.enableUndo(widget)
 
@@ -1411,3 +1423,22 @@ class Area(gtk.DrawingArea):
 
 return (self.oldx + sign(dx) * size,
 self.oldy + sign(dy) * size)
+
+def _keep_line_ratio(self, coords):
+
+def sign(x):
+return x and x / abs(x) or 0
+
+dx = int(coords[0]) - self.oldx
+dy = int(coords[1]) - self.oldy
+size = max(abs(dx), abs(dy))
+
+if abs(dx)  0.5 * size and abs(dy)  0.5 * size:
+return (self.oldx + sign(dx) * size,
+   self.oldy + sign(dy) * size)
+elif abs(dx)  0.5 * size and abs(dy)  0.5 * size:
+return (self.oldx,
+   self.oldy + sign(dy) * size)
+elif abs(dx)  0.5 * size and abs(dy)  0.5 * size:
+return (self.oldx + sign(dx) * size,
+   self.oldy)
-- 
1.7.1

___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [PATCH Paint activity v2] Implemented Mirroring Effect in Paint Activity (SL#2463)

2010-10-21 Thread Ayush Goyal

 James,

I am sorry for the confusion over the OLPC#2495  SL#2463 bug issue i 
should also have contacted u but instead i made most of the changes u 
suggested and uploaded them. Also i uploaded some errors lat time it 
must have created some confusion.


Regarding the changes you are asking me to make in implementation of the 
effects separately for applying effect over a selection and for entire 
image i have referenced the functions for effect already present and 
used that as guideline to make changes in code. I have just started 
developing and i still hv much to learn about efficient coding for these 
issues so please pardon my mistakes. I will try my best to code more 
efficiently in future and thanks for reviewing the patch.


Regards,
Ayush




On 10/21/2010 07:38 AM, James Cameron wrote:

On Wed, Oct 20, 2010 at 08:00:16PM +0530, Ayush Goyal wrote:

+if self.selmove:
+size = self.pixmap_sel.get_size()
+pix = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8,
+size[0], size[1])
+pix.get_from_drawable(self.pixmap_sel,
+gtk.gdk.colormap_get_system(), 0, 0, 0, 0, size[0], size[1])
+else:
+pix = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8,
+width, height)
+pix.get_from_drawable(self.pixmap, gtk.gdk.colormap_get_system(),
+0, 0, 0, 0, width, height)
+
+pix = pix.flip(horizontal)

Are you sure this version of the patch works for you for both selected
area and whole image?  The pix.flip is only on the whole image branch of
the if.  Either this version of the patch does not work, or you did not
test it, or I misunderstand.  Lay odds.  ;-)


+if self.selmove:
+self.pixmap_sel.draw_pixbuf(self.gc, pix, 0, 0, 0, 0,
+size[0], size[1], dither=gtk.gdk.RGB_DITHER_NORMAL,
+x_dither=0, y_dither=0)
+
+self.pixmap_temp.draw_drawable(self.gc, self.pixmap, 0, 0, 0, 0,
+width, height)
+self.pixmap_temp.draw_drawable(self.gc, self.pixmap_sel,
+0, 0, self.orig_x, self.orig_y, size[0], size[1])
+self.pixmap_temp.draw_rectangle(self.gc_selection, False,
+self.orig_x, self.orig_y, size[0], size[1])
+self.pixmap_temp.draw_rectangle(self.gc_selection1, False,
+self.orig_x - 1, self.orig_y - 1, size[0] + 2, size[1] + 2)
+
+else:
+self.pixmap.draw_pixbuf(self.gc, pix, 0, 0, 0, 0, width, height,
+dither=gtk.gdk.RGB_DITHER_NORMAL, x_dither=0, y_dither=0)
+
+self.queue_draw()
+if not self.selmove:
+self.enableUndo(widget)

I still think there need only be one check for self.selmove, and
duplicated calls for pix.flip and queue_draw in each branch.  Whether
this is done as a set of different functions or not is up to you ...

... but I'm frustrated in this communication with you because I suggest
n changes and see only a patch come back with n-m changes, with no
discussion of why m changes were not adopted.



___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


[Sugar-devel] [PATCH Paint Activity v3] Added Invert Color Effect to Paint Activity (OLPC #2495)

2010-10-20 Thread Ayush Goyal

Signed-off-by: Ayush Goyal ay...@seeta.in
---
 Area.py |   71 --
 icons/invert-colors.svg |  387 +++
 toolbox.py  |   23 ++--
 3 files changed, 459 insertions(+), 22 deletions(-)
 create mode 100644 icons/invert-colors.svg
 v1-v2: Standardized code to pep8
 v2-v3: More pep8 errors corrected

diff --git a/Area.py b/Area.py
index a0e82d0..35d38b3 100644
--- a/Area.py
+++ b/Area.py
@@ -69,10 +69,12 @@ import os
 import tempfile
 import math
 import pango
+import numpy
 from fill import *
 from Desenho import Desenho
 from urlparse import urlparse
 
+
 ##Tools and events manipulation are handle with this class.
 
 TARGET_URI = 0
@@ -80,7 +82,6 @@ TARGET_URI = 0
 
 class Area(gtk.DrawingArea):
 
-
 __gsignals__ = {
 'undo': (gobject.SIGNAL_ACTION, gobject.TYPE_NONE, ([])),
 'redo': (gobject.SIGNAL_ACTION, gobject.TYPE_NONE, ([])),
@@ -227,7 +228,7 @@ class Area(gtk.DrawingArea):
 self.gc = win.new_gc()
 self.gc_eraser = win.new_gc()
 colormap = self.get_colormap()
-self.white = colormap.alloc_color('#ff', True, True) # white
+self.white = colormap.alloc_color('#ff', True, True)  # white
 self.black = colormap.alloc_color('#00', True, True)  # black
 
 self.gc_eraser.set_foreground(self.white)
@@ -555,7 +556,7 @@ class Area(gtk.DrawingArea):
 self.selmove = True
 self.sel_get_out = False
 self.emit('select')
-elif self.sel_get_out: #get out of the func selection
+elif self.sel_get_out:  # get out of the func selection
 self.getout()
 try:
 del(self.d.pixbuf_resize)
@@ -648,7 +649,7 @@ class Area(gtk.DrawingArea):
 if self.undo_times  0:
 self.undo_times -= 1
 self.redo_times += 1
-try: #to not try paint someting wrong
+try:  # to not try paint someting wrong
 self.pixmap.draw_drawable(self.gc,
 self.undo_list[self.undo_times], 0, 0, 0, 0, width, height)
 except:
@@ -663,7 +664,7 @@ class Area(gtk.DrawingArea):
 
 #special case for func polygon
 if self.tool['name'] == 'freeform':
-self.polygon_start = True #start the polygon again
+self.polygon_start = True  # start the polygon again
 
 self.emit('undo')
 
@@ -680,7 +681,7 @@ class Area(gtk.DrawingArea):
 self.redo_times -= 1
 self.undo_times += 1
 
-try: #to not try paint someting wrong
+try:  # to not try paint someting wrong
 self.pixmap.draw_drawable(self.gc,
 self.undo_list[self.undo_times], 0, 0, 0, 0,
 width, height)
@@ -705,11 +706,11 @@ class Area(gtk.DrawingArea):
 if self.undo_surf:
 self.undo_times += 1
 
-self.undo_list.append(None)#alloc memory
+self.undo_list.append(None)  # alloc memory
 self.undo_list[self.undo_times] = gtk.gdk.Pixmap(widget.window,
-width, height, -1) #define type
+width, height, -1)  # define type
 self.undo_list[self.undo_times].draw_drawable(self.gc, self.pixmap,
-0, 0, 0, 0, width, height) #copy workarea
+0, 0, 0, 0, width, height)  # copy workarea
 self.undo_times += 1
 self.redo_times = 0
 self.first_undo = True
@@ -915,6 +916,56 @@ class Area(gtk.DrawingArea):
 if not self.selmove:
 self.enableUndo(widget)
 
+def invert_colors(self, widget):
+Apply invert effect.
+
+@param  self -- the Area object (GtkDrawingArea)
+@param  widget -- the Area object (GtkDrawingArea)
+
+
+
+width, height = self.window.get_size()
+
+if self.selmove:
+size = self.pixmap_sel.get_size()
+pix = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8,
+size[0], size[1])
+pix.get_from_drawable(self.pixmap_sel,
+gtk.gdk.colormap_get_system(), 0, 0, 0, 0, size[0], size[1])
+else:
+pix = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8,
+width, height)
+pix.get_from_drawable(self.pixmap, gtk.gdk.colormap_get_system(),
+0, 0, 0, 0, width, height)
+
+pix_manip2 = pix.get_pixels_array()
+pix_manip = numpy.ones(pix_manip2.shape, dtype=numpy.uint8) * 255
+pix_manip2 = pix_manip - pix_manip2
+pix = gtk.gdk.pixbuf_new_from_array(pix_manip2, gtk.gdk.COLORSPACE_RGB,
+8)
+
+if self.selmove:
+self.pixmap_sel.draw_pixbuf(self.gc, pix, 0, 0, 0, 0,
+size[0], size[1], dither=gtk.gdk.RGB_DITHER_NORMAL,
+x_dither=0, y_dither=0

[Sugar-devel] [PATCH Paint activity v2] Implemented Mirroring Effect in Paint Activity (SL#2463)

2010-10-20 Thread Ayush Goyal
Two mirror effects 'Mirror Horizontal' and 'Mirror Vertical' have been added.
Mirror horizontal tool flips the entire image or selected area horizontally.
Mirror vertical tool does the same vertically.

Signed-off-by: Ayush Goyal ay...@seeta.in
---
 Area.py |   47 
 icons/mirror-horizontal.svg |  272 +++
 icons/mirror-vertical.svg   |  272 +++
 toolbox.py  |   18 +++
 4 files changed, 609 insertions(+), 0 deletions(-)
 create mode 100644 icons/mirror-horizontal.svg
 create mode 100644 icons/mirror-vertical.svg
 v1-v2:Standardized to pep8 and optimized the code

diff --git a/Area.py b/Area.py
index 35d38b3..ba022f5 100644
--- a/Area.py
+++ b/Area.py
@@ -966,6 +966,53 @@ class Area(gtk.DrawingArea):
 if not self.selmove:
 self.enableUndo(widget)
 
+def mirror(self, widget, horizontal=True):
+Apply mirror horizontal/vertical effect.
+
+@param  self -- the Area object (GtkDrawingArea)
+@param  widget -- the Area object (GtkDrawingArea)
+@param  horizontal -- If true sets flip as horizontal else vertical
+
+
+
+width, height = self.window.get_size()
+
+if self.selmove:
+size = self.pixmap_sel.get_size()
+pix = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8,
+size[0], size[1])
+pix.get_from_drawable(self.pixmap_sel,
+gtk.gdk.colormap_get_system(), 0, 0, 0, 0, size[0], size[1])
+else:
+pix = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8,
+width, height)
+pix.get_from_drawable(self.pixmap, gtk.gdk.colormap_get_system(),
+0, 0, 0, 0, width, height)
+
+pix = pix.flip(horizontal)
+
+if self.selmove:
+self.pixmap_sel.draw_pixbuf(self.gc, pix, 0, 0, 0, 0,
+size[0], size[1], dither=gtk.gdk.RGB_DITHER_NORMAL,
+x_dither=0, y_dither=0)
+
+self.pixmap_temp.draw_drawable(self.gc, self.pixmap, 0, 0, 0, 0,
+width, height)
+self.pixmap_temp.draw_drawable(self.gc, self.pixmap_sel,
+0, 0, self.orig_x, self.orig_y, size[0], size[1])
+self.pixmap_temp.draw_rectangle(self.gc_selection, False,
+self.orig_x, self.orig_y, size[0], size[1])
+self.pixmap_temp.draw_rectangle(self.gc_selection1, False,
+self.orig_x - 1, self.orig_y - 1, size[0] + 2, size[1] + 2)
+
+else:
+self.pixmap.draw_pixbuf(self.gc, pix, 0, 0, 0, 0, width, height,
+dither=gtk.gdk.RGB_DITHER_NORMAL, x_dither=0, y_dither=0)
+
+self.queue_draw()
+if not self.selmove:
+self.enableUndo(widget)
+
 def _pixbuf2Image(self, pb):
 change a pixbuf to RGB image
 
diff --git a/icons/mirror-horizontal.svg b/icons/mirror-horizontal.svg
new file mode 100644
index 000..2554356
--- /dev/null
+++ b/icons/mirror-horizontal.svg
@@ -0,0 +1,272 @@
+?xml version=1.0 encoding=UTF-8 standalone=no?
+svg
+   xmlns:osb=http://www.openswatchbook.org/uri/2009/osb;
+   xmlns:dc=http://purl.org/dc/elements/1.1/;
+   xmlns:cc=http://creativecommons.org/ns#;
+   xmlns:rdf=http://www.w3.org/1999/02/22-rdf-syntax-ns#;
+   xmlns:svg=http://www.w3.org/2000/svg;
+   xmlns=http://www.w3.org/2000/svg;
+   xmlns:xlink=http://www.w3.org/1999/xlink;
+   xmlns:sodipodi=http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd;
+   xmlns:inkscape=http://www.inkscape.org/namespaces/inkscape;
+   enable-background=new 0 0 55 55
+   height=55px
+   version=1.1
+   viewBox=0 0 55 55
+   width=55px
+   x=0px
+   xml:space=preserve
+   y=0px
+   id=svg2
+   inkscape:version=0.48.0 r9654
+   sodipodi:docname=mirror-horizontal.svgmetadata
+ id=metadata50rdf:RDFcc:Work
+ rdf:about=dc:formatimage/svg+xml/dc:formatdc:type
+   rdf:resource=http://purl.org/dc/dcmitype/StillImage; /dc:title 
//cc:Work/rdf:RDF/metadatadefs
+ id=defs48inkscape:path-effect
+   effect=skeletal
+   id=path-effect5822
+   is_visible=true
+   pattern=M 0,0 0,10 10,5 z
+   copytype=single_stretched
+   prop_scale=1
+   scale_y_rel=false
+   spacing=0
+   normal_offset=0
+   tang_offset=0
+   prop_units=false
+   vertical_pattern=false
+   fuse_tolerance=0 /inkscape:path-effect
+   effect=skeletal
+   id=path-effect5818
+   is_visible=true
+   pattern=M 0,0 0,10 10,5 z
+   copytype=single_stretched
+   prop_scale=1
+   scale_y_rel=false
+   spacing=0
+   normal_offset=0
+   tang_offset=0
+   prop_units=false
+   vertical_pattern=false
+   fuse_tolerance=0 /linearGradient
+   id=linearGradient5788
+   osb:paint=solidstop
+ style=stop-color:#00;stop-opacity:1;
+ offset=0
+ id=stop5790

Re: [Sugar-devel] [PATCH Paint Activity] Added Invert Color Effect to Paint Activity (OLPC #2495)

2010-10-18 Thread Ayush Goyal

 Gonzalo,

Thank you for the review and feedback.

Please find the revised patch attached at http://dev.laptop.org/ticket/2495.

The icon developed can be found at http://seeta.in/dextrose/olpc2495/.

Looking forward to your review on the revised patch.

Appreciate your support.

Regards,

Ayush
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


[Sugar-devel] [Design]: OLPC#2493 [Implement a scale in paint Activity]

2010-10-18 Thread Ayush Goyal


Team,

Kindly share your feedback on the two approaches I have arrived at for 
this issue. Thank you Gonzalo for your positive feedback on them.


1.Use selection tool(Marquee tool) for scale using its boundary as 
dimensions ,printing it out on either toolbox ,or on a temporary status 
bar at bottom or view it on a gtk.window instance using a scale button.


2.Implement a line scale like a line tool which will show dimensions 
from starting point to end-point in pixels as text at center of the line.


Looking forward to your reviews.

Regards,
Ayush
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


[Sugar-devel] [PATCH Paint Activity] Added Invert Color Effect to Paint Activity (OLPC #2495)

2010-10-16 Thread Ayush Goyal

Signed-off-by: Ayush Goyal ay...@seeta.in
---
 Area.py |   40 +
 icons/invert-colors.svg |  387 +++
 toolbox.py  |   22 ++-
 3 files changed, 441 insertions(+), 8 deletions(-)
 create mode 100644 icons/invert-colors.svg

diff --git a/Area.py b/Area.py
index 2dca7da..7c7f4c5 100644
--- a/Area.py
+++ b/Area.py
@@ -70,6 +70,7 @@ import pango
 from fill import *
 from Desenho import Desenho
 from urlparse import urlparse
+import numpy
 
 ##Tools and events manipulation are handle with this class.
 
@@ -833,6 +834,45 @@ class Area(gtk.DrawingArea):
 self.queue_draw()
 if not self.selmove:
 self.enableUndo(widget)
+
+def invert_colors(self,widget):
+Apply invert color effect.
+
+@param  self -- the Area object (GtkDrawingArea)
+@param  widget -- the Area object (GtkDrawingArea)
+
+
+
+width, height = self.window.get_size()
+ 
+if self.selmove:
+size = self.pixmap_sel.get_size()
+pix = 
gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB,False,8,size[0],size[1])
+
pix.get_from_drawable(self.pixmap_sel,gtk.gdk.colormap_get_system(),0,0,0,0,size[0],size[1])
+else:
+pix = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB,False,8,width,height)
+
pix.get_from_drawable(self.pixmap,gtk.gdk.colormap_get_system(),0,0,0,0,width,height)
+
+pix_manip2=pix.get_pixels_array()
+pix_manip=numpy.ones(pix_manip2.shape,dtype=numpy.uint8)*255
+pix_manip2=pix_manip-pix_manip2
+pix=gtk.gdk.pixbuf_new_from_array(pix_manip2,gtk.gdk.COLORSPACE_RGB,8) 
   
+
+
+if self.selmove:
+
self.pixmap_sel.draw_pixbuf(self.gc,pix,0,0,0,0,size[0],size[1],dither=gtk.gdk.RGB_DITHER_NORMAL,x_dither=0,y_dither=0)
+
+
self.pixmap_temp.draw_drawable(self.gc,self.pixmap,0,0,0,0,width,height)
+
self.pixmap_temp.draw_drawable(self.gc,self.pixmap_sel,0,0,self.orig_x,self.orig_y,size[0],size[1])
+
self.pixmap_temp.draw_rectangle(self.gc_selection,False,self.orig_x,self.orig_y,size[0],size[1])
+
self.pixmap_temp.draw_rectangle(self.gc_selection1,False,self.orig_x-1,self.orig_y-1,size[0]+2,size[1]+2)
+
+else:
+
self.pixmap.draw_pixbuf(self.gc,pix,0,0,0,0,width,height,dither=gtk.gdk.RGB_DITHER_NORMAL,x_dither=0,y_dither=0)
+
+self.queue_draw()
+if not self.selmove:
+self.enableUndo(widget)
 
 def _pixbuf2Image(self, pb):
 change a pixbuf to RGB image
diff --git a/icons/invert-colors.svg b/icons/invert-colors.svg
new file mode 100644
index 000..373ca70
--- /dev/null
+++ b/icons/invert-colors.svg
@@ -0,0 +1,387 @@
+?xml version=1.0 encoding=UTF-8 standalone=no?
+svg
+   xmlns:osb=http://www.openswatchbook.org/uri/2009/osb;
+   xmlns:dc=http://purl.org/dc/elements/1.1/;
+   xmlns:cc=http://creativecommons.org/ns#;
+   xmlns:rdf=http://www.w3.org/1999/02/22-rdf-syntax-ns#;
+   xmlns:svg=http://www.w3.org/2000/svg;
+   xmlns=http://www.w3.org/2000/svg;
+   xmlns:xlink=http://www.w3.org/1999/xlink;
+   xmlns:sodipodi=http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd;
+   xmlns:inkscape=http://www.inkscape.org/namespaces/inkscape;
+   enable-background=new 0 0 55 55
+   height=55px
+   version=1.1
+   viewBox=0 0 55 55
+   width=55px
+   x=0px
+   xml:space=preserve
+   y=0px
+   id=svg2
+   inkscape:version=0.48.0 r9654
+   sodipodi:docname=invert-colors.svgmetadata
+ id=metadata50rdf:RDFcc:Work
+ rdf:about=dc:formatimage/svg+xml/dc:formatdc:type
+   rdf:resource=http://purl.org/dc/dcmitype/StillImage; 
//cc:Work/rdf:RDF/metadatadefs
+ id=defs48inkscape:path-effect
+   effect=skeletal
+   id=path-effect5822
+   is_visible=true
+   pattern=M 0,0 0,10 10,5 z
+   copytype=single_stretched
+   prop_scale=1
+   scale_y_rel=false
+   spacing=0
+   normal_offset=0
+   tang_offset=0
+   prop_units=false
+   vertical_pattern=false
+   fuse_tolerance=0 /inkscape:path-effect
+   effect=skeletal
+   id=path-effect5818
+   is_visible=true
+   pattern=M 0,0 0,10 10,5 z
+   copytype=single_stretched
+   prop_scale=1
+   scale_y_rel=false
+   spacing=0
+   normal_offset=0
+   tang_offset=0
+   prop_units=false
+   vertical_pattern=false
+   fuse_tolerance=0 /linearGradient
+   id=linearGradient5788
+   osb:paint=solidstop
+ style=stop-color:#00;stop-opacity:1;
+ offset=0
+ id=stop5790 //linearGradientlinearGradient
+   
gradientTransform=matrix(-4.371139e-8,1,-1,-4.371139e-8,55,-4.882812e-4)
+   gradientUnits=userSpaceOnUse
+   id=SVGID_1_-0
+   x1=8.4995003
+   x2=46.5
+   y1=27.5
+   y2=27.5stop
+ offset=0
+ style=stop-color:#FF
+ id=stop6-4 /stop

Re: [Sugar-devel] [PATCHv2] Title for 'Rectangualar Marquee' tool changed to 'Select Area'

2010-10-14 Thread Ayush Goyal

 Gonzalo,

Thanks for your recommendations. I have revised the patch, made the 
changes and resent it again using git send-mail. Please review it.


Regards,
Ayush

___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


[Sugar-devel] [PATCHv2] Title for 'Rectangualar Marquee' tool changed to 'Select Area'

2010-10-13 Thread Ayush Goyal
The select tool is less than optimally discoverable in English because
of the name 'Rectangular Marquee'.  The name is changed to 'Select
Area'.

Signed-off-by: Ayush Goyal ay...@seeta.in
---
 toolbox.py |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/toolbox.py b/toolbox.py
index 90f664d..299181b 100644
--- a/toolbox.py
+++ b/toolbox.py
@@ -434,7 +434,7 @@ class ToolsToolbar(gtk.Toolbar):
 
 
 
-self._tool_marquee_rectangular = 
DrawToolButton('tool-marquee-rectangular',activity.tool_group,_('Rectangular 
Marquee'))
+self._tool_marquee_rectangular = 
DrawToolButton('tool-marquee-rectangular',activity.tool_group,_('Select Area'))
 self.insert(self._tool_marquee_rectangular, -1)
 try:
 self._configure_palette(self._tool_marquee_rectangular, 
self._TOOL_MARQUEE_RECTANGULAR)
-- 
1.7.1

___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


[Sugar-devel] [PATCH] Title for 'Rectangular Marquee' tool changed to 'Select Area' (SL 2266)

2010-10-12 Thread Ayush Goyal
From: Ayush Goyal ayush at seeta.in


Signed-off-by: Ayush Goyal ayush at seeta.in
---
 po/Paint.pot |2 +-
 po/af.po |2 +-
 po/am.po |2 +-
 po/ar.po |2 +-
 po/ay.po |2 +-
 po/bg.po |2 +-
 po/bi.po |2 +-
 po/bn.po |2 +-
 po/bn_IN.po  |2 +-
 po/ca.po |2 +-
 po/cpp.po|2 +-
 po/cs.po |2 +-
 po/de.po |2 +-
 po/dz.po |2 +-
 po/el.po |2 +-
 po/en.po |2 +-
 po/es.po |2 +-
 po/fa.po |2 +-
 po/fa_AF.po  |2 +-
 po/ff.po |2 +-
 po/fil.po|2 +-
 po/fr.po |2 +-
 po/gu.po |2 +-
 po/ha.po |2 +-
 po/he.po |2 +-
 po/hi.po |2 +-
 po/ht.po |2 +-
 po/hu.po |2 +-
 po/ig.po |2 +-
 po/is.po |2 +-
 po/it.po |2 +-
 po/ja.po |2 +-
 po/km.po |2 +-
 po/ko.po |2 +-
 po/ko_KO.po  |2 +-
 po/kos.po|2 +-
 po/mg.po |2 +-
 po/mk.po |2 +-
 po/ml.po |2 +-
 po/mn.po |2 +-
 po/mr.po |2 +-
 po/ms.po |2 +-
 po/mvo.po|2 +-
 po/na.po |2 +-
 po/nb.po |2 +-
 po/ne.po |2 +-
 po/nl.po |2 +-
 po/pa.po |2 +-
 po/pap.po|2 +-
 po/pis.po|2 +-
 po/pl.po |2 +-
 po/ps.po |2 +-
 po/pseudo.po |2 +-
 po/pt.po |2 +-
 po/pt_BR.po  |2 +-
 po/qu.po |2 +-
 po/ro.po |2 +-
 po/ru.po |2 +-
 po/rw.po |2 +-
 po/sd.po |2 +-
 po/si.po |2 +-
 po/sk.po |2 +-
 po/sl.po |2 +-
 po/sq.po |2 +-
 po/sv.po |2 +-
 po/sw.po |2 +-
 po/ta.po |2 +-
 po/te.po |2 +-
 po/th.po |2 +-
 po/tpi.po|2 +-
 po/tr.po |2 +-
 po/tvl.po|2 +-
 po/tzo.po|2 +-
 po/ug.po |2 +-
 po/ur.po |2 +-
 po/vi.po |2 +-
 po/wa.po |2 +-
 po/yo.po |2 +-
 po/zh_CN.po  |2 +-
 po/zh_TW.po  |2 +-
 toolbox.py   |2 +-
 81 files changed, 81 insertions(+), 81 deletions(-)

diff --git a/po/Paint.pot b/po/Paint.pot
index 6bbc6b4..f0d39df 100644
--- a/po/Paint.pot
+++ b/po/Paint.pot
@@ -89,7 +89,7 @@ msgid Bucket
 msgstr 
 
 #: toolbox.py:365
-msgid Rectangular Marquee
+msgid Select Area
 msgstr 
 
 #: toolbox.py:417 toolbox.py:1049 toolbox.py:1412
diff --git a/po/af.po b/po/af.po
index 884b5f4..efc240b 100644
--- a/po/af.po
+++ b/po/af.po
@@ -89,7 +89,7 @@ msgid Bucket
 msgstr 
 
 #: toolbox.py:365
-msgid Rectangular Marquee
+msgid Select Area
 msgstr 
 
 #: toolbox.py:417 toolbox.py:1049 toolbox.py:1412
diff --git a/po/am.po b/po/am.po
index 599b8e8..10dc4b7 100644
--- a/po/am.po
+++ b/po/am.po
@@ -89,7 +89,7 @@ msgid Bucket
 msgstr 
 
 #: toolbox.py:365
-msgid Rectangular Marquee
+msgid Select Area
 msgstr 
 
 #: toolbox.py:417 toolbox.py:1049 toolbox.py:1412
diff --git a/po/ar.po b/po/ar.po
index d0d8609..2ae532d 100644
--- a/po/ar.po
+++ b/po/ar.po
@@ -94,7 +94,7 @@ msgid Bucket
 msgstr محفظة
 
 #: toolbox.py:365
-msgid Rectangular Marquee
+msgid Select Area
 msgstr معلِّمة مربّعة
 
 #: toolbox.py:417 toolbox.py:1049 toolbox.py:1412
diff --git a/po/ay.po b/po/ay.po
index 599b8e8..10dc4b7 100644
--- a/po/ay.po
+++ b/po/ay.po
@@ -89,7 +89,7 @@ msgid Bucket
 msgstr 
 
 #: toolbox.py:365
-msgid Rectangular Marquee
+msgid Select Area
 msgstr 
 
 #: toolbox.py:417 toolbox.py:1049 toolbox.py:1412
diff --git a/po/bg.po b/po/bg.po
index 7f45f15..ad8b3ae 100644
--- a/po/bg.po
+++ b/po/bg.po
@@ -88,7 +88,7 @@ msgid Bucket
 msgstr Заливка
 
 #: toolbox.py:365
-msgid Rectangular Marquee
+msgid Select Area
 msgstr Правоъгълно маркиране
 
 #: toolbox.py:417 toolbox.py:1049 toolbox.py:1412
diff --git a/po/bi.po b/po/bi.po
index 884b5f4..efc240b 100644
--- a/po/bi.po
+++ b/po/bi.po
@@ -89,7 +89,7 @@ msgid Bucket
 msgstr 
 
 #: toolbox.py:365
-msgid Rectangular Marquee
+msgid Select Area
 msgstr 
 
 #: toolbox.py:417 toolbox.py:1049 toolbox.py:1412
diff --git a/po/bn.po b/po/bn.po
index a163110..d6ac625 100644
--- a/po/bn.po
+++ b/po/bn.po
@@ -88,7 +88,7 @@ msgid Bucket
 msgstr ঝুড়ি
 
 #: toolbox.py:365
-msgid Rectangular Marquee
+msgid Select Area
 msgstr চতুর্ভূজাকার মার্কিউই
 
 #: toolbox.py:417 toolbox.py:1049 toolbox.py:1412
diff --git a/po/bn_IN.po b/po/bn_IN.po
index 3af9f60..9cd9249 100644
--- a/po/bn_IN.po
+++ b/po/bn_IN.po
@@ -90,7 +90,7 @@ msgid Bucket
 msgstr বাকেট
 
 #: toolbox.py:365
-msgid Rectangular Marquee
+msgid Select Area
 msgstr চতুর্ভূজাকার মার্কিউই
 
 #: toolbox.py:417 toolbox.py:1049 toolbox.py:1412
diff --git a/po/ca.po b/po/ca.po
index 175dc22..8585e5a 100644
--- a/po/ca.po
+++ b/po/ca.po
@@ -94,7 +94,7 @@ msgid Bucket
 msgstr Galleda
 
 #: toolbox.py:365
-msgid Rectangular Marquee
+msgid Select Area
 msgstr Marquesina Rectangular
 
 #: toolbox.py:417 toolbox.py:1049 toolbox.py

[Sugar-devel] [Design]: SL 2338 (Paint-28 - add custom icons for rest of Shape cursors)

2010-10-12 Thread Ayush Goyal
Gonzalo,

Wish if you could review the custom icons in the links attached below, and
let me know your feedback -

http://seeta.in/dextrose/sl2338/freeform.png

http://seeta.in/dextrose/sl2338/line.png

http://seeta.in/dextrose/sl2338/polygon.png

Once the icons are reviewed and accepted, I'll attach them at the trac item.

Thank you. Appreciate your support.

Regards,

Ayush
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel