write_shapes.json

Le fichier JSON de l'exemple « Le rapport du mois, ses graphiques tracés en courbes ». Un camembert de l'emploi des heures, une jauge en anneau de l'avancement de l'année, une carte aux coins adoucis, et des arcs à qui l'on dit où aller plutôt que de combien tourner.

JSON 336 lignes

Ce fichier est une requête : une application l'envoie par le réseau au serveur, qui crée le PDF et le renvoie. Il donne la même page que les versions Rust et Python de cet exemple. Une requête nomme chaque fichier qu'elle emploie, jamais le contenu de ces fichiers ; l'appel porte la requête et les fichiers ensemble. Une police que le serveur détient déjà, comme DejaVuSans, se nomme sans rien y joindre. Envoyez la requête à l'adresse que donne la page de l'API.

À quoi sert cet exemple

Le rapport mensuel d'une imprimerie dit où sont passées les heures, où en est le travail depuis le début de l'année, et comment les commandes ont bougé de semaine en semaine. Ces chiffres arrivent d'habitude sous forme d'images collées sur la page : très bien à l'écran, floues dès que quelqu'un imprime ou regarde de plus près.

Ce que montre cet exemple

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
{
  "items": [
    {
      "type": "text",
      "rect": {"llx": 72, "lly": 769.6, "urx": 523, "ury": 790},
      "content": ["The month, drawn in curves"],
      "font": "DejaVuSans",
      "font_size": 17
    },

    {
      "type": "text",
      "rect": {"llx": 72, "lly": 700.6, "urx": 523, "ury": 757.6},
      "content": ["A page states a path with straight segments and cubic curves, and with nothing else: there is no circle operator and no arc operator. Every shape below was asked for by name — a centre and a radius, two angles, three points to pass through — and the curves were worked out for it. No piece bends further than a quarter turn, so a circle is four curves and the outline is out by a fortieth of a point on a circle an inch across."],
      "font": "DejaVuSans",
      "font_size": 9.5
    },

    {
      "type": "text",
      "rect": {"llx": 72, "lly": 665.4, "urx": 523, "ury": 678.6},
      "content": ["Where the hours went"],
      "font": "DejaVuSans",
      "font_size": 11
    },

    {
      "type": "path",
      "segments": [
        {"move_to": {"x": 146, "y": 647.4}},
        {"curve_to": {"x1": 183.555, "y1": 647.4, "x2": 214, "y2": 616.955, "x": 214, "y": 579.4}},
        {"curve_to": {"x1": 214, "y1": 553.573, "x2": 199.369, "y2": 529.975, "x": 176.235, "y": 518.492}},
        {"line_to": {"x": 146, "y": 579.4}},
        "close"
      ],
      "fill": [0.16, 0.33, 0.62]
    },

    {
      "type": "path",
      "segments": [
        {"move_to": {"x": 176.235, "y": 518.492}},
        {"curve_to": {"x1": 142.596, "y1": 501.793, "x2": 101.79, "y2": 515.526, "x": 85.092, "y": 549.165}},
        {"curve_to": {"x1": 83.613, "y1": 552.143, "x2": 82.356, "y2": 555.225, "x": 81.328, "y": 558.387}},
        {"line_to": {"x": 146, "y": 579.4}},
        "close"
      ],
      "fill": [0.3, 0.57, 0.75]
    },

    {
      "type": "path",
      "segments": [
        {"move_to": {"x": 81.328, "y": 558.387}},
        {"curve_to": {"x1": 73.188, "y1": 583.439, "x2": 80.249, "y2": 610.938, "x": 99.451, "y": 628.97}},
        {"line_to": {"x": 146, "y": 579.4}},
        "close"
      ],
      "fill": [0.55, 0.73, 0.82]
    },

    {
      "type": "path",
      "segments": [
        {"move_to": {"x": 99.451, "y": 628.97}},
        {"curve_to": {"x1": 112.059, "y1": 640.81, "x2": 128.704, "y2": 647.4, "x": 146, "y": 647.4}},
        {"line_to": {"x": 146, "y": 579.4}},
        "close"
      ],
      "fill": [0.79, 0.86, 0.9]
    },

    {
      "type": "path",
      "segments": [
        {"rounded_polyline": {"points": [{"x": 242, "y": 625.4}, {"x": 254, "y": 625.4}, {"x": 254, "y": 637.4}, {"x": 242, "y": 637.4}], "radius": -3, "close": true}}
      ],
      "fill": [0.16, 0.33, 0.62]
    },

    {
      "type": "text",
      "rect": {"llx": 262, "lly": 617, "urx": 442, "ury": 628.4},
      "content": ["Drawing office"],
      "font": "DejaVuSans",
      "font_size": 9.5
    },

    {
      "type": "path",
      "segments": [
        {"rounded_polyline": {"points": [{"x": 242, "y": 599.4}, {"x": 254, "y": 599.4}, {"x": 254, "y": 611.4}, {"x": 242, "y": 611.4}], "radius": -3, "close": true}}
      ],
      "fill": [0.3, 0.57, 0.75]
    },

    {
      "type": "text",
      "rect": {"llx": 262, "lly": 591, "urx": 442, "ury": 602.4},
      "content": ["Plates and proofs"],
      "font": "DejaVuSans",
      "font_size": 9.5
    },

    {
      "type": "path",
      "segments": [
        {"rounded_polyline": {"points": [{"x": 242, "y": 573.4}, {"x": 254, "y": 573.4}, {"x": 254, "y": 585.4}, {"x": 242, "y": 585.4}], "radius": -3, "close": true}}
      ],
      "fill": [0.55, 0.73, 0.82]
    },

    {
      "type": "text",
      "rect": {"llx": 262, "lly": 565, "urx": 442, "ury": 576.4},
      "content": ["Delivery"],
      "font": "DejaVuSans",
      "font_size": 9.5
    },

    {
      "type": "path",
      "segments": [
        {"rounded_polyline": {"points": [{"x": 242, "y": 547.4}, {"x": 254, "y": 547.4}, {"x": 254, "y": 559.4}, {"x": 242, "y": 559.4}], "radius": -3, "close": true}}
      ],
      "fill": [0.79, 0.86, 0.9]
    },

    {
      "type": "text",
      "rect": {"llx": 262, "lly": 539, "urx": 442, "ury": 550.4},
      "content": ["Storage"],
      "font": "DejaVuSans",
      "font_size": 9.5
    },

    {
      "type": "text",
      "rect": {"llx": 72, "lly": 488.2, "urx": 523, "ury": 501.4},
      "content": ["How far into the year the work is"],
      "font": "DejaVuSans",
      "font_size": 11
    },

    {
      "type": "path",
      "segments": [
        {"move_to": {"x": 170, "y": 426.2}},
        {"curve_to": {"x1": 170, "y1": 451.605, "x2": 149.405, "y2": 472.2, "x": 124, "y": 472.2}},
        {"curve_to": {"x1": 98.595, "y1": 472.2, "x2": 78, "y2": 451.605, "x": 78, "y": 426.2}},
        {"curve_to": {"x1": 78, "y1": 400.795, "x2": 98.595, "y2": 380.2, "x": 124, "y": 380.2}},
        {"curve_to": {"x1": 149.405, "y1": 380.2, "x2": 170, "y2": 400.795, "x": 170, "y": 426.2}},
        "close",
        {"move_to": {"x": 154, "y": 426.2}},
        {"curve_to": {"x1": 154, "y1": 409.631, "x2": 140.569, "y2": 396.2, "x": 124, "y": 396.2}},
        {"curve_to": {"x1": 107.431, "y1": 396.2, "x2": 94, "y2": 409.631, "x": 94, "y": 426.2}},
        {"curve_to": {"x1": 94, "y1": 442.769, "x2": 107.431, "y2": 456.2, "x": 124, "y": 456.2}},
        {"curve_to": {"x1": 140.569, "y1": 456.2, "x2": 154, "y2": 442.769, "x": 154, "y": 426.2}},
        "close"
      ],
      "fill": [0.9, 0.92, 0.95]
    },

    {
      "type": "path",
      "segments": [
        {"move_to": {"x": 124, "y": 464.2}},
        {"curve_to": {"x1": 144.987, "y1": 464.2, "x2": 162, "y2": 447.187, "x": 162, "y": 426.2}},
        {"curve_to": {"x1": 162, "y1": 405.213, "x2": 144.987, "y2": 388.2, "x": 124, "y": 388.2}},
        {"curve_to": {"x1": 114.335, "y1": 388.2, "x2": 105.033, "y2": 391.883, "x": 97.987, "y": 398.499}}
      ],
      "stroke": {"width": 16, "color": [0.16, 0.33, 0.62]}
    },

    {
      "type": "text",
      "rect": {"llx": 190, "lly": 418.8, "urx": 470, "ury": 430.2},
      "content": ["of the year's work is behind us"],
      "font": "DejaVuSans",
      "font_size": 9.5
    },

    {
      "type": "text",
      "rect": {"llx": 72, "lly": 363, "urx": 523, "ury": 376.2},
      "content": ["A card whose corners are eased off"],
      "font": "DejaVuSans",
      "font_size": 11
    },

    {
      "type": "path",
      "segments": [
        {"move_to": {"x": 86, "y": 255}},
        {"line_to": {"x": 509, "y": 255}},
        {"curve_to": {"x1": 516.732, "y1": 255, "x2": 523, "y2": 261.268, "x": 523, "y": 269}},
        {"line_to": {"x": 523, "y": 337}},
        {"curve_to": {"x1": 523, "y1": 344.732, "x2": 516.732, "y2": 351, "x": 509, "y": 351}},
        {"line_to": {"x": 86, "y": 351}},
        {"curve_to": {"x1": 78.268, "y1": 351, "x2": 72, "y2": 344.732, "x": 72, "y": 337}},
        {"line_to": {"x": 72, "y": 269}},
        {"curve_to": {"x1": 72, "y1": 261.268, "x2": 78.268, "y2": 255, "x": 86, "y": 255}},
        "close"
      ],
      "fill": [0.96, 0.97, 0.98],
      "stroke": {"width": 0.8, "color": [0.72, 0.72, 0.72]}
    },

    {
      "type": "text",
      "rect": {"llx": 90, "lly": 320.2, "urx": 390, "ury": 331},
      "content": ["Orders taken, week by week"],
      "font": "DejaVuSans",
      "font_size": 9
    },

    {
      "type": "path",
      "segments": [
        {"move_to": {"x": 90, "y": 292.314}},
        {"line_to": {"x": 157.751, "y": 301.046}},
        {"curve_to": {"x1": 158.692, "y1": 301.167, "x2": 159.644, "y2": 301.193, "x": 160.59, "y": 301.122}},
        {"line_to": {"x": 226.246, "y": 296.186}},
        {"curve_to": {"x1": 227.63, "y1": 296.081, "x2": 229.022, "y2": 296.184, "x": 230.376, "y": 296.489}},
        {"line_to": {"x": 295.383, "y": 311.151}},
        {"curve_to": {"x1": 296.786, "y1": 311.468, "x2": 298.229, "y2": 311.566, "x": 299.662, "y": 311.443}},
        {"line_to": {"x": 364.798, "y": 305.846}},
        {"curve_to": {"x1": 366.038, "y1": 305.74, "x2": 367.287, "y2": 305.799, "x": 368.511, "y": 306.023}},
        {"line_to": {"x": 434.288, "y": 318.032}},
        {"curve_to": {"x1": 435.315, "y1": 318.22, "x2": 436.36, "y2": 318.292, "x": 437.403, "y": 318.247}},
        {"line_to": {"x": 505, "y": 315.343}}
      ],
      "stroke": {"width": 2.2, "color": [0.3, 0.57, 0.75]}
    },

    {
      "type": "text",
      "rect": {"llx": 72, "lly": 217.8, "urx": 523, "ury": 231},
      "content": ["Arcs told where to go, not how far to turn"],
      "font": "DejaVuSans",
      "font_size": 11
    },

    {
      "type": "text",
      "rect": {"llx": 72, "lly": 183.6, "urx": 272, "ury": 193.8},
      "content": ["One arc, through three points"],
      "font": "DejaVuSans",
      "font_size": 8.5
    },

    {
      "type": "path",
      "segments": [
        {"move_to": {"x": 72, "y": 131.8}},
        {"curve_to": {"x1": 134.16, "y1": 166.467, "x2": 209.84, "y2": 166.467, "x": 272, "y": 131.8}}
      ],
      "stroke": {"width": 1.6, "color": [0.16, 0.33, 0.62]}
    },

    {
      "type": "text",
      "rect": {"llx": 284, "lly": 183.6, "urx": 360, "ury": 193.8},
      "content": ["Radii enlarged"],
      "font": "DejaVuSans",
      "font_size": 8.5
    },

    {
      "type": "path",
      "segments": [
        {"move_to": {"x": 284, "y": 131.8}},
        {"elliptical_arc": {"from": {"x": 284, "y": 131.8}, "to": {"x": 344, "y": 131.8}, "rx": 6, "ry": 3, "clockwise": true, "enlarge_radii": true}}
      ],
      "stroke": {"width": 1.6, "color": [0.16, 0.33, 0.62]}
    },

    {
      "type": "text",
      "rect": {"llx": 372, "lly": 183.6, "urx": 592, "ury": 193.8},
      "content": ["Four arcs, between the same two points"],
      "font": "DejaVuSans",
      "font_size": 8.5
    },

    {
      "type": "path",
      "segments": [
        {"move_to": {"x": 372, "y": 131.8}},
        {"curve_to": {"x1": 392.247, "y1": 123.783, "x2": 431.046, "y2": 122.049, "x": 458.661, "y": 127.927}},
        {"curve_to": {"x1": 463.761, "y1": 129.013, "x2": 468.26, "y2": 130.319, "x": 472, "y": 131.8}}
      ],
      "stroke": {"width": 1.6, "color": [0.16, 0.33, 0.62]}
    },

    {
      "type": "path",
      "segments": [
        {"move_to": {"x": 372, "y": 131.8}},
        {"curve_to": {"x1": 392.247, "y1": 139.817, "x2": 431.046, "y2": 141.551, "x": 458.661, "y": 135.673}},
        {"curve_to": {"x1": 463.761, "y1": 134.587, "x2": 468.26, "y2": 133.281, "x": 472, "y": 131.8}}
      ],
      "stroke": {"width": 1.6, "color": [0.3, 0.57, 0.75]}
    },

    {
      "type": "path",
      "segments": [
        {"move_to": {"x": 372, "y": 131.8}},
        {"curve_to": {"x1": 351.753, "y1": 123.783, "x2": 357.725, "y2": 112.519, "x": 385.339, "y": 106.64}},
        {"curve_to": {"x1": 412.954, "y1": 100.762, "x2": 451.753, "y2": 102.496, "x": 472, "y": 110.513}},
        {"curve_to": {"x1": 488, "y1": 116.849, "x2": 488, "y2": 125.465, "x": 472, "y": 131.8}}
      ],
      "stroke": {"width": 1.6, "color": [0.55, 0.73, 0.82]}
    },

    {
      "type": "path",
      "segments": [
        {"move_to": {"x": 372, "y": 131.8}},
        {"curve_to": {"x1": 351.753, "y1": 139.817, "x2": 357.725, "y2": 151.081, "x": 385.339, "y": 156.96}},
        {"curve_to": {"x1": 412.954, "y1": 162.838, "x2": 451.753, "y2": 161.104, "x": 472, "y": 153.087}},
        {"curve_to": {"x1": 488, "y1": 146.751, "x2": 488, "y2": 138.135, "x": 472, "y": 131.8}}
      ],
      "stroke": {"width": 1.6, "color": [0.79, 0.86, 0.9]}
    },

    {
      "type": "text",
      "rect": {"llx": 72, "lly": 57.2, "urx": 523, "ury": 87.8},
      "content": ["A curve costs six numbers and a straight segment costs two, so a circle is five lines of a page rather than one. What it does not cost is a picture: the shapes here are drawn by reading software at whatever size the page is shown, and they stay sharp at any of them."],
      "font": "DejaVuSans",
      "font_size": 8.5
    }
  ]
}