from gram import Gram, GramCode gr = Gram() gr.svgPxForCm = 100 gr.baseName = 'code' gr.grid(0, 0, 3, 3) gr.code("% some tikz code") gr.code(r"""\draw [->] (1,1) .. controls (1.5,3) and (2,0) .. (2.5,2);""") gr.code(r"""\draw [thick, gray, ->] (0,2) parabola bend (0.5, 1) (1, 2.5);""") gr.png() # Wipe out the tikz code toRemove = [g for g in gr.graphics if isinstance(g, GramCode)] for g in toRemove: gr.graphics.remove(g) gr.code( r'<path d="M100 -100 C 150 -300 200 0 250 -200" stroke="black" fill="none" />' ) gr.code( r'<path d="M 0 -200 Q 50 20 100 -250" stroke="grey" stroke-width="4px" fill="none" />' ) gr.svg()
from gram import Gram,GramCode gr = Gram() gr.svgPxForCm = 100 gr.baseName = 'rawcode' gr.grid(0,0,3,3) gr.code("% some tikz code") gr.code(r"""\draw [->] (1,1) .. controls (1.5,3) and (2,0) .. (2.5,2);""") gr.code(r"""\draw [thick, gray, ->] (0,2) parabola bend (0.5, 1) (1, 2.5);""") gr.png() # Wipe out the tikz code toRemove = [g for g in gr.graphics if isinstance(g, GramCode)] for g in toRemove: gr.graphics.remove(g) gr.code(r'<path d="M100 -100 C 150 -300 200 0 250 -200" stroke="black" fill="none" />') gr.code(r'<path d="M 0 -200 Q 50 20 100 -250" stroke="grey" stroke-width="4px" fill="none" />') gr.svg()
from gram import Gram tt = "xxx xxX xXy xyy".split() xx = [i for i in range(1,5)] gr = Gram() gr.baseName = 'textVerticalAlignment' gr.grid(0,0,5,5) for i in range(4): gr.code(r"\node [anchor=west] at (%.1f,4.0) {%s};" % (xx[i], tt[i])) g = gr.text(tt[i],xx[i],3) g.anchor = 'west' gr.code(r"\node [anchor=west,draw] at (%.1f,2.0) {%s};" % (xx[i], tt[i])) g = gr.text(tt[i],xx[i],1) g.anchor = 'west' g.draw = True gr.png() # gr.svg() tikz code does not work here
from gram import Gram tt = "xxx xxX xXy xyy".split() xx = [i for i in range(1, 5)] gr = Gram() gr.baseName = 'textVerticalAlignment' gr.grid(0, 0, 5, 5) for i in range(4): gr.code(r"\node [anchor=west] at (%.1f,4.0) {%s};" % (xx[i], tt[i])) g = gr.text(tt[i], xx[i], 3) g.anchor = 'west' gr.code(r"\node [anchor=west,draw] at (%.1f,2.0) {%s};" % (xx[i], tt[i])) g = gr.text(tt[i], xx[i], 1) g.anchor = 'west' g.draw = True gr.png() # gr.svg() tikz code does not work here