~ubuntu-branches/ubuntu/trusty/pyx/trusty

« back to all changes in this revision

Viewing changes to manual/textvalign.py

  • Committer: Bazaar Package Importer
  • Author(s): Graham Wilson
  • Date: 2004-12-25 06:42:57 UTC
  • Revision ID: james.westby@ubuntu.com-20041225064257-31469ij5uysqq302
Tags: upstream-0.7.1
ImportĀ upstreamĀ versionĀ 0.7.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from pyx import *
 
2
 
 
3
text.preamble(r"\parindent0pt")
 
4
 
 
5
c = canvas.canvas()
 
6
t = c.text(0, 0, r"spam \& eggs", [trafo.scale(6), text.parbox(1.2, baseline=text.parbox.top)])
 
7
t2 = text.text(0, 0, "eggs", [trafo.scale(6)])
 
8
b, b2 = t.bbox(), t2.bbox()
 
9
c.stroke(t.path(), [style.linewidth.THin])
 
10
c.stroke(path.line(-0.3, b.top(), 0, b.top()))
 
11
c.text(-0.5, b.top(), "valign.top", [text.vshift.mathaxis, text.halign.right])
 
12
c.stroke(path.line(-0.3, 0.5*(b.top()+b.bottom()), 0, 0.5*(b.top()+b.bottom())))
 
13
c.text(-0.5, 0.5*(b.top()+b.bottom()), "valign.middle", [text.vshift.mathaxis, text.halign.right])
 
14
c.stroke(path.line(-0.3, b.bottom(), 0, b.bottom()))
 
15
c.text(-0.5, b.bottom(), "valign.bottom", [text.vshift.mathaxis, text.halign.right])
 
16
c.stroke(path.line(0, 0, 7.5, 0))
 
17
c.text(7.7, 0, "parbox.top", [text.vshift.mathaxis])
 
18
c.stroke(path.line(7.2, 0.5*(b.bottom()-b2.bottom()), 7.5, 0.5*(b.bottom()-b2.bottom())))
 
19
c.text(7.7, 0.5*(b.bottom()-b2.bottom()), "parbox.middle", [text.vshift.mathaxis])
 
20
c.stroke(path.line(0, b.bottom()-b2.bottom(), 7.5, b.bottom()-b2.bottom()))
 
21
c.text(7.7, b.bottom()-b2.bottom(), "parbox.bottom", [text.vshift.mathaxis])
 
22
c.writeEPSfile("textvalign", paperformat="a4")