File size: 5,581 Bytes
eb1a751
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# -*- coding: utf-8 -*-
# hensmith: Heat Exchanger Network Synthesis, Modeling, Integration,
# Thermodynamics, and Heuristics
# Copyright (C) 2020-, Sarang Bhagwat <sarangbhagwat.developer@gmail.com>
#
# This module is under the UIUC open-source license. See
# github.com/BioSTEAMDevelopmentGroup/hensmith/blob/master/LICENSE.txt
# for license details.
"""Compose the README quickstart-demo poster from real repo assets.

Writes ``docs/source/_static/images/examples/quickstart_demo_poster.png`` --
a branded, clickable still (logo, title, step sequence, a play badge, and
the real quickstart pinch diagram in a white card) that the README links to
the interactive demo. It is laid out on a 1200 x 630 canvas (the usual
social-card size) and rendered at dpi 200, i.e. 2400 x 1260 px.

Inputs (both generated by other scripts in this directory):

- ``_static/images/logo/logo_hensmith.png``
- ``_static/images/examples/tutorial_01_quickstart_pinch_diagram.png``

Run with the IBO_2026 interpreter, from the repo root::

    python docs/_demo_src/make_poster.py
"""
from _common import IMAGES, report      # sets the Agg backend before pyplot
import matplotlib.pyplot as plt
from matplotlib.patches import FancyBboxPatch, Polygon
from PIL import Image

OUT = IMAGES / 'examples' / 'quickstart_demo_poster.png'
LOGO = IMAGES / 'logo' / 'logo_hensmith.png'
PINCH = IMAGES / 'examples' / 'tutorial_01_quickstart_pinch_diagram.png'

# brand tokens (docs dark theme; see _common.THEMES['dark'])
BG      = '#14181e'   # page background, dark theme
INK     = '#e8eef0'
MUTED   = '#98a3b3'
ACCENT  = '#5b9be0'   # cold-stream blue, dark variant (reads on dark)
ACCENTD = '#2e6db4'   # cold-stream blue, light variant (the pill)
SCREEN  = '#ffffff'

W, H = 1200.0, 630.0  # canvas in "layout px" (1 px = 1/100 in); dpi 200 doubles it
DPI = 200

# The right-hand card is 500 px wide and as tall as the pinch diagram's aspect
# demands; that is short for this wide figure, so the card is centred on the
# canvas and the left column is laid out around the same vertical centre.
CARD_X, CARD_W, CARD_PAD = 650.0, 500.0, 16.0
LEFT = 70.0            # left column x
SEAM = 636.0           # hairline between the two columns


def make():
    pinch = plt.imread(str(PINCH))
    logo = plt.imread(str(LOGO))

    card_h = CARD_W * pinch.shape[0] / pinch.shape[1]
    card_y = (H - card_h) / 2
    img_w = CARD_W - 2 * CARD_PAD
    img_h = img_w * pinch.shape[0] / pinch.shape[1]
    img_x = CARD_X + CARD_PAD
    img_y = card_y + (card_h - img_h) / 2

    fig = plt.figure(figsize=(W / 100, H / 100), dpi=DPI)
    fig.patch.set_facecolor(BG)
    ax = fig.add_axes([0, 0, 1, 1])
    ax.set_xlim(0, W); ax.set_ylim(0, H); ax.axis('off')

    # faint accent hairline down the seam
    ax.plot([SEAM, SEAM], [110, 520], color=ACCENTD, lw=1.2, alpha=0.28,
            solid_capstyle='round')

    # right: the real quickstart pinch diagram in a white "screen" card
    ax.add_patch(FancyBboxPatch((CARD_X + 6, card_y - 8), CARD_W, card_h,
                 boxstyle='round,pad=0,rounding_size=18', linewidth=0,
                 facecolor='#000000', alpha=0.28, zorder=1))          # shadow
    ax.add_patch(FancyBboxPatch((CARD_X, card_y), CARD_W, card_h,
                 boxstyle='round,pad=0,rounding_size=18', linewidth=0,
                 facecolor=SCREEN, zorder=2))                         # card
    ax_img = fig.add_axes([img_x / W, img_y / H, img_w / W, img_h / H])
    ax_img.axis('off'); ax_img.set_facecolor(SCREEN)
    ax_img.imshow(pinch, aspect='equal', zorder=3)

    # left: logo, top of the column
    logo_h = 58.0
    logo_w = logo_h * logo.shape[1] / logo.shape[0]
    logo_top = 520.0
    ax_logo = fig.add_axes([LEFT / W, (logo_top - logo_h) / H, logo_w / W, logo_h / H])
    ax_logo.axis('off'); ax_logo.imshow(logo, zorder=3)

    # title (serif, echoing the demo page)
    ax.text(LEFT, 415, 'Heat integration,', fontsize=36, fontweight='bold',
            family='serif', color=INK, va='baseline')
    ax.text(LEFT, 367, 'end to end.', fontsize=36, fontweight='bold',
            family='serif', color=INK, va='baseline')

    # subtitle
    ax.text(LEFT, 306, 'One facility synthesizes the heat exchanger',
            fontsize=16.5, color=MUTED, va='baseline')
    ax.text(LEFT, 280, 'network of any BioSTEAM system.',
            fontsize=16.5, color=MUTED, va='baseline')

    # step sequence
    x = LEFT
    steps = ['Build', 'Simulate', 'Savings', 'Pinch diagram']
    for i, s in enumerate(steps):
        ax.text(x, 214, s, fontsize=13, color=ACCENT, va='baseline',
                family='monospace')
        x += 11 * len(s) + 10
        if i < len(steps) - 1:
            ax.text(x, 214, '·', fontsize=15, color=MUTED, va='baseline',
                    family='monospace')
            x += 22

    # play badge pill
    pill_y = 110.0
    ax.add_patch(FancyBboxPatch((LEFT, pill_y), 415, 50,
                 boxstyle='round,pad=0,rounding_size=25', linewidth=0,
                 facecolor=ACCENTD, zorder=3))
    ax.add_patch(Polygon([[LEFT + 30, pill_y + 13], [LEFT + 30, pill_y + 37],
                          [LEFT + 51, pill_y + 25]], closed=True,
                 facecolor='white', zorder=4))
    ax.text(LEFT + 68, pill_y + 25, 'Watch the demo  ·  ~1 min', fontsize=15.5,
            fontweight='bold', color='white', va='center', zorder=4)

    fig.savefig(str(OUT), facecolor=BG, dpi=DPI)
    plt.close(fig)

    with Image.open(OUT) as im:
        assert im.size == (2400, 1260), im.size
    return OUT


if __name__ == '__main__':
    report(make())