Content shown and hidden by layer

One floor plan on four layers you can show and hide: the furniture and the dimensions shown, the notes hidden until asked for, and a draft mark that is there to be looked at and never printed.

JSON write_layers.json 214 lines

This one is not a program. It is the request the document server is sent: the same page, asked for over the network by an application that writes no PDF code at all.

The library writes each line of the page at a stated height; a request gives a block of words a rectangle instead, so every line's rectangle here is worked back from that height. Nine of them reach past the plan they sit under, harmlessly, because the library writes those lines without breaking them and a block of words would break them at the edge of its rectangle. The walls are one colour set once on the library's side, an outer wall and then a partition; on the wire they are two things, each stating that colour for itself, and each piece of furniture is filled and then outlined as two shapes there and drawn once and painted in one go here. The four layers themselves, what each of them holds, and the draft mark a reader may not decide to print are the same either way, down to the order the panel lists them in.

  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
{
  "layers": [
    { "name": "Furniture" },
    { "name": "Dimensions" },
    { "name": "Notes", "visible": false },
    { "name": "Draft", "on_screen": true, "printed": false }
  ],
  "items": [
    {
      "type": "text",
      "rect": { "llx": 80.0, "lly": 750.0, "urx": 560.0, "ury": 768.0 },
      "content": ["One plan, four layers"],
      "font": "DejaVuSans",
      "font_size": 15.0
    },
    {
      "type": "text",
      "rect": { "llx": 80.0, "lly": 730.0, "urx": 590.0, "ury": 742.0 },
      "content": [
        "The walls are always there. Everything else is a layer the reader can show and hide."
      ],
      "font": "DejaVuSans",
      "font_size": 10.0,
      "color": [0.35, 0.35, 0.35]
    },

    {
      "type": "rect",
      "rect": { "llx": 80.0, "lly": 380.0, "urx": 515.0, "ury": 700.0 },
      "stroke": { "width": 3.0, "color": [0.15, 0.15, 0.15] }
    },
    {
      "type": "line",
      "from": { "x": 345.0, "y": 380.0 },
      "to": { "x": 345.0, "y": 570.0 },
      "stroke": { "width": 3.0, "color": [0.15, 0.15, 0.15] }
    },

    {
      "type": "rect",
      "rect": { "llx": 120.0, "lly": 590.0, "urx": 240.0, "ury": 660.0 },
      "fill": [0.85, 0.88, 0.93],
      "stroke": { "width": 1.0, "color": [0.35, 0.45, 0.6] },
      "layer": "Furniture"
    },
    {
      "type": "rect",
      "rect": { "llx": 380.0, "lly": 570.0, "urx": 470.0, "ury": 680.0 },
      "fill": [0.85, 0.88, 0.93],
      "stroke": { "width": 1.0, "color": [0.35, 0.45, 0.6] },
      "layer": "Furniture"
    },
    {
      "type": "rect",
      "rect": { "llx": 370.0, "lly": 410.0, "urx": 480.0, "ury": 450.0 },
      "fill": [0.85, 0.88, 0.93],
      "stroke": { "width": 1.0, "color": [0.35, 0.45, 0.6] },
      "layer": "Furniture"
    },

    {
      "type": "path",
      "segments": [
        { "move_to": { "x": 80.0, "y": 354.0 } },
        { "line_to": { "x": 515.0, "y": 354.0 } },
        { "move_to": { "x": 80.0, "y": 349.0 } },
        { "line_to": { "x": 80.0, "y": 359.0 } },
        { "move_to": { "x": 515.0, "y": 349.0 } },
        { "line_to": { "x": 515.0, "y": 359.0 } },
        { "move_to": { "x": 34.0, "y": 380.0 } },
        { "line_to": { "x": 34.0, "y": 700.0 } },
        { "move_to": { "x": 29.0, "y": 380.0 } },
        { "line_to": { "x": 39.0, "y": 380.0 } },
        { "move_to": { "x": 29.0, "y": 700.0 } },
        { "line_to": { "x": 39.0, "y": 700.0 } }
      ],
      "stroke": { "width": 0.8, "color": [0.2, 0.5, 0.35] },
      "layer": "Dimensions"
    },
    {
      "type": "text",
      "rect": { "llx": 279.5, "lly": 362.0, "urx": 360.0, "ury": 372.8 },
      "content": ["7.25 m"],
      "font": "DejaVuSans",
      "font_size": 9.0,
      "color": [0.2, 0.5, 0.35],
      "layer": "Dimensions"
    },
    {
      "type": "text",
      "rect": { "llx": 40.0, "lly": 540.0, "urx": 120.0, "ury": 550.8 },
      "content": ["5.00 m"],
      "font": "DejaVuSans",
      "font_size": 9.0,
      "color": [0.2, 0.5, 0.35],
      "layer": "Dimensions"
    },

    {
      "type": "text",
      "rect": { "llx": 124.0, "lly": 570.0, "urx": 340.0, "ury": 579.6 },
      "content": ["Table seats six."],
      "font": "DejaVuSans",
      "font_size": 8.0,
      "color": [0.7, 0.25, 0.1],
      "layer": "Notes"
    },
    {
      "type": "text",
      "rect": { "llx": 372.0, "lly": 552.0, "urx": 590.0, "ury": 561.6 },
      "content": ["Bed against the party wall."],
      "font": "DejaVuSans",
      "font_size": 8.0,
      "color": [0.7, 0.25, 0.1],
      "layer": "Notes"
    },
    {
      "type": "text",
      "rect": { "llx": 372.0, "lly": 396.0, "urx": 590.0, "ury": 405.6 },
      "content": ["Counter, waste under."],
      "font": "DejaVuSans",
      "font_size": 8.0,
      "color": [0.7, 0.25, 0.1],
      "layer": "Notes"
    },

    {
      "type": "stamp",
      "rect": { "llx": 80.0, "lly": 380.0, "urx": 515.0, "ury": 700.0 },
      "content": "DRAFT",
      "font": "DejaVuSans",
      "slant": "up",
      "color": [0.8, 0.3, 0.3],
      "layer": "Draft"
    },

    {
      "type": "text",
      "rect": { "llx": 80.0, "lly": 300.0, "urx": 165.0, "ury": 312.0 },
      "content": ["Furniture"],
      "font": "DejaVuSans",
      "font_size": 10.0
    },
    {
      "type": "text",
      "rect": { "llx": 170.0, "lly": 300.0, "urx": 590.0, "ury": 312.0 },
      "content": ["shown; turn it off and the rooms stand empty"],
      "font": "DejaVuSans",
      "font_size": 10.0,
      "color": [0.35, 0.35, 0.35]
    },
    {
      "type": "text",
      "rect": { "llx": 80.0, "lly": 282.0, "urx": 165.0, "ury": 294.0 },
      "content": ["Dimensions"],
      "font": "DejaVuSans",
      "font_size": 10.0
    },
    {
      "type": "text",
      "rect": { "llx": 170.0, "lly": 282.0, "urx": 590.0, "ury": 294.0 },
      "content": ["shown; the distances around the plan"],
      "font": "DejaVuSans",
      "font_size": 10.0,
      "color": [0.35, 0.35, 0.35]
    },
    {
      "type": "text",
      "rect": { "llx": 80.0, "lly": 264.0, "urx": 165.0, "ury": 276.0 },
      "content": ["Notes"],
      "font": "DejaVuSans",
      "font_size": 10.0
    },
    {
      "type": "text",
      "rect": { "llx": 170.0, "lly": 264.0, "urx": 590.0, "ury": 276.0 },
      "content": ["hidden; turn it on to read them"],
      "font": "DejaVuSans",
      "font_size": 10.0,
      "color": [0.35, 0.35, 0.35]
    },
    {
      "type": "text",
      "rect": { "llx": 80.0, "lly": 246.0, "urx": 165.0, "ury": 258.0 },
      "content": ["Draft"],
      "font": "DejaVuSans",
      "font_size": 10.0
    },
    {
      "type": "text",
      "rect": { "llx": 170.0, "lly": 246.0, "urx": 590.0, "ury": 258.0 },
      "content": ["shown on screen, never printed"],
      "font": "DejaVuSans",
      "font_size": 10.0,
      "color": [0.35, 0.35, 0.35]
    },
    {
      "type": "text",
      "rect": { "llx": 80.0, "lly": 216.0, "urx": 590.0, "ury": 228.0 },
      "content": ["The draft mark carries its own answer for the printer, so nothing has to"],
      "font": "DejaVuSans",
      "font_size": 10.0,
      "color": [0.35, 0.35, 0.35]
    },
    {
      "type": "text",
      "rect": { "llx": 80.0, "lly": 202.0, "urx": 590.0, "ury": 214.0 },
      "content": ["be switched off before the page is printed."],
      "font": "DejaVuSans",
      "font_size": 10.0,
      "color": [0.35, 0.35, 0.35]
    }
  ]
}