コード例 #1
0
def rev_path(x1, y1, x2, y2, txt=None):
    elements = []
    # x1, y1 = r1.get_cx(), r1.get_cy()
    # x2, y2 = r2.get_cx(), r2.get_cy(),
    l = line(x1, y1, x2, y2)
    elements.append(l)
    style = 'stroke-width:{0};stroke:{1}'.format(16, ALUM_6)
    l.set_style(style)
    if txt:
        x, y = middle(x1, y1, x2, y2)
        style2 = StyleBuilder()
        #style2.setFontFamily('envy code r')
        style2.setFontFamily('arial')
        style2.setFontWeight('bold')
        style2.setFilling(ALUM_1)
        # shift text left and up by a bit
        # whole alphabet in this font is 167 px width
        per_char = 167. / 26
        t = text(txt, -len(txt) / 2 * per_char, 4)
        t.set_style(style2.getStyle())

        #import pdb; pdb.set_trace()
        group = rotate([t], slope_angle(x1, y1, x2, y2))
        group = translate([group], x, y)
        elements.append(group)

    return elements
コード例 #2
0
def rev_path(x1,y1, x2,y2, txt=None):
    elements = []
    # x1, y1 = r1.get_cx(), r1.get_cy()
    # x2, y2 = r2.get_cx(), r2.get_cy(),
    l = line(x1, y1,
             x2, y2)
    elements.append(l)
    style = 'stroke-width:{0};stroke:{1}'.format(16, ALUM_6)
    l.set_style(style)
    if txt:
        x, y = middle(x1, y1, x2, y2)
        style2 = StyleBuilder()
        #style2.setFontFamily('envy code r')
        style2.setFontFamily('arial')
        style2.setFontWeight('bold')
        style2.setFilling(ALUM_1)
        # shift text left and up by a bit
        # whole alphabet in this font is 167 px width
        per_char = 167./26
        t = text(txt, -len(txt)/2*per_char, 4)
        t.set_style(style2.getStyle())

        #import pdb; pdb.set_trace()
        group = rotate([t], slope_angle(x1, y1, x2, y2))
        group = translate([group], x, y)
        elements.append(group)


    return elements
コード例 #3
0
ファイル: slice_analyzer.py プロジェクト: makerbot/TestFiles
    def toSVG(self, style):
        if self.start.x is None or self.start.y is None \
            or self.end.x is None or self.end.y is None:
            return None

        myline = line(self.start.x * factor, self.start.y * factor,
                      self.end.x * factor, self.end.y * factor)
        myline.set_style(style.getStyle())
        return myline
コード例 #4
0
ファイル: style.py プロジェクト: christiankaiser/themavis
 def legend(self, elem, x, y, width, height, label_style):
     n = len(self.colors.colors)
     box_height = int(np.floor(float(height) / (n+2)))
     box_width = min(8, width/2)
     mark_style = StyleBuilder(self.mark_style)
     textsize = int(re.findall('([0-9]+)',
         label_style.get('font-size', "8")
     )[0])
     label_x = x + box_width + self.mark_length + 1
     for i in range(n):
         box = rect(
             x = mm_to_px(x), 
             y = mm_to_px(y + (n-i-1)*box_height),
             width = mm_to_px(box_width),
             height = mm_to_px(box_height)
         )
         s = deepcopy(self.styles[i].style_dict)
         s['stroke'] = 'black'
         box.set_style(StyleBuilder(s).getStyle())
         elem.addElement(box)
         
         if i < (n-1):
             mark = line(
                 X1=mm_to_px(x+box_width), 
                 Y1=mm_to_px(y+(n-i-1)*box_height),
                 X2=mm_to_px(x+box_width+self.mark_length),
                 Y2=mm_to_px(y+(n-i-1)*box_height)
             )
             mark.set_style(mark_style.getStyle())
             elem.addElement(mark)
             label = text(
                 content="%0.*f" % (self.ndecimals, self.limits[i]), 
                 x=mm_to_px(label_x), y=mm_to_px(y+(n-i-1)*box_height)+(textsize/2)
             )
             label.set_style(StyleBuilder(label_style).getStyle())
             elem.addElement(label)
      
     label = text(
         content="Min: %0.*f" % (self.ndecimals, np.min(self.values)), 
         x=mm_to_px(label_x), y=mm_to_px(y+n*box_height)+(textsize/2)
     )
     label.set_style(StyleBuilder(label_style).getStyle())
     elem.addElement(label)
     
     label = text(
         content="Max: %0.*f" % (self.ndecimals, np.max(self.values)), 
         x=mm_to_px(label_x), y=mm_to_px(y+0*box_height)+(textsize/2)
     )
     label.set_style(StyleBuilder(label_style).getStyle())
     elem.addElement(label)
コード例 #5
0
def rev_path(x1, y1, x2, y2, txt=None, color=ALUM_6, width=16):
    elements = []
    # x1, y1 = r1.get_cx(), r1.get_cy()
    # x2, y2 = r2.get_cx(), r2.get_cy(),
    l = line(x1, y1, x2, y2)
    elements.append(l)
    style = 'stroke-width:{0};stroke:{1}'.format(width, color)
    l.set_style(style)
    if txt:
        x, y = middle(x1, y1, x2, y2)
        # shift text left and up by a bit
        # whole alphabet in this font is 167 px width
        per_char = 167. / 26
        t = translate([words(txt)], -len(txt) / 2 * per_char, 4)
        group = rotate([t], slope_angle(x1, y1, x2, y2))
        group = translate([group], x, y)
        elements.append(group)

    return elements
コード例 #6
0
ファイル: allPythonContent.py プロジェクト: Mondego/pyreco
def rev_path(x1,y1, x2,y2, txt=None, color=ALUM_6, width=16):
    elements = []
    # x1, y1 = r1.get_cx(), r1.get_cy()
    # x2, y2 = r2.get_cx(), r2.get_cy(),
    l = line(x1, y1,
             x2, y2)
    elements.append(l)
    style = 'stroke-width:{0};stroke:{1}'.format(width, color)
    l.set_style(style)
    if txt:
        x, y = middle(x1, y1, x2, y2)
        # shift text left and up by a bit
        # whole alphabet in this font is 167 px width
        per_char = 167./26
        t = translate([words(txt)], -len(txt)/2*per_char, 4)
        group = rotate([t], slope_angle(x1, y1, x2, y2))
        group = translate([group], x, y)
        elements.append(group)


    return elements