Git hosting and a container registry in one Rust binary (axum + Astro)
| 1 | #!/usr/bin/env python3 |
| 2 | """Builds the irongit icons from the logo in brand/. |
| 3 | |
| 4 | brand/logo-source.png is used as is when it already has a transparent |
| 5 | background; near-opaque pixels are snapped to fully opaque so the mark never |
| 6 | lets a background tint through. A source on a flat green screen (PNG without |
| 7 | alpha, or brand/logo-source.jpg) is keyed instead: the green is removed by how |
| 8 | green each pixel is, and edge pixels are unmixed (P = a*F + (1-a)*G solved for |
| 9 | a and F) so outlines keep their real colour instead of a green fringe. |
| 10 | |
| 11 | Output goes to frontend/public: |
| 12 | |
| 13 | logo.png 512 px, transparent, for pages and Open Graph |
| 14 | logo-128.png the nav and auth pages (crisp up to 3x at ~40 px) |
| 15 | icon-192.png web app manifest sizes |
| 16 | apple-touch-icon.png 180 px on the site's dark surface (iOS ignores alpha) |
| 17 | favicon.ico 16, 32 and 48 px |
| 18 | favicon-32.png modern browsers |
| 19 | |
| 20 | python3 -I scripts/gen-brand.py |
| 21 | """ |
| 22 | |
| 23 | |
| 24 | |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | = .. |
| 30 | = / |
| 31 | = / / |
| 32 | = # --color-surface, dark theme |
| 33 | |
| 34 | |
| 35 | |
| 36 | = |
| 37 | , , = , , |
| 38 | |
| 39 | # Background colour from the corners, which are always background here. |
| 40 | = 60 |
| 41 | = |
| 42 | = |
| 43 | = - |
| 44 | |
| 45 | # Greenness: 0 for the neutral greys of the vault, bg_green for background. |
| 46 | = - |
| 47 | , = 0.12 * , 0.88 * |
| 48 | = |
| 49 | |
| 50 | # Unmix the background out of partially covered pixels. |
| 51 | = |
| 52 | = |
| 53 | = |
| 54 | # The artwork is neutral greys and gold (red above green); remove any green |
| 55 | # spill left in the edge colours. |
| 56 | = + 3 |
| 57 | = |
| 58 | |
| 59 | = |
| 60 | |
| 61 | return |
| 62 | |
| 63 | |
| 64 | |
| 65 | = |
| 66 | = |
| 67 | # Background removers leave the body at 250-254; make it solid. |
| 68 | = 255 |
| 69 | = |
| 70 | = 0 |
| 71 | |
| 72 | return |
| 73 | |
| 74 | |
| 75 | |
| 76 | """Crops to the ink and squares it up with transparent padding.""" |
| 77 | = / 255.0 |
| 78 | , = |
| 79 | , , , = , + 1, , + 1 |
| 80 | = |
| 81 | = |
| 82 | = |
| 83 | = |
| 84 | |
| 85 | |
| 86 | return |
| 87 | |
| 88 | |
| 89 | |
| 90 | """Caps green at the larger of red and blue. Neutral greys and gold |
| 91 | (red above green) are untouched; only spill and resampling tint goes.""" |
| 92 | = |
| 93 | = + 3 |
| 94 | = |
| 95 | return |
| 96 | |
| 97 | |
| 98 | |
| 99 | # Lanczos overshoots on the faint edge pixels beside the gold rims and |
| 100 | # tints them olive, so the spill cap runs again after every resize. |
| 101 | return |
| 102 | |
| 103 | |
| 104 | |
| 105 | , = / , / |
| 106 | |
| 107 | = |
| 108 | |
| 109 | return |
| 110 | return |
| 111 | return |
| 112 | |
| 113 | |
| 114 | |
| 115 | = |
| 116 | |
| 117 | |
| 118 | |
| 119 | |
| 120 | |
| 121 | |
| 122 | = |
| 123 | = |
| 124 | |
| 125 | |
| 126 | |
| 127 | # Each favicon size is resized (and despilled) here rather than by the ICO writer. |
| 128 | = |
| 129 | |
| 130 | |
| 131 | |
| 132 | return 0 |
| 133 | |
| 134 | |
| 135 | |
| 136 |