[Sugar-devel] Fwd: [Dextrose] [PATCH v3 PaintActivity] New suggestion for arrow drawing in Paint

Manusheel Gupta manu at seeta.in
Fri Oct 22 17:20:37 EDT 2010


FYI

---------- Forwarded message ----------
From: Gonzalo Odiard <gonzalo at laptop.org>
Date: Fri, Oct 22, 2010 at 11:56 PM
Subject: Re: [Dextrose] [PATCH v3 PaintActivity] New suggestion for arrow
drawing in Paint
To: Anurag Chowdhury <anurag at seeta.in>
Cc: Manusheel Gupta <manu at seeta.in>


Change commited.

Gonzalo


On Fri, Oct 22, 2010 at 1:49 PM, Anurag Chowdhury <anurag at seeta.in> wrote:

> I have added the patch to the ticket .
> Also, can you tell  me if there is any thing more to be added or improved
> in the patch.
> And can I add you to the Reviewed-By tag in the patch?
>
> Regards
> Anurag
>
>
> On Fri, Oct 22, 2010 at 4:13 PM, Gonzalo Odiard <gonzalo at laptop.org>wrote:
>
>> Please, add the patch to the ticket
>
>
>> Gonzalo
>>
>> On Fri, Oct 22, 2010 at 12:12 AM, Anurag Chowdhury <anurag at seeta.in>wrote:
>>
>>> In the paint activity's shape tool we were able to make only horizontal
>>> arrows,
>>> so now we have modified the arrow tool which will now make arrows in all
>>> directions.
>>> ---
>>>  Desenho.py |   31 ++++++++++++++++++++++---------
>>>  1 files changed, 22 insertions(+), 9 deletions(-)
>>>
>>> v1->v2 :Removed the vertical-arrow tool and modified the arrow tool to
>>> enable
>>> drawing arrows in all directions.
>>> v2->v3 :Fixed the error of two extra lines when made the arrow with a
>>> different
>>> colour border
>>>
>>> diff --git a/Desenho.py b/Desenho.py
>>> index 3be1910..1b16ccd 100644
>>> --- a/Desenho.py
>>> +++ b/Desenho.py
>>> @@ -294,18 +294,31 @@ class Desenho:
>>>
>>>         x = coords[0] - widget.oldx
>>>         y = coords[1] - widget.oldy
>>> -        points = [(widget.oldx, widget.oldy),\
>>> -            (widget.oldx + int(x / 6), widget.oldy + y), \
>>> -            (widget.oldx + int(x / 6), widget.oldy + int(y / 3)), \
>>> -            (widget.oldx + x, widget.oldy + int(y / 3)), \
>>> -            (widget.oldx + x, widget.oldy - int(y / 3)), \
>>> -            (widget.oldx + int(x / 6), widget.oldy - int(y / 3)),\
>>> -            (widget.oldx + int(x / 6), widget.oldy - y)]
>>> +        A = math.atan2(y, x)
>>> +        dA = 2 * math.pi / 2
>>> +        r = math.hypot(y, x)
>>> +        m = math.sin(A)
>>> +        p = [(widget.oldx, widget.oldy)]
>>> +        p.append((widget.oldx + int(r * math.cos(A)),\
>>> +                  widget.oldy + int(r * math.sin(A))))
>>> +        p.append((widget.oldx + int(0.74 * r * math.cos(A + dA / 6)),\
>>> +                  widget.oldy + int(0.74 * r * math.sin(A + dA / 6))))
>>> +        p.append((widget.oldx + int(2 * r * math.cos(A + dA / 6 + dA /
>>> 20)),\
>>> +                  widget.oldy + int(2 * r * math.sin(A + dA / 6 + dA /
>>> 20))))
>>> +        p.append((widget.oldx +\
>>> +                  int(2 * r * math.cos(A + dA / 6 - dA / 20 + dA / 6)),\
>>> +                  widget.oldy +\
>>> +                  int(2 * r * math.sin(A + dA / 6 - dA / 20 + dA / 6))))
>>> +        p.append((widget.oldx + int(0.74 * r * math.cos(A + dA / 6 + dA
>>> / 6)),\
>>> +                  widget.oldy + int(0.74 * r * math.sin(A + dA / 6 + dA
>>> / 6))))
>>> +        p.append((widget.oldx + int(r * math.cos(A + dA / 2)),\
>>> +                  widget.oldy + int(r * math.sin(A + dA / 2))))
>>>         pixmap.draw_drawable(widget.gc, widget.pixmap, 0, 0, 0, 0,
>>>             width, height)
>>> +        tp = tuple(p)
>>>         if fill == True:
>>> -            pixmap.draw_polygon(widget.gc, True, points)
>>> -        pixmap.draw_polygon(widget.gc_line, False, points)
>>> +            pixmap.draw_polygon(widget.gc, True, tp)
>>> +        pixmap.draw_polygon(widget.gc_line, False, tp)
>>>         widget.queue_draw()
>>>
>>>     def parallelogram(self, widget, coords, temp, fill):
>>> --
>>> 1.7.2.3
>>>
>>> _______________________________________________
>>> Dextrose mailing list
>>> Dextrose at lists.sugarlabs.org
>>> http://lists.sugarlabs.org/listinfo/dextrose
>>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20101023/9e8ea96f/attachment.html>


More information about the Sugar-devel mailing list