Exemplo n.º 1
0
from gram import Gram, GramCoord, GramGrid, GramText

gr = Gram()
gr.baseName = 'anchors'
gr.font = 'helvetica'
gr.defaultInnerSep = 0.1
g = GramGrid(0, 1, 8, 7)
gr.graphics.append(g)

##    _goodAnchors = ['west', 'north west', 'north', 'north east', 'east',
##                        'base', 'base west', 'base east',
##                        'south west', 'south', 'south east',
##                        #'mid', 'mid west', 'mid east',
##                        'center'] # center seems to be the default

nnDict = {}
nn = []
for i in range(3):
    for j in range(4):
        indx = (i * 4) + j
        refPt = gr.goodAnchors[indx]
        print indx, refPt
        n = GramCoord((2 * j) + 1, (2 * i) + 1, refPt)
        nnDict[refPt] = n
        nn.append(n)
        gr.graphics.append(n)

myStr = 'Xxy'
theTextSize = 'normalsize'
for i in range(12):
    anch = gr.goodAnchors[i]
Exemplo n.º 2
0
from __future__ import print_function
from gram import Gram,GramCoord,GramGrid,GramText

Gram.pdflatexOutputGoesToDevNull = True

gr = Gram()
gr.pdfViewer = 'open'
gr.baseName = 'anchors'
gr.font = 'helvetica'
gr.defaultInnerSep = 0.1
g = GramGrid(0, 1, 8, 7)
gr.graphics.append(g)

##    _goodAnchors = ['west', 'north west', 'north', 'north east', 'east',
##                        'base', 'base west', 'base east',
##                        'south west', 'south', 'south east',
##                        #'mid', 'mid west', 'mid east',
##                        'center'] # center seems to be the default

nnDict = {}
nn = []
for i in range(3):
    for j in range(4):
        indx = (i * 4) + j
        refPt = gr.goodAnchors[indx]
        print(indx, refPt)
        n = GramCoord((2 * j) + 1,
                      (2 * i) + 1,
                      refPt)
        nnDict[refPt] = n
        nn.append(n)
Exemplo n.º 3
0
from gram import Gram
gr = Gram()
gr.baseName = 'line'
gr.font = 'Helvetica'
gr.grid(0,0,4,4)
g = gr.line(1,1,2,3)
g.colour = 'black!20'
g.colour.transparent = True
g.lineThickness = 28. # pts
g = gr.line(3, 3.5, 2, 1)
g.lineThickness = 'semithick'
g.lineStyle = 'dashed'
# A default, un-modified line
gr.line(1, 3, 1.5, 0.5)
g = gr.line(3.5, 1, 3.5, 2)
g.lineThickness = 10
g.cap = 'rect'  # default butt
g = gr.text('some lines', 3,3)
g.anchor = 'north west'
g.textSize = 'normalsize'
gr.png()
gr.svg()
Exemplo n.º 4
0
& each & 0.01 \\ 
Gnu & stuffed & 92.50 \\ 
Emu & stuffed & 33.33 \\ 
Armadillo & frozen & 8.99 \\ \addlinespace
Total &           & 56.23 \\ \bottomrule 
\end{tabular}
\end{center}
\end{minipage}
"""

t5 = r"""\includegraphics[scale = 0.25, angle=32]
{../../frownie_tongue.png}"""

from gram import Gram
gr = Gram()
gr.font = "palatino"
gr.latexUsePackages.append('mdwlist')
gr.latexUsePackages.append('booktabs')
gr.latexUsePackages.append('graphicx')
gr.showTextAnchor=True
gr.showTextBB=True

bNames = ['t1', 't2', 't3', 't3x', 't4', 't5']
tt = [t1, t2, t3, t3x, t4, t5]

for dNum in range(6):
    gr.graphics = []
    gr.baseName = bNames[dNum]
    gr.text(tt[dNum],0,0)
    print("about to do %s" % tt[dNum])
    gr.pdf()
Exemplo n.º 5
0
from gram import Gram

gr = Gram()
gr.font = 'palatino'
gr.baseName = 'little'
g = gr.text("A bit of text.", 1, 0)
g.draw = True
g = gr.text(r"$\sum \alpha\beta$", 2.5, 0)
g.anchor = 'west'
g = gr.text("0123456789", 3.5, 0)
g.anchor = 'west'
gr.png()

gr = Gram()
gr.font = 'palatino'
gr.baseName = 'little'
g = gr.text("A bit of text.", 1, 0)
g.draw = True
g = gr.text(
    '&#x2211;<tspan style="font-style: italic;">&#x03b1;&#x03b2;</tspan>', 2.5,
    0)
g.anchor = 'west'
g = gr.text("0123456789", 3.5, 0)
g.anchor = 'west'
gr.svg()
Exemplo n.º 6
0
Gnat & per gram & 13.65 \\ 
& each & 0.01 \\ 
Gnu & stuffed & 92.50 \\ 
Emu & stuffed & 33.33 \\ 
Armadillo & frozen & 8.99 \\ \addlinespace
Total &           & 56.23 \\ \bottomrule 
\end{tabular}
\end{center}
\end{minipage}
"""

t5 = r"""\includegraphics[scale = 0.25, angle=32]
{../../frownie_tongue.png}"""

from gram import Gram
gr = Gram()
gr.font = "palatino"
gr.latexUsePackages.append('mdwlist')
gr.latexUsePackages.append('booktabs')
gr.latexUsePackages.append('graphicx')

bNames = ['t1', 't2', 't3', 't3x', 't4', 't5']
tt = [t1, t2, t3, t3x, t4, t5]

for dNum in range(6):
    gr.graphics = []
    gr.baseName = bNames[dNum]
    gr.text(tt[dNum], 0, 0)
    print "about to do %s" % tt[dNum]
    gr.png()
Exemplo n.º 7
0
from gram import Gram,GramCoord,GramText
gr = Gram()
gr.font = 'times'
gr.baseName = 'style'

g = GramText('xXy')
g.cA = GramCoord()
g.textSize = 'Huge'
g.textShape = 'itshape'
g.color = 'green'
g.rotate = '30'
g.name = 'st1'
g.anchor = 'north west'
gr.styleDict[g.name] = g

g = GramText('xXy')
g.cA = GramCoord()
g.textSize = 'footnotesize'
g.textFamily = 'sffamily'
g.color = 'blue'
g.draw = 'violet'
g.name = 'st2'
g.anchor = 'center'
gr.styleDict[g.name] = g

for i in range(5):
    g = gr.text("Howdy!", 1, i)
    g.style = 'st1'

g = gr.styleDict['st2']
g.draw = 'orange'
Exemplo n.º 8
0
from gram import Gram
gr = Gram()
gr.baseName = 'line'
gr.font = 'Helvetica'
gr.grid(0, 0, 4, 4)
g = gr.line(1, 1, 2, 3)
g.colour = 'black!20'
g.lineThickness = 28.  # pts
g = gr.line(3, 3.5, 2, 1)
g.lineThickness = 'semithick'
g.lineStyle = 'dashed'
# A default, un-modified line
gr.line(1, 3, 1.5, 0.5)
g = gr.line(3.5, 1, 3.5, 2)
g.lineThickness = 10
g.cap = 'rect'  # default butt
g = gr.text('some lines', 3, 3)
g.anchor = 'north west'
g.textSize = 'normalsize'
gr.png()
gr.svg()
Exemplo n.º 9
0
from gram import Gram
gr1 = Gram()
gr1.font = 'helvetica'
gr1.baseName = 'gramInGram'
gr1.text("Embedding gram", 0,0)
gr2 = Gram()
g = gr2.text("Embedded gram",0,0)
gr2.gX = 0.3
gr2.gY = 0.5
gr1.grams.append(gr2)
gr1.pdf()
gr1.svg()
Exemplo n.º 10
0
from gram import Gram
gr1 = Gram()
gr1.font = 'helvetica'
gr1.baseName = 'gramInGram'
gr1.text("Embedding gram", 0, 0)
gr2 = Gram()
g = gr2.text("Embedded gram", 0, 0)
gr2.gX = 0.3
gr2.gY = 0.5
gr1.grams.append(gr2)
gr1.pdf()
gr1.svg()
Exemplo n.º 11
0
from gram import Gram
gr = Gram()
gr.baseName = 'wrapped'
gr.font = 'palatino'
myText = r"""This is a bit of text, with a
\texttt{textWidth}, to show wrapping.  You
can also set the \texttt{textJustification},
although this one does not, and so uses the
default \texttt{ragged} justification."""
g = gr.text(myText, 1,2.5)
g.textWidth = 4.0
gr.text(r'''This text is not wrapped, as
it has no \texttt{textWidth}''', 0,0)
gr.png()