Skip to content
Draft
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
1 change: 1 addition & 0 deletions formulus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"prebuild": "pnpm run sync:version && pnpm run generate"
},
"dependencies": {
"@maplibre/maplibre-react-native": "11.5.1",
"@notifee/react-native": "^9.1.8",
"@nozbe/simdjson": "3.9.4",
"@nozbe/sqlite": "3.46.0",
Expand Down
140 changes: 140 additions & 0 deletions formulus/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 61 additions & 0 deletions formulus/scripts/generate-map-cluster-badges.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
"""
Regenerates the cluster count badges used by the Observations map
(src/assets/map/cluster-*.png). Counts are images, not map text, so they
render offline without map fonts. Requires Pillow >= 10.1.

python scripts/generate-map-cluster-badges.py
"""

from pathlib import Path

from PIL import Image, ImageDraw, ImageFont

from_root = Path(__file__).resolve().parent.parent
OUT = from_root / "src" / "assets" / "map"
SCALE = 3
FONT_PX = 13 * SCALE
STROKE_PX = 1 * SCALE

LABELS = {str(n): str(n) for n in range(2, 10)}
LABELS.update(
{
"10p": "10+",
"20p": "20+",
"50p": "50+",
"100p": "100+",
"200p": "200+",
"500p": "500+",
"1kp": "1k+",
"2kp": "2k+",
"5kp": "5k+",
"10kp": "10k+",
}
)


def main():
OUT.mkdir(parents=True, exist_ok=True)
font = ImageFont.load_default(size=FONT_PX)
for key, text in LABELS.items():
left, top, right, bottom = font.getbbox(text, stroke_width=STROKE_PX)
pad = STROKE_PX
image = Image.new("RGBA", (right - left + pad * 2, bottom - top + pad * 2), (0, 0, 0, 0))
ImageDraw.Draw(image).text(
(pad - left, pad - top),
text,
font=font,
fill=(255, 255, 255, 255),
stroke_width=STROKE_PX,
stroke_fill=(0, 0, 0, 110),
)
image.save(OUT / f"cluster-{key}@3x.png", optimize=True)
base = image.resize(
(max(1, image.width // SCALE), max(1, image.height // SCALE)),
Image.LANCZOS,
)
base.save(OUT / f"cluster-{key}.png", optimize=True)
print(f"Wrote {len(LABELS)} badges to {OUT}")


if __name__ == "__main__":
main()
Binary file added formulus/src/assets/map/cluster-100p.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added formulus/src/assets/map/cluster-100p@3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added formulus/src/assets/map/cluster-10kp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added formulus/src/assets/map/cluster-10kp@3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added formulus/src/assets/map/cluster-10p.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added formulus/src/assets/map/cluster-10p@3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added formulus/src/assets/map/cluster-1kp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added formulus/src/assets/map/cluster-1kp@3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added formulus/src/assets/map/cluster-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added formulus/src/assets/map/cluster-200p.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added formulus/src/assets/map/cluster-200p@3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added formulus/src/assets/map/cluster-20p.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added formulus/src/assets/map/cluster-20p@3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added formulus/src/assets/map/cluster-2@3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added formulus/src/assets/map/cluster-2kp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added formulus/src/assets/map/cluster-2kp@3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added formulus/src/assets/map/cluster-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added formulus/src/assets/map/cluster-3@3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added formulus/src/assets/map/cluster-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added formulus/src/assets/map/cluster-4@3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added formulus/src/assets/map/cluster-5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added formulus/src/assets/map/cluster-500p.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added formulus/src/assets/map/cluster-500p@3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added formulus/src/assets/map/cluster-50p.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added formulus/src/assets/map/cluster-50p@3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added formulus/src/assets/map/cluster-5@3x.png
Binary file added formulus/src/assets/map/cluster-5kp.png
Binary file added formulus/src/assets/map/cluster-5kp@3x.png
Binary file added formulus/src/assets/map/cluster-6.png
Binary file added formulus/src/assets/map/cluster-6@3x.png
Binary file added formulus/src/assets/map/cluster-7.png
Binary file added formulus/src/assets/map/cluster-7@3x.png
Binary file added formulus/src/assets/map/cluster-8.png
Binary file added formulus/src/assets/map/cluster-8@3x.png
Binary file added formulus/src/assets/map/cluster-9.png
Binary file added formulus/src/assets/map/cluster-9@3x.png
Loading
Loading