This file is indexed.

/usr/share/pyshared/pyscript/arrowheads.py is in python-pyscript 0.6.1-4.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
# Copyright (C) 2002-2006  Alexei Gilchrist and Paul Cochrane
# 
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

# $Id: arrowheads.py,v 1.6 2006/05/15 11:52:15 paultcochrane Exp $

"""
Arrow heads for Path and elsewhere 
"""

__revision__ = '$Revision: 1.6 $'

from pyscript.defaults import defaults
#from math import sqrt, pi, sin, cos
from pyscript.vectors import P, Bbox # ,Identity 
from pyscript.base import Color
from pyscript.objects import AffineObj
import cStringIO

# -------------------------------------------------------------------------
# Base class: ArrowHead
# -------------------------------------------------------------------------

class ArrowHead(AffineObj):
    '''
    Arrow head object

    @cvar tip: where to position the tip of the arrow head
    @cvar angle: the direction to point

    Convenience variables modifying the head size:

    @cvar scalew: scale the width by this amount
    @cvar scaleh: scale height by this amount

    The actual shape of the arrowhead is defined by the following, distances
    are given in points
    
    @cvar start: tuple giving starting point for path
    @cvar shape: list of tuples giving arguments to postscripts curveto operator
    @cvar closed: whether to close the path or not
    @cvar fg: line color or None for no line
    @cvar bg: fill color or None for no fill
    @cvar linewidth: linewidth
    @cvar linejoin: 0=miter, 1=round, 2=bevel
    @cvar mitrelimit:  length of mitre of corners
    ''' 

    fg = Color(0)
    bg = Color(0)

    # used by Path object to set position and direction
    reverse = 0    
    pos = 1

    tip = P(0, 0)
    angle = 0

    start = (0, 0)
    # triangular share in the Golden ratio
    # positions in pixels
    shape = [(0, 0, 1.5, -4.854, 1.5, -4.854),
           (1.5, -4.854, -1.5, -4.854, -1.5, -4.854),
           (-1.5, -4.854, 0, 0, 0, 0)]

    closed = 1

    scalew = 1
    scaleh = 1

    linewidth = 0.2
    linejoin = 2 #0=miter, 1=round, 2=bevel

    # miterlimit:
    # 1.414 cuts off miters at angles less than 90 degrees.
    # 2.0 cuts off miters at angles less than 60 degrees.
    # 10.0 cuts off miters at angles less than 11 degrees.
    # 1.0 cuts off miters at all angles, so that bevels are always produced
    miterlimit = 2  

    def __init__(self, *param, **options):

        # remember this angle for when instance is copied...
        # this assumes all rotations that have been applied
        # are represented by angle and reverse
        angle0 = self.angle + self.reverse*180

        AffineObj.__init__(self, **options)

        if len(param) == 1:
            self.pos = param[0]

        sx = self.scalew
        sy = self.scaleh

        self.start = (self.start[0]*sx, self.start[1]*sy)

        shape = []
        for b in self.shape:
            shape.append((b[0]*sx, b[1]*sy, b[2]*sx, b[3]*sy, b[4]*sx, b[5]*sy))
        self.shape = shape
     
        self.rotate(self.angle+self.reverse*180-angle0)

        self.move(self.tip)
        
    def body(self):
        """
        Return the postscript body of the Path
        """

        out = cStringIO.StringIO()

        if self.linewidth is not None:
            out.write("%g setlinewidth " % self.linewidth)

        if self.linejoin is not None:
            out.write("%d setlinejoin " % self.linejoin)

        if self.miterlimit is not None:
            out.write("%f setmiterlimit " % self.miterlimit)

        out.write('newpath %g %g moveto\n' % self.start)
        for bez in self.shape:
            out.write('%g %g %g %g %g %g curveto\n' % bez)

        if self.closed:
            out.write('closepath\n')

        if self.bg is not None:
            out.write("gsave %s fill grestore\n" % self.bg)
        
        if self.fg is not None:
            out.write("%s stroke\n" % self.fg)

        return out.getvalue()

    def bbox(self):
        """
        Return the bounding box of the Path
        """
        
        # the (0,0) point:
        p0 = self.itoe(P(0, 0))
        xmax = xmin = p0.x
        ymax = ymin = p0.y

        for bez in self.shape:
       
            c1x, c1y, c2x, c2y, p2x, p2y = bez
            p1 = self.itoe(P(c1x, c1y)/float(defaults.units))
            p2 = self.itoe(P(c2x, c2y)/float(defaults.units))
            p3 = self.itoe(P(p2x, p2y)/float(defaults.units))

            xmax = max(xmax, p1.x, p2.x, p3.x)
            xmin = min(xmin, p1.x, p2.x, p3.x)
            ymax = max(ymax, p1.y, p2.y, p3.y)
            ymin = min(ymin, p1.y, p2.y, p3.y)

        return Bbox(sw=P(xmin, ymin), width=xmax-xmin, height=ymax-ymin)

# -------------------------------------------------------------------------
# Modifications
# -------------------------------------------------------------------------
# for symmetry....
class ArrowHead1(ArrowHead):
    '''
    Default Arrow head: triangular in Golden ratio
    '''
    pass

class ArrowHead2(ArrowHead):
    '''
    Similar to default but with concave base
    '''

    shape = [(0, 0, 1.5, -4.854, 1.5, -4.854),
           (0, -2, 0, -2, -1.5, -4.854),
           (-1.5, -4.854, 0, 0, 0, 0)]

class ArrowHead3(ArrowHead):
    '''
    Like default but rounded base
    '''

    shape = [(0, 0, 1.5, -4.854, 1.5, -4.854),
           (1.5*1.5, 1.5*(-4.854), 1.5*(-1.5), 1.5*(-4.854), -1.5, -4.854),
           (-1.5, -4.854, 0, 0, 0, 0)]

class ArrowHead4(ArrowHead):
    '''
    traditional line arrow
    '''
    bg = None
    start = (2, -5)
    closed = 0
    linewidth = .5
    shape = [(2, -5, 0, 0, 0, 0),
           (0, 0, -2, -5, -2, -5)]

# vim: expandtab shiftwidth=4: