From acf876258160e9266a9f3a6041c4d3764bd264e3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=B6rg=20Lehmann?= Date: Thu, 22 Apr 2004 07:30:46 +0000 Subject: [PATCH] prepare for removal of string unit initialisation and remove some implicit conversions to visual and width lengths git-svn-id: https://pyx.svn.sourceforge.net/svnroot/pyx/trunk/pyx@1705 069f4177-920e-0410-937b-c2a4a81bcd90 --- pyx/canvas.py | 12 ++++++------ pyx/deco.py | 28 ++++++++++++++-------------- pyx/style.py | 28 ++++++++++++++-------------- 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/pyx/canvas.py b/pyx/canvas.py index 6fd640ca..0ff9ac8a 100644 --- a/pyx/canvas.py +++ b/pyx/canvas.py @@ -395,8 +395,8 @@ class canvas(_canvas): """a canvas is a collection of PSCmds together with PSAttrs""" - def writeEPSfile(self, filename, paperformat=None, rotated=0, fittosize=0, margin="1 t cm", - bbox=None, bboxenlarge="1 t pt"): + def writeEPSfile(self, filename, paperformat=None, rotated=0, fittosize=0, margin=1 * unit.t_cm, + bbox=None, bboxenlarge=1 * unit.t_pt): """write canvas to EPS file If paperformat is set to a known paperformat, the output will be centered on @@ -424,7 +424,7 @@ class canvas(_canvas): abbox = bbox is not None and bbox or self.bbox() abbox.enlarge(bboxenlarge) ctrafo = calctrafo(abbox, paperformat, margin, rotated, fittosize) - + # if there has been a global transformation, adjust the bounding box # accordingly if ctrafo: abbox.transform(ctrafo) @@ -464,8 +464,8 @@ class canvas(_canvas): file.write("%%Trailer\n") file.write("%%EOF\n") - def writePDFfile(self, filename, paperformat=None, rotated=0, fittosize=0, margin="1 t cm", - bbox=None, bboxenlarge="1 t pt"): + def writePDFfile(self, filename, paperformat=None, rotated=0, fittosize=0, margin=1 * unit.t_cm, + bbox=None, bboxenlarge=1 * unit.t_pt): sys.stderr.write("*** PyX Warning: writePDFfile is experimental and supports only a subset of PyX's features\n") if filename[-4:]!=".pdf": @@ -676,7 +676,7 @@ class canvas(_canvas): class page(canvas): def __init__(self, attrs=[], texrunner=None, pagename=None, paperformat="a4", rotated=0, fittosize=0, - margin="1 t cm", bboxenlarge="1 t pt"): + margin=1 * unit.t_cm, bboxenlarge=1 * unit.t_pt): canvas.__init__(self, attrs, texrunner) self.pagename = pagename self.paperformat = paperformat.capitalize() diff --git a/pyx/deco.py b/pyx/deco.py index 875a25e9..a922be3c 100644 --- a/pyx/deco.py +++ b/pyx/deco.py @@ -595,7 +595,7 @@ class smoothed(deco, attr.attr): """ def __init__(self, radius, softness=1, strict=0): - self.radius = unit.length(radius, default_type="v") + self.radius = radius self.softness = softness self.strict = strict @@ -868,17 +868,17 @@ class smoothed(deco, attr.attr): smoothed.clear = attr.clearclass(smoothed) _base = 1 -smoothed.SHARP = smoothed(radius="%f cm" % (_base/math.sqrt(64))) -smoothed.SHARp = smoothed(radius="%f cm" % (_base/math.sqrt(32))) -smoothed.SHArp = smoothed(radius="%f cm" % (_base/math.sqrt(16))) -smoothed.SHarp = smoothed(radius="%f cm" % (_base/math.sqrt(8))) -smoothed.Sharp = smoothed(radius="%f cm" % (_base/math.sqrt(4))) -smoothed.sharp = smoothed(radius="%f cm" % (_base/math.sqrt(2))) -smoothed.normal = smoothed(radius="%f cm" % (_base)) -smoothed.round = smoothed(radius="%f cm" % (_base*math.sqrt(2))) -smoothed.Round = smoothed(radius="%f cm" % (_base*math.sqrt(4))) -smoothed.ROund = smoothed(radius="%f cm" % (_base*math.sqrt(8))) -smoothed.ROUnd = smoothed(radius="%f cm" % (_base*math.sqrt(16))) -smoothed.ROUNd = smoothed(radius="%f cm" % (_base*math.sqrt(32))) -smoothed.ROUND = smoothed(radius="%f cm" % (_base*math.sqrt(64))) +smoothed.SHARP = smoothed(radius=_base/math.sqrt(64) * unit.v_cm) +smoothed.SHARp = smoothed(radius=_base/math.sqrt(32) * unit.v_cm) +smoothed.SHArp = smoothed(radius=_base/math.sqrt(16) * unit.v_cm) +smoothed.SHarp = smoothed(radius=_base/math.sqrt(8) * unit.v_cm) +smoothed.Sharp = smoothed(radius=_base/math.sqrt(4) * unit.v_cm) +smoothed.sharp = smoothed(radius=_base/math.sqrt(2) * unit.v_cm) +smoothed.normal = smoothed(radius=_base * unit.v_cm) +smoothed.round = smoothed(radius=_base*math.sqrt(2) * unit.v_cm) +smoothed.Round = smoothed(radius=_base*math.sqrt(4) * unit.v_cm) +smoothed.ROund = smoothed(radius=_base*math.sqrt(8) * unit.v_cm) +smoothed.ROUnd = smoothed(radius=_base*math.sqrt(16) * unit.v_cm) +smoothed.ROUNd = smoothed(radius=_base*math.sqrt(32) * unit.v_cm) +smoothed.ROUND = smoothed(radius=_base*math.sqrt(64) * unit.v_cm) diff --git a/pyx/style.py b/pyx/style.py index 3d280ce8..29ed0cd1 100644 --- a/pyx/style.py +++ b/pyx/style.py @@ -160,8 +160,8 @@ class linewidth(unit.length, attr.sortbeforeexclusiveattr, strokestyle): """linewidth of paths""" - def __init__(self, l="0 cm"): - unit.length.__init__(self, l=l, default_type="w") + def __init__(self, l): + unit.length.__init__(self, l) attr.sortbeforeexclusiveattr.__init__(self, linewidth, [dash, linestyle]) def outputPS(self, file): @@ -172,16 +172,16 @@ class linewidth(unit.length, attr.sortbeforeexclusiveattr, strokestyle): _base = 0.02 -linewidth.THIN = linewidth("%f cm" % (_base/math.sqrt(32))) -linewidth.THIn = linewidth("%f cm" % (_base/math.sqrt(16))) -linewidth.THin = linewidth("%f cm" % (_base/math.sqrt(8))) -linewidth.Thin = linewidth("%f cm" % (_base/math.sqrt(4))) -linewidth.thin = linewidth("%f cm" % (_base/math.sqrt(2))) -linewidth.normal = linewidth("%f cm" % _base) -linewidth.thick = linewidth("%f cm" % (_base*math.sqrt(2))) -linewidth.Thick = linewidth("%f cm" % (_base*math.sqrt(4))) -linewidth.THick = linewidth("%f cm" % (_base*math.sqrt(8))) -linewidth.THIck = linewidth("%f cm" % (_base*math.sqrt(16))) -linewidth.THICk = linewidth("%f cm" % (_base*math.sqrt(32))) -linewidth.THICK = linewidth("%f cm" % (_base*math.sqrt(64))) +linewidth.THIN = linewidth(_base/math.sqrt(32) * unit.w_cm) +linewidth.THIn = linewidth(_base/math.sqrt(16) * unit.w_cm) +linewidth.THin = linewidth(_base/math.sqrt(8) * unit.w_cm) +linewidth.Thin = linewidth(_base/math.sqrt(4) * unit.w_cm) +linewidth.thin = linewidth(_base/math.sqrt(2) * unit.w_cm) +linewidth.normal = linewidth(_base * unit.w_cm) +linewidth.thick = linewidth(_base*math.sqrt(2) * unit.w_cm) +linewidth.Thick = linewidth(_base*math.sqrt(4) * unit.w_cm) +linewidth.THick = linewidth(_base*math.sqrt(8) * unit.w_cm) +linewidth.THIck = linewidth(_base*math.sqrt(16) * unit.w_cm) +linewidth.THICk = linewidth(_base*math.sqrt(32) * unit.w_cm) +linewidth.THICK = linewidth(_base*math.sqrt(64) * unit.w_cm) linewidth.clear = attr.clearclass(linewidth) -- 2.11.4.GIT