Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified assets/images/doors/area-community.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/doors/area-education.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/doors/area-research.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/js/castle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The animated brick tower in the home page's arched door. Hugo bundles it with `j
| `castle-geometry.js` | The bricks |
| `castle-piles.js` | Baked resting poses of the two heaps. Generated, see below |
| `bake-castle-piles.js` | Offline physics bake for those poses. Never part of the site's bundle |
| `illustrations-render.js` | Offline renderer for the four area illustrations. Never part of the site's bundle |
| `illustrations-render.js`, `illustrations-harness.html` | Offline renderer for the education, research and community area plates; `scripts/rebrand/render_area_illustrations.py` renders them. Never part of the site's bundle |
| `../doors/castle.js` | Loads the bundle after paint and owns playback: pause, hover, tap, off-screen suspension. Also opens the tower game, see `../tower/README.md` |
| `../doors/motion.js` | The pause state the castle shares with the home page's quotes, remembered between visits |

Expand Down
5 changes: 5 additions & 0 deletions assets/js/castle/illustrations-harness.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!doctype html>
<html lang="en"><meta charset="utf-8"><title>FORRT area plates</title>
<style>html,body{margin:0;background:transparent}canvas{display:block}</style>
<script type="importmap">{"imports":{"three":"/three/index.js","three/addons/":"/three/addons/"}}</script>
<canvas></canvas><script type="module" src="illustrations-render.js"></script></html>
358 changes: 258 additions & 100 deletions assets/js/castle/illustrations-render.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions content/home/2-areas.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ weight = 20
title = "Education & Pedagogy"
blurb = "Find, access and reuse teaching and mentoring materials."
image = "area-education"
alt = "A brick pencil standing on an open green book."
alt = "Two green brick towers joined by an arch rising from an open book."
links = [
{ url = "resources/" },
{ url = "lesson-plans/" },
Expand All @@ -22,7 +22,7 @@ weight = 20
title = "Meta-Science & Research"
blurb = "Track, explore, conduct and share reproduction and replication studies."
image = "area-research"
alt = "Two near-identical brick towers, one with a single orange brick, seen through a magnifying glass."
alt = "An open notebook whose two pages show the same bar chart built from bricks."
links = [
{ url = "replication-hub/" },
{ url = "https://forrt.org/flora-replication-atlas/" },
Expand Down Expand Up @@ -50,7 +50,7 @@ weight = 20
title = "Community & Sustainability"
blurb = "From a culture of competition to one of community."
image = "area-community"
alt = "Brick figures in many colours standing in a circle, with a gap and one more figure arriving."
alt = "Three brick figures working together at a table, with an empty stool for one more."
links = [
{ url = "about/teams/" },
{ url = "contributors/" },
Expand Down
6 changes: 3 additions & 3 deletions content/welcome/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ areas:
- key: edu
title: "Education & Pedagogy"
image: area-education
alt: "A brick pencil standing on an open green book."
alt: "Two green brick towers joined by an arch rising from an open book."
links:
- title: "Educational Nexus"
text: "FORRT's teaching projects and resources in one place."
Expand All @@ -37,7 +37,7 @@ areas:
- key: res
title: "Meta-Science & Research"
image: area-research
alt: "Two near-identical brick towers, one with a single orange brick, seen through a magnifying glass."
alt: "An open notebook whose two pages show the same bar chart built from bricks."
links:
- title: "Replication Hub"
text: "Tools and guidance for reproduction and replication studies."
Expand All @@ -59,7 +59,7 @@ areas:
- key: com
title: "Community & Sustainability"
image: area-community
alt: "Brick figures in many colours standing in a circle, with a gap and one more figure arriving."
alt: "Three brick figures working together at a table, with an empty stool for one more."
links:
- title: "Teams"
text: "Find a team or project to join."
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/doors/topic_resources.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ <h2 id="topic-now-title" class="visually-hidden">These resources by current clus
{{ end }}
</ol>
</section>
<figure class="heading-plate topic-plate"><img src="{{ $plate.RelPermalink }}" alt="A brick pencil standing on an open green book." width="{{ $plate.Width }}" height="{{ $plate.Height }}"></figure>
<figure class="heading-plate topic-plate"><img src="{{ $plate.RelPermalink }}" alt="Two green brick towers joined by an arch rising from an open book." width="{{ $plate.Width }}" height="{{ $plate.Height }}"></figure>
</div>
<div class="topic-toolbar">
<div class="list-filter topic-tools" data-noun="resources" data-list="#now-{{ (index $groups 0).key }}" data-no-jump hidden>
Expand Down
2 changes: 1 addition & 1 deletion layouts/resources/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ <h2 id="res-start-h">Ready to teach with</h2>
</ul>
</nav>
</div>
<figure class="heading-plate res-plate"><img src="{{ $plate.RelPermalink }}" alt="A brick pencil standing on an open green book." width="{{ $plate.Width }}" height="{{ $plate.Height }}"></figure>
<figure class="heading-plate res-plate"><img src="{{ $plate.RelPermalink }}" alt="Two green brick towers joined by an arch rising from an open book." width="{{ $plate.Width }}" height="{{ $plate.Height }}"></figure>
</div>
</header>

Expand Down
63 changes: 63 additions & 0 deletions scripts/rebrand/render_area_illustrations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/env python3
"""Render the education, research and community area plates (assets/images/doors/area-*.webp).

python3 scripts/rebrand/render_area_illustrations.py

Loads assets/js/castle/illustrations-render.js in headless Chromium through
assets/js/castle/illustrations-harness.html, with Three.js served from assets/three/. Each plate
is trimmed to the model and its shadow and set 640 px wide. At that size their bricks match the
justice plate's, which comes from the castle (assets/js/castle/README.md) and is not rendered here.

Needs Pillow and Playwright for Python with its Chromium (`python3 -m playwright install chromium`).
"""
import base64
import io
import mimetypes
from pathlib import Path
from urllib.parse import urlsplit

from PIL import Image
from playwright.sync_api import sync_playwright

ROOT = Path(__file__).resolve().parents[2]
CASTLE = ROOT / "assets/js/castle"
# kind in illustrations-render.js: area plate
PLATES = {"popup": "education", "notebook": "research", "table": "community"}


def main():
with sync_playwright() as playwright:
browser = playwright.chromium.launch(args=["--use-angle=swiftshader", "--enable-unsafe-swiftshader"])
context = browser.new_context(viewport={"width": 1200, "height": 800})

def serve(route):
path = urlsplit(route.request.url).path.lstrip("/")
if path in ("illustrations-harness.html", "illustrations-render.js"):
source = CASTLE / path
elif path.startswith("three/") and ".." not in path:
source = ROOT / "assets" / path
else:
return route.abort()
route.fulfill(body=source.read_bytes(), content_type=mimetypes.guess_type(source)[0])

context.route("**/*", serve)
for kind, area in PLATES.items():
page = context.new_page()
page.on("pageerror", lambda error, kind=kind: print(f"{kind}: {error}", flush=True))
page.on("console", lambda msg, kind=kind: msg.type == "error" and print(f"{kind}: {msg.text}", flush=True))
page.goto(f"http://plates.invalid/illustrations-harness.html?kind={kind}")
page.wait_for_function("window.renderReady", timeout=90000)
raw, size = page.eval_on_selector("canvas", "c => [c.toDataURL('image/png').split(',')[1], [c.clientWidth, c.clientHeight]]")
page.close()
# Back from the renderer's pixel ratio to its CSS size, then trim with a 5 px margin.
plate = Image.open(io.BytesIO(base64.b64decode(raw))).convert("RGBA").resize(tuple(size), Image.LANCZOS)
x0, y0, x1, y1 = plate.getchannel("A").point(lambda a: 255 if a > 4 else 0).getbbox()
plate = plate.crop((max(0, x0 - 5), max(0, y0 - 5), min(plate.width, x1 + 5), min(plate.height, y1 + 5)))
plate = plate.resize((640, round(640 * plate.height / plate.width)), Image.LANCZOS)
plate.save(ROOT / f"assets/images/doors/area-{area}.webp", quality=88, method=6)
print(f"area-{area}.webp from {kind}: {plate.width} × {plate.height}")
browser.close()


if __name__ == "__main__":
main()
Loading