Example #1
0
 def __init__(self, findersOrPaths=None, **kwargs):
     Element.__init__(self, **kwargs)
     self.finders = {}  # Key is finder root, so we keep unique finders.
     if not findersOrPaths:  # At least make it search in the current directory
         findersOrPaths = ['.']
     self.addFinders(findersOrPaths)
     self.originTop = True
 def __init__(self, font, s=None, draw3D=True, location=None, showAxisNames=True, **kwargs):
     Element.__init__(self, **kwargs)
     # Initialize the default Element behavior tags.
     self.font = font
     self.glyphNames = s or 'e'
     self.draw3D = draw3D # TODO: Draw as 3D structure of spheres and needles/spikes.
     self.location = location # Use to visualize a specific location, otherwise all needles are at min value.
     self.showAxisNames = showAxisNames
Example #3
0
    def __init__(self, f, name=None, label=None, title=None, eId=None, c='F', s=1, strokeWidth=None, stroke=noColor,
            earSize=None, earLeft=True, earFill=None, cFill=None, cStroke=None, cStrokeWidth=None,
            labelFont=None, labelFontSize=None, titleFont=None, titleFontSize=None, show=True, **kwargs):
        """
        >>> from pagebot.fonttoolbox.objects.font import getFont
        >>> from pagebot.fonttoolbox.fontpaths import getTestFontsPath
        >>> from pagebot.contexts.drawbotcontext import DrawBotContext
        >>> from pagebot.elements import newRect
        >>> from pagebot.document import Document
        >>> from pagebot.toolbox.color import color
        >>> c = DrawBotContext()
        >>> w, h = 300, 400
        >>> doc = Document(w=w, h=h, autoPages=1, padding=30, originTop=False, context=c)
        >>> page = doc[1]
        >>> path = getTestFontsPath() + '/google/roboto/Roboto-Regular.ttf' # We know this exists in the PageBot repository
        >>> font = getFont(path)
        >>> iw, ih = w/4, h/4
        >>> x, y = w/8, h/8
        >>> fi = FontIcon(font, x=x, y=y, w=iw, h=ih, name="40k", earSize=0.3, earLeft=True, parent=page, stroke=blackColor, strokeWidth=3)
        >>> bg = newRect(x=w/2, w=w/2, h=h/2, fill=blackColor,parent=page)
        >>> fi = FontIcon(font, x=x, y=y, w=iw, h=ih, name="40k", c="H", cFill=color(0.5), earSize=0.3, earLeft=True, earFill=None, fill=color(1,0,0,0.5), parent=bg, stroke=color(1), strokeWidth=3)
        >>> doc.export('_export/FontIconTest.pdf')
        >>> doc.export('_export/FontIconTest.jpg')
        """

        Element.__init__(self,  **kwargs)
        self.f = f # Font instance
        if title is not None:
            self.title = title or "%s %s" % (f.info.familyName, f.info.styleName)
        self.titleFont = titleFont, labelFont or f
        self.titleFontSize = pt(28)
        self.labelFont = labelFont or f
        self.labelFontSize = labelFontSize or pt(10)
        self.label = label # Optiona second label line
        self.c = c # Character(s) in the icon.
        if cFill is None:
            cFill = blackColor
        self.cFill = cFill
        if cStroke is None:
            cStroke = blackColor
        self.cStroke = cStroke
        self.cStrokeWidth = cStrokeWidth or pt(1)
        self.scale = s
        self.show = show
        if stroke is not None:
            self.style["stroke"] = stroke
        if strokeWidth is not None:
            self.style["strokeWidth"] = strokeWidth
        self.earSize = earSize or 0.25 # 1/4 of width
        self.earLeft = earLeft
        if earFill is None:
            earFill = self.css("fill")
        self.earFill = earFill
 def __init__(self, font, x=None, y=None, w=None, h=None, glyphName=None, location=None, angles=None, showAxisNames=True,
     **kwargs):
     Element.__init__(self, **kwargs)
     self.x = x
     self.y = y
     self.h = h
     self.w = w
     self.font = font
     if angles is None:
         angles = self.initAngles() # Initialize the angles in equal parts if not defined.
     self.angles = angles
     self.showAxisNames = showAxisNames
     # Make sure that this is a formatted string. Otherwise create it with the current style.
     # Note that in case there is potential clash in the double usage of fill and stroke.
     self.glyphName = glyphName or 'e'