Exemplo n.º 1
0
    def _build_curve(self):
        def curve_point(alpha):
            alpha = radians(alpha)
            point = (cos(alpha) * self.rx, sin(alpha) * self.ry)
            point = rotate_2d(point, radians(self.rotation))
            x, y = vadd(self.center, point)
            return (x, y, zaxis)

        def normalize_angle(angle):
            angle = fmod(angle, 360.0)
            if angle < 0:
                angle += 360.0
            return angle

        zaxis = 0.0 if len(self.center) < 3 else self.center[2]
        points = []
        delta = (self.endangle - self.startangle) / self.segments
        for segment in xrange(self.segments):
            alpha = self.startangle + delta * segment
            points.append(curve_point(alpha))
        polyline = Polyline(points, color=self.color, layer=self.layer, linetype=self.linetype)

        if equals_almost(self.startangle, normalize_angle(self.endangle)):
            polyline.close()
        return polyline
Exemplo n.º 2
0
Arquivo: curves.py Projeto: msarch/py
    def __dxftags__(self):
        def curve_point(alpha):
            alpha = radians(alpha)
            point = (cos(alpha) * self.rx, sin(alpha) * self.ry)
            point = rotate_2d(point, radians(self.rotation))
            x, y = vadd(self.center, point)
            return (x, y, zaxis)

        def normalize_angle(angle):
            angle = fmod(angle, 360.)
            if angle < 0:
                angle += 360.
            return angle

        zaxis = 0. if len(self.center) < 3 else self.center[2]
        points = []
        delta = (self.endangle - self.startangle) / self.segments
        for segment in xrange(self.segments):
            alpha = self.startangle + delta * segment
            points.append(curve_point(alpha))
        polyline = Polyline(points,
                            color=self.color,
                            layer=self.layer,
                            linetype=self.linetype)

        if equals_almost(self.startangle, normalize_angle(self.endangle)):
            polyline.close()
        return polyline.__dxftags__()
Exemplo n.º 3
0
Arquivo: rect.py Projeto: msarch/py
 def _build_polyline(self):
     """ build the rectangle with a polyline """
     polyline = Polyline(self.points, color=self.color, layer=self.layer)
     polyline.close()
     if self.linetype is not None:
         polyline['linetype'] = self.linetype
     return polyline
Exemplo n.º 4
0
Arquivo: rect.py Projeto: msarch/py
 def _build_polyline(self):
     """ build the rectangle with a polyline """
     polyline = Polyline(self.points, color=self.color, layer=self.layer)
     polyline.close()
     if self.linetype is not None:
         polyline['linetype'] = self.linetype
     return polyline
Exemplo n.º 5
0
 def _build_polyline(self):
     '''Build the polyline (key component)'''
     polyline = Polyline(self.transformed_points,
                         color=self.color,
                         layer=self.layer,
                         flags=0)
     polyline.close()  #redundant in most cases
     if self.linetype is not None:
         polyline['linetype'] = self.linetype
     return polyline