Commit 24c54b35 authored by Amélie Dumont's avatar Amélie Dumont

tests amelie: 2 colonnes, foliotage, décalage page gauche/droite, pages séparées

parent a354b4f3
......@@ -266,16 +266,16 @@ for node in api.nodes():
# 10 - diagrams
def plot(data, labelx, sublabelx, labely, sublabely, labelz, sublabelz):
width, height = 130, 130
magnitude = 1.0
depth = 2.0 ** 0.5 * 0.5
antidiagonal = False
left, top, right, bottom = 20, 20, 40, 20
distance = 5.0
sublabelz %= magnitude
black = rgb(0, 0, 0)
regular = font.open('src/Montserrat-Regular.ttf')
bold = font.open('src/Montserrat-Bold.ttf')
......@@ -284,7 +284,7 @@ def plot(data, labelx, sublabelx, labely, sublabely, labelz, sublabelz):
label = strike(regular).size(10, 12).color(black)
labelbold = strike(bold).size(10, 12).color(black)
g = group()
m, n = len(data), len(data[0])
w, h = n - 1.0, m - 1.0
k = width / (w + depth * h)
......@@ -293,16 +293,16 @@ def plot(data, labelx, sublabelx, labely, sublabely, labelz, sublabelz):
magnitude *= norm
dx += left
dy += top
assert norm > 0, 'Diagram height too small.'
if antidiagonal:
points = [[((x+y*depth)*k, (h-y*depth-data[y][x]*norm)*k)
for x in range(n)] for y in range(m)]
else:
points = [[((x+(h-y)*depth)*k, (h-y*depth-data[y][x]*norm)*k)
for x in range(n)] for y in range(m)]
for y in range(1, m - 1):
coordinates = []
for x in range(n):
......@@ -313,7 +313,7 @@ def plot(data, labelx, sublabelx, labely, sublabely, labelz, sublabelz):
for y in range(m):
coordinates.extend(points[y][x])
g.place(thick.polyline(*coordinates)).position(dx, dy)
coordinates = []
for x in range(0, n - 1):
coordinates.extend(points[0][x])
......@@ -324,7 +324,7 @@ def plot(data, labelx, sublabelx, labely, sublabely, labelz, sublabelz):
for y in reversed(range(1, m)):
coordinates.extend(points[y][0])
g.place(thick.polygon(*coordinates)).position(dx, dy)
x0, y0 = 0, h*k
x1, y1 = w*k, h*(1-depth)*k
x2, y2 = (w+h*depth)*k, (h*(1-depth)-magnitude)*k
......@@ -349,7 +349,7 @@ def plot(data, labelx, sublabelx, labely, sublabely, labelz, sublabelz):
bx, by = x2, (y0+y3)*0.5
cx, cy = (x1+x2)*0.5, (y2+y3)*0.5
dist = -distance
ex = labelbold.width(labelx)*0.5 / p.k
fx, fy = labelbold.textsize*0.1 / p.k, labelbold.leading*0.5 / p.k
gy = labelbold.ascender() / p.k
......@@ -362,7 +362,7 @@ def plot(data, labelx, sublabelx, labely, sublabely, labelz, sublabelz):
g.place(text(
labelbold.paragraph(labelz),
label.paragraph(sublabelz))).position(bx+distance+dx + fx, by+dy - fy)
return g
p = d.addpage()
......@@ -399,6 +399,3 @@ p.place(text(
view(d.pdf())
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment