Example #1
0
# -----------------------------------------------------------------------
# imports
# -----------------------------------------------------------------------

from __future__ import division

from hep.draw import *
from hep.draw import metafile, postscript, xwindow, imagefile
import sys

# -----------------------------------------------------------------------
# tests
# -----------------------------------------------------------------------

canvas = Canvas((-1, -1, 1, 1), aspect=1)
canvas.append(Line(((-1, -1), (-1, 1), (1, 1), (1, -1), (-1, -1))))
canvas.append(Polygon(((-0.8, 0), (0, -0.7), (0.5, 0.1), (0.45, 0.85)), color=Color(1, 0.92, 0.96)))
canvas.append(Line(((1, -1), (-1, 1))))
canvas.append(Line(((0, 0), (-0.3, -0.3))))
canvas.append(SimpleText((0, 0), "Hello, world!", alignment=(0.5, 0.5)))
figure = BrickLayout((2, 4))
map(figure.append, 6 * (canvas,))

postscript.EPSFile("draw2.eps", (0.15, 0.10)).render(figure)
metafile.EnhancedMetafile("draw2.emf", (0.15, 0.10)).render(figure)
imagefile.render(figure, "draw2.png", (600, 400))
window = xwindow.FigureWindow(figure, (0.15, 0.1))

if len(sys.argv) > 1:
    raw_input("hit enter to end: ")
Example #2
0
from   hep import *
from   hep.draw import *
from   hep.draw import metafile, postscript, xwindow, imagefile
import sys

#-----------------------------------------------------------------------
# test
#-----------------------------------------------------------------------

def symbols():
    f = Canvas((0, 0, 0.18, 0.18))
    for n, symbol_name in enumerate(sort(xwindow.symbol_map.keys())):
        x = 0.01 + (n // 24) * 0.04
        y = (26 - n % 24) * 0.006
        f.append(Symbol((x, y), symbol_name,
                        font="Times", font_size=14 * point))
        f.append(SimpleText((x + 0.008, y), symbol_name,
                            font_size=14 * point))
    return f


f = symbols()

metafile.EnhancedMetafile("symbols1.emf", (0.18, 0.18)).render(f)
postscript.PSFile("symbols1.ps").render(f)
imagefile.render(f, "symbols1.png", virtual_size=(0.18, 0.18))
window = xwindow.FigureWindow(f, (0.18, 0.18))

if len(sys.argv) > 1:
    raw_input()