Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/Desenho.py
diff options
context:
space:
mode:
authorAnurag Chowdhury <anurag@seeta.in>2010-10-22 03:04:11 (GMT)
committer Gonzalo Odiard <godiard@sugarlabs.org>2010-10-22 18:19:45 (GMT)
commita6417742e6e7688f215d91184355e399745c02aa (patch)
treeb8819adc1bfd1af1de70637e15ecac26d98e5c99 /Desenho.py
parentc8ddf32147fb582850f64e8da87cc3d4a2f4193d (diff)
New suggestion for arrow drawing in Paint
activity.olpc4170 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.
Diffstat (limited to 'Desenho.py')
-rw-r--r--Desenho.py31
1 files changed, 22 insertions, 9 deletions
diff --git a/Desenho.py b/Desenho.py
index 17525e5..ec464af 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):