@skvggor/pharos 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Marcos Lima
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,160 @@
1
+ # Pharos
2
+
3
+ A pixel "display" font for React: each character is a glyph drawn on a
4
+ `12×18` grid and rendered as a field of squares. Serif glyphs, with vertical
5
+ zones for accents, ascenders, x-height and descenders.
6
+
7
+ <p align="center">
8
+ <img
9
+ src="docs/showcase.png"
10
+ alt="Pharos demo shown in a desktop browser and a phone: the name skvggor rendered in the serif pixel font beside a glowing red display"
11
+ width="720"
12
+ />
13
+ </p>
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ npm install @skvggor/pharos
19
+ ```
20
+
21
+ ## Usage
22
+
23
+ ```tsx
24
+ import { PixelText } from "@skvggor/pharos";
25
+ import "@skvggor/pharos/styles.css";
26
+
27
+ export function App() {
28
+ return <PixelText text="HELLO" pixelSize={14} gap={2} color="#16a34a" />;
29
+ }
30
+ ```
31
+
32
+ ## `PixelText` props
33
+
34
+ | Prop | Type | Default | Description |
35
+ | -------------------- | ------------------ | -------------- | --------------------------------------------------------------------- |
36
+ | `text` | `string` | — | Text to render (required). |
37
+ | `pixelSize` | `number \| string` | `6px` | Size of each pixel cell. |
38
+ | `gap` | `number \| string` | `1px` | Gap between pixels. |
39
+ | `letterSpacing` | `number \| string` | `0.5` cell | Gap between characters (accepts negative values to tighten). |
40
+ | `color` | `string` | `currentColor` | Lit pixel color. |
41
+ | `offColor` | `string` | `transparent` | Unlit pixel color. |
42
+ | `pixelShape` | `PixelShape` | `dot` | Pixel shape: `dot`, `squircle`, `diamond`, `ring`, `square`. |
43
+ | `smartCorners` | `boolean` | `false` | Round outer corners by neighbour analysis (`square`/`squircle` only). |
44
+ | `smoothness` | `number` | `0.6` | Rounding strength (`0` retro → `1` organic). |
45
+ | `proportional` | `boolean` | `true` | Trim per-glyph side-bearing (tight kerning). `false` = monospace. |
46
+ | `spaceWidth` | `number` | `4` | Space character width, in cells. |
47
+ | `renderOff` | `boolean` | `true` | Render unlit cells too (needed to animate them); `false` = lighter DOM. |
48
+ | `fluid` | `boolean` | `false` | Width follows the parent; height keeps the aspect ratio. |
49
+ | `gapRatio` | `number` | `0.16` | Pixel gap as a fraction of the pixel (fluid mode). |
50
+ | `letterSpacingRatio` | `number` | `0.5` | Letter gap as a fraction of the pixel (fluid mode). |
51
+
52
+ ## Kerning
53
+
54
+ By default (`proportional`), each glyph is trimmed of its empty side columns
55
+ and rendered at its real ink width, with a small, even gap between letters —
56
+ instead of the wide, uneven spacing of a monospace canvas. The gap is
57
+ adjustable through `letterSpacing` (and `letterSpacingRatio` in fluid mode),
58
+ including negative values to overlap letters. Use `proportional={false}` for a
59
+ classic monospace display look.
60
+
61
+ ## Fluid width
62
+
63
+ In `fluid` mode the component becomes a *container query context*
64
+ (`container-type: inline-size`) with `width: 100%`, and the pixel size becomes
65
+ `calc(100cqw / units)`. Because gaps and spacing are fractions of the pixel,
66
+ **everything scales together** — the width fills the parent and the height
67
+ follows to keep the aspect ratio, with no runtime measurement.
68
+
69
+ ```tsx
70
+ <div style={{ width: "100%" }}>
71
+ <PixelText text="HELLO" fluid color="#fbbf24" />
72
+ </div>
73
+ ```
74
+
75
+ ## Per-pixel animation
76
+
77
+ Every pixel (lit and unlit) is rendered as a DOM element. Each lit pixel
78
+ exposes CSS variables so it can be animated individually:
79
+
80
+ - `--ph-i`: sequential index of the lit pixel across the whole text.
81
+ - `--ph-n`: total number of lit pixels.
82
+ - `--ph-row` / `--ph-col`: pixel position within the character matrix.
83
+
84
+ Sweep example:
85
+
86
+ ```css
87
+ .my-class .pharos__pixel--on {
88
+ animation: light-up 1.6s ease-in-out infinite alternate;
89
+ animation-delay: calc(var(--ph-i) * 28ms);
90
+ }
91
+
92
+ @keyframes light-up {
93
+ from { opacity: 0.1; transform: scale(0.6); }
94
+ to { opacity: 1; transform: scale(1); }
95
+ }
96
+ ```
97
+
98
+ ## Canvas metrics (`12×18`)
99
+
100
+ | Rows | Zone |
101
+ | ----- | -------------- |
102
+ | 0–2 | Accent |
103
+ | 3–13 | Cap body |
104
+ | 6–13 | x-height |
105
+ | 14–17 | Descender |
106
+
107
+ Glyphs are authored as compact string matrices: `#` lit, `.` empty, and the
108
+ numpad-mnemonic markers `7 9 1 3` for corner triangles (subpixel smoothing).
109
+
110
+ ## Character set
111
+
112
+ - Letters `A–Z` and `a–z`, digits `0–9`.
113
+ - Accents `á à â ã ä é è ê í î ó ô õ ú ü ñ ç` (plus the matching capitals).
114
+ - Punctuation `, . ! ? : ; - ' " ( ) / @` and space.
115
+
116
+ Use `getCharacters()` to list everything available. Accented glyphs are
117
+ composed from a base letter plus a diacritic mark, so adding more is cheap.
118
+
119
+ ## Extending glyphs
120
+
121
+ Register your own glyphs (or override existing ones) at runtime. The source is
122
+ validated against the canvas metrics and the cache is invalidated:
123
+
124
+ ```ts
125
+ import { registerGlyph } from "@skvggor/pharos";
126
+
127
+ registerGlyph("€", [
128
+ "............",
129
+ "............",
130
+ "............",
131
+ "....#####...",
132
+ "...##.......",
133
+ "...##.......",
134
+ ".#######....",
135
+ "...##.......",
136
+ ".#######....",
137
+ "...##.......",
138
+ "...##.......",
139
+ "...##.......",
140
+ "....#####...",
141
+ "............",
142
+ "............",
143
+ "............",
144
+ "............",
145
+ "............",
146
+ ]);
147
+ ```
148
+
149
+ ## Development
150
+
151
+ ```bash
152
+ npm run dev # visual demo
153
+ npm test # tests
154
+ npm run test:coverage # tests + coverage
155
+ npm run build # build the library + types
156
+ npm run build:demo # build the demo (GitHub Pages)
157
+ ```
158
+
159
+ The demo is deployed to GitHub Pages from `main` via GitHub Actions
160
+ (`.github/workflows/deploy.yml`).
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("react/jsx-runtime");var t={"#":`on`,".":`off`,7:`tl`,9:`tr`,1:`bl`,3:`br`},n={width:12,height:18,accentTop:0,capTop:3,xHeight:6,baseline:13,descenderBottom:17};function r(e){return e!==`off`}function i(e){if(e.length!==n.height)throw Error(`Glyph must have ${n.height} rows, received ${e.length}.`);return e.map((e,r)=>{if(e.length!==n.width)throw Error(`Glyph row ${r} must have ${n.width} columns, received ${e.length}.`);return Array.from(e,(e,n)=>{let i=t[e];if(!i)throw Error(`Unknown glyph marker "${e}" at row ${r}, column ${n}.`);return i})})}function a(){return Array.from({length:n.height},()=>Array.from({length:n.width},()=>`off`))}var o={" ":[`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`],A:[`............`,`............`,`............`,`.....97.....`,`.....##.....`,`....####....`,`....#..#....`,`...##..##...`,`...##..##...`,`..########..`,`..##....##..`,`.##......##.`,`.##......##.`,`####....####`,`............`,`............`,`............`,`............`],E:[`............`,`............`,`............`,`..########..`,`..##........`,`..##........`,`..##........`,`..##........`,`..#######...`,`..##........`,`..##........`,`..##........`,`..##........`,`..########..`,`............`,`............`,`............`,`............`],H:[`............`,`............`,`............`,`.####..####.`,`..##....##..`,`..##....##..`,`..##....##..`,`..##....##..`,`..########..`,`..##....##..`,`..##....##..`,`..##....##..`,`..##....##..`,`.####..####.`,`............`,`............`,`............`,`............`],I:[`............`,`............`,`............`,`...######...`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`...######...`,`............`,`............`,`............`,`............`],L:[`............`,`............`,`............`,`.####.......`,`..##........`,`..##........`,`..##........`,`..##........`,`..##........`,`..##........`,`..##........`,`..##........`,`..##........`,`..########..`,`............`,`............`,`............`,`............`],O:[`............`,`............`,`............`,`...######...`,`.3#......#1.`,`.#........#.`,`##........##`,`##........##`,`##........##`,`##........##`,`##........##`,`.#........#.`,`.9#......#7.`,`...######...`,`............`,`............`,`............`,`............`],T:[`............`,`............`,`............`,`############`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`....####....`,`............`,`............`,`............`,`............`],l:[`............`,`............`,`............`,`....####....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`...######...`,`............`,`............`,`............`,`............`],o:[`............`,`............`,`............`,`............`,`............`,`............`,`....####....`,`...##..##...`,`..##....##..`,`..##....##..`,`..##....##..`,`..##....##..`,`...##..##...`,`....####....`,`............`,`............`,`............`,`............`],p:[`............`,`............`,`............`,`............`,`............`,`............`,`..######....`,`..##..##....`,`..##...##...`,`..##...##...`,`..##...##...`,`..##..##....`,`..######....`,`..##........`,`..##........`,`..##........`,`..##........`,`.####.......`],M:[`............`,`............`,`............`,`.##......##.`,`.###....###.`,`.####..####.`,`.##.####.##.`,`.##.####.##.`,`.##..##..##.`,`.##......##.`,`.##......##.`,`.##......##.`,`.##......##.`,`####....####`,`............`,`............`,`............`,`............`],a:[`............`,`............`,`............`,`............`,`............`,`............`,`...######...`,`..##....##..`,`........##..`,`...#######..`,`..##....##..`,`.##.....##..`,`..##....##..`,`..########..`,`............`,`............`,`............`,`............`],á:[`............`,`.......##...`,`......##....`,`............`,`............`,`............`,`...######...`,`..##....##..`,`........##..`,`...#######..`,`..##....##..`,`.##.....##..`,`..##....##..`,`..########..`,`............`,`............`,`............`,`............`],u:[`............`,`............`,`............`,`............`,`............`,`............`,`.####.####..`,`..##...##...`,`..##...##...`,`..##...##...`,`..##...##...`,`..##...##...`,`..##...##...`,`..#######...`,`............`,`............`,`............`,`............`],n:[`............`,`............`,`............`,`............`,`............`,`............`,`..#####.....`,`..##..##....`,`..##...##...`,`..##...##...`,`..##...##...`,`..##...##...`,`..##...##...`,`.####.####..`,`............`,`............`,`............`,`............`],d:[`............`,`............`,`............`,`.......###..`,`.......###..`,`.......##...`,`...####.##..`,`..##..####..`,`.##....###..`,`.##.....##..`,`.##.....##..`,`.##....###..`,`..##..####..`,`...####.##..`,`............`,`............`,`............`,`............`],r:[`............`,`............`,`............`,`............`,`............`,`............`,`..######....`,`..###..##...`,`..##........`,`..##........`,`..##........`,`..##........`,`..##........`,`.#####......`,`............`,`............`,`............`,`............`],s:[`............`,`............`,`............`,`............`,`............`,`............`,`..#####.....`,`.##...##....`,`.##.........`,`..####......`,`.....###....`,`.......##...`,`.##...##....`,`..#####.....`,`............`,`............`,`............`,`............`],v:[`............`,`............`,`............`,`............`,`............`,`............`,`.##......##.`,`.##......##.`,`..##....##..`,`..##....##..`,`...##..##...`,`...##..##...`,`....####....`,`.....##.....`,`............`,`............`,`............`,`............`],k:[`............`,`............`,`............`,`.##.........`,`.##.........`,`.##.........`,`.##....##...`,`.##...##....`,`.##..##.....`,`.#####......`,`.##.##......`,`.##..##.....`,`.##...##....`,`.##....##...`,`............`,`............`,`............`,`............`],g:[`............`,`............`,`............`,`............`,`............`,`............`,`..######....`,`.##....##...`,`.##....##...`,`.##....##...`,`.##....##...`,`.##....##...`,`..#######...`,`.......##...`,`.......##...`,`.#.....##...`,`.##...##....`,`..#####.....`],0:[`............`,`............`,`............`,`...######...`,`..##....##..`,`.##......##.`,`.##......##.`,`.##......##.`,`.##......##.`,`.##......##.`,`.##......##.`,`.##......##.`,`..##....##..`,`...######...`,`............`,`............`,`............`,`............`],9:[`............`,`............`,`............`,`...#####....`,`..##...##...`,`.##....##...`,`.##....##...`,`..##...##...`,`...######...`,`.......##...`,`.......##...`,`.......##...`,`.......##...`,`.......##...`,`............`,`............`,`............`,`............`],1:[`............`,`............`,`............`,`...####.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`...######...`,`............`,`............`,`............`,`............`],2:[`............`,`............`,`............`,`..######....`,`.##....##...`,`.......##...`,`......##....`,`.....##.....`,`....##......`,`...##.......`,`..##........`,`..##........`,`..##........`,`..########..`,`............`,`............`,`............`,`............`],3:[`............`,`............`,`............`,`..######....`,`.##....##...`,`.......##...`,`.......##...`,`....#####...`,`.......##...`,`.......##...`,`.......##...`,`.......##...`,`.##....##...`,`..######....`,`............`,`............`,`............`,`............`],4:[`............`,`............`,`............`,`.....###....`,`....####....`,`...##.##....`,`..##..##....`,`.##...##....`,`.########...`,`......##....`,`......##....`,`......##....`,`......##....`,`......##....`,`............`,`............`,`............`,`............`],5:[`............`,`............`,`............`,`..#######...`,`..##........`,`..##........`,`..######....`,`.......##...`,`.......##...`,`.......##...`,`.......##...`,`.......##...`,`.##....##...`,`..######....`,`............`,`............`,`............`,`............`],6:[`............`,`............`,`............`,`....####....`,`..###.......`,`.##.........`,`.##.........`,`.######.....`,`.##....##...`,`.##....##...`,`.##....##...`,`.##....##...`,`..##..##....`,`...####.....`,`............`,`............`,`............`,`............`],7:[`............`,`............`,`............`,`..########..`,`.......##...`,`......##....`,`.....##.....`,`.....##.....`,`....##......`,`....##......`,`....##......`,`...##.......`,`...##.......`,`...##.......`,`............`,`............`,`............`,`............`],8:[`............`,`............`,`............`,`..######....`,`.##....##...`,`.##....##...`,`.##....##...`,`..######....`,`.##....##...`,`.##....##...`,`.##....##...`,`.##....##...`,`.##....##...`,`..######....`,`............`,`............`,`............`,`............`],B:[`............`,`............`,`............`,`.#######....`,`.##....##...`,`.##....##...`,`.##...##....`,`.######.....`,`.##...##....`,`.##....##...`,`.##....##...`,`.##....##...`,`.##....##...`,`.#######....`,`............`,`............`,`............`,`............`],C:[`............`,`............`,`............`,`...#####....`,`.##.....##..`,`.##.........`,`##..........`,`##..........`,`##..........`,`##..........`,`.##.........`,`.##.....##..`,`...#####....`,`............`,`............`,`............`,`............`,`............`],D:[`............`,`............`,`............`,`.######.....`,`.##...##....`,`.##....##...`,`.##....##...`,`.##.....##..`,`.##.....##..`,`.##....##...`,`.##....##...`,`.##...##....`,`.######.....`,`............`,`............`,`............`,`............`,`............`],F:[`............`,`............`,`............`,`.########...`,`.##.........`,`.##.........`,`.##.........`,`.######.....`,`.##.........`,`.##.........`,`.##.........`,`.##.........`,`.##.........`,`.##.........`,`............`,`............`,`............`,`............`],G:[`............`,`............`,`............`,`...#####....`,`.##.....##..`,`.##.........`,`##..........`,`##..........`,`##..#####...`,`##......##..`,`##......##..`,`.##....##...`,`...#####....`,`............`,`............`,`............`,`............`,`............`],J:[`............`,`............`,`............`,`....######..`,`.......##...`,`.......##...`,`.......##...`,`.......##...`,`.......##...`,`.......##...`,`.......##...`,`##.....##...`,`.##...##....`,`..#####.....`,`............`,`............`,`............`,`............`],K:[`............`,`............`,`............`,`.##....##...`,`.##...##....`,`.##..##.....`,`.##.##......`,`.####.......`,`.####.......`,`.##.##......`,`.##..##.....`,`.##...##....`,`.##....##...`,`.##.....##..`,`............`,`............`,`............`,`............`],N:[`............`,`............`,`............`,`.##.....##..`,`.###....##..`,`.####...##..`,`.##.##..##..`,`.##..##.##..`,`.##...####..`,`.##....###..`,`.##.....##..`,`.##.....##..`,`.##.....##..`,`.##.....##..`,`............`,`............`,`............`,`............`],P:[`............`,`............`,`............`,`.######.....`,`.##...##....`,`.##....##...`,`.##....##...`,`.##...##....`,`.######.....`,`.##.........`,`.##.........`,`.##.........`,`.##.........`,`.##.........`,`............`,`............`,`............`,`............`],Q:[`............`,`............`,`............`,`...######...`,`.##......##.`,`##........##`,`##........##`,`##........##`,`##........##`,`##........##`,`.##......##.`,`...######...`,`.......###..`,`........###.`,`............`,`............`,`............`,`............`],R:[`............`,`............`,`............`,`.######.....`,`.##...##....`,`.##....##...`,`.##...##....`,`.######.....`,`.##.##......`,`.##..##.....`,`.##...##....`,`.##...##....`,`.##....##...`,`.##....##...`,`............`,`............`,`............`,`............`],S:[`............`,`............`,`............`,`..######....`,`.##....##...`,`.##.........`,`.##.........`,`..#####.....`,`.....###....`,`.......##...`,`.......##...`,`.##....##...`,`.##....##...`,`..######....`,`............`,`............`,`............`,`............`],U:[`............`,`............`,`............`,`.##.....##..`,`.##.....##..`,`.##.....##..`,`.##.....##..`,`.##.....##..`,`.##.....##..`,`.##.....##..`,`.##.....##..`,`.##....##...`,`..##...##...`,`...#####....`,`............`,`............`,`............`,`............`],V:[`............`,`............`,`............`,`##........##`,`.##......##.`,`.##......##.`,`..##....##..`,`..##....##..`,`...##..##...`,`...##..##...`,`....####....`,`....####....`,`.....##.....`,`.....##.....`,`............`,`............`,`............`,`............`],W:[`............`,`............`,`............`,`##........##`,`##........##`,`##........##`,`##........##`,`##...##...##`,`##..####..##`,`##.##..##.##`,`####....####`,`###......###`,`.##......##.`,`.##......##.`,`............`,`............`,`............`,`............`],X:[`............`,`............`,`............`,`##........##`,`.##......##.`,`..##....##..`,`...##..##...`,`....####....`,`.....##.....`,`....####....`,`...##..##...`,`..##....##..`,`.##......##.`,`##........##`,`............`,`............`,`............`,`............`],Y:[`............`,`............`,`............`,`##........##`,`.##......##.`,`..##....##..`,`...##..##...`,`....####....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`...######...`,`............`,`............`,`............`,`............`],Z:[`............`,`............`,`............`,`..########..`,`.......##...`,`......##....`,`.....##.....`,`....##......`,`...##.......`,`..##........`,`..##........`,`..##........`,`..##........`,`..########..`,`............`,`............`,`............`,`............`],b:[`............`,`............`,`............`,`.##.........`,`.##.........`,`.##.........`,`.#####......`,`.##..##.....`,`.##...##....`,`.##...##....`,`.##...##....`,`.##...##....`,`.##..##.....`,`.#####......`,`............`,`............`,`............`,`............`],c:[`............`,`............`,`............`,`............`,`............`,`............`,`...####.....`,`..##..##....`,`.##.........`,`.##.........`,`.##.........`,`.##.........`,`..##..##....`,`...####.....`,`............`,`............`,`............`,`............`],e:[`............`,`............`,`............`,`............`,`............`,`............`,`...####.....`,`..##..##....`,`.##....##...`,`.########...`,`.##.........`,`.##.........`,`..##..##....`,`...####.....`,`............`,`............`,`............`,`............`],f:[`............`,`............`,`............`,`....####....`,`...##..#....`,`...##.......`,`.#######....`,`...##.......`,`...##.......`,`...##.......`,`...##.......`,`...##.......`,`...##.......`,`...##.......`,`............`,`............`,`............`,`............`],h:[`............`,`............`,`............`,`.##.........`,`.##.........`,`.##.........`,`.#####......`,`.##..##.....`,`.##...##....`,`.##...##....`,`.##...##....`,`.##...##....`,`.##...##....`,`.##...##....`,`............`,`............`,`............`,`............`],i:[`............`,`............`,`............`,`............`,`.....##.....`,`............`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`...######...`,`............`,`............`,`............`,`............`],j:[`............`,`............`,`............`,`............`,`.....##.....`,`............`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`##...##.....`,`.##.##......`,`..###.......`],m:[`............`,`............`,`............`,`............`,`............`,`............`,`##########..`,`##..##..##..`,`##..##..##..`,`##..##..##..`,`##..##..##..`,`##..##..##..`,`##..##..##..`,`##..##..##..`,`............`,`............`,`............`,`............`],q:[`............`,`............`,`............`,`............`,`............`,`............`,`..######....`,`.##....##...`,`.##....##...`,`.##....##...`,`.##....##...`,`.##....##...`,`..#######...`,`.......##...`,`.......##...`,`.......##...`,`.......##...`,`.....#####..`],t:[`............`,`............`,`............`,`............`,`...##.......`,`...##.......`,`.######.....`,`...##.......`,`...##.......`,`...##.......`,`...##.......`,`...##.......`,`...##..##...`,`....####....`,`............`,`............`,`............`,`............`],w:[`............`,`............`,`............`,`............`,`............`,`............`,`##........##`,`##........##`,`##...##...##`,`##..####..##`,`##.##..##.##`,`####....####`,`.##......##.`,`.##......##.`,`............`,`............`,`............`,`............`],x:[`............`,`............`,`............`,`............`,`............`,`............`,`.##.....##..`,`..##...##...`,`...##.##....`,`....###.....`,`....###.....`,`...##.##....`,`..##...##...`,`.##.....##..`,`............`,`............`,`............`,`............`],y:[`............`,`............`,`............`,`............`,`............`,`............`,`.##.....##..`,`.##.....##..`,`.##.....##..`,`.##.....##..`,`..##...##...`,`..#######...`,`.......##...`,`.......##...`,`.......##...`,`.......##...`,`##.....##...`,`.######.....`],z:[`............`,`............`,`............`,`............`,`............`,`............`,`..######....`,`.....##.....`,`.....##.....`,`....##......`,`...##.......`,`..##........`,`..##........`,`..######....`,`............`,`............`,`............`,`............`],"?":[`............`,`............`,`............`,`..######....`,`.##....##...`,`.......##...`,`......##....`,`.....##.....`,`.....##.....`,`............`,`.....##.....`,`.....##.....`,`............`,`............`,`............`,`............`,`............`,`............`],":":[`............`,`............`,`............`,`............`,`............`,`............`,`.....##.....`,`.....##.....`,`............`,`............`,`............`,`.....##.....`,`.....##.....`,`............`,`............`,`............`,`............`,`............`],";":[`............`,`............`,`............`,`............`,`............`,`............`,`.....##.....`,`.....##.....`,`............`,`............`,`............`,`.....##.....`,`.....##.....`,`.....##.....`,`....##......`,`............`,`............`,`............`],"-":[`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`..######....`,`..######....`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`],"'":[`............`,`............`,`............`,`.....##.....`,`.....##.....`,`....##......`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`],'"':[`............`,`............`,`............`,`...##.##....`,`...##.##....`,`..##.##.....`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`],"(":[`............`,`............`,`............`,`....##......`,`...##.......`,`..##........`,`..##........`,`..##........`,`..##........`,`..##........`,`..##........`,`..##........`,`...##.......`,`....##......`,`............`,`............`,`............`,`............`],")":[`............`,`............`,`............`,`......##....`,`.......##...`,`........##..`,`........##..`,`........##..`,`........##..`,`........##..`,`........##..`,`........##..`,`.......##...`,`......##....`,`............`,`............`,`............`,`............`],"/":[`............`,`............`,`............`,`........##..`,`.......##...`,`......##....`,`......##....`,`.....##.....`,`.....##.....`,`....##......`,`....##......`,`...##.......`,`...##.......`,`..##........`,`............`,`............`,`............`,`............`],"@":[`............`,`............`,`............`,`..######....`,`.##....##...`,`##......##..`,`##..###.##..`,`##.##.#.##..`,`##.##.#.##..`,`##.##.#.##..`,`##..####.#..`,`##..........`,`.##....##...`,`..######....`,`............`,`............`,`............`,`............`],ç:[`............`,`............`,`............`,`............`,`............`,`............`,`...####.....`,`..##..##....`,`.##.........`,`.##.........`,`.##.........`,`..##..##....`,`...####.....`,`....##......`,`.....##.....`,`...###......`,`............`,`............`],Ç:[`............`,`............`,`............`,`...#####....`,`.##.....##..`,`.##.........`,`##..........`,`##..........`,`##..........`,`.##.........`,`.##.....##..`,`...#####....`,`....##......`,`.....##.....`,`...###......`,`............`,`............`,`............`],",":[`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`...##.......`,`...##.......`,`...##.......`,`..##........`,`............`,`............`],"!":[`............`,`............`,`............`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`............`,`.....##.....`,`.....##.....`,`............`,`............`,`............`,`............`],".":[`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`...##.......`,`...##.......`,`............`,`............`,`............`,`............`]},s={acute:[`.......##...`,`......##....`],grave:[`....##......`,`.....##.....`],circumflex:[`.....##.....`,`....#..#....`],tilde:[`...###.##...`,`..##.###....`],diaeresis:[`....#..#....`,`....#..#....`]};function c(e,t,n){return e.map((e,r)=>r===n?t[0]:r===n+1?t[1]:e)}var l=e=>e.map((e,t)=>t===4?`............`:e),u=(e,t)=>c(o[e],t,3),d=(e,t)=>c(o[e],t,0);Object.assign(o,{á:u(`a`,s.acute),à:u(`a`,s.grave),â:u(`a`,s.circumflex),ã:u(`a`,s.tilde),ä:u(`a`,s.diaeresis),é:u(`e`,s.acute),è:u(`e`,s.grave),ê:u(`e`,s.circumflex),í:c(l(o.i),s.acute,3),î:c(l(o.i),s.circumflex,3),ó:u(`o`,s.acute),ô:u(`o`,s.circumflex),õ:u(`o`,s.tilde),ú:u(`u`,s.acute),ü:u(`u`,s.diaeresis),ñ:u(`n`,s.tilde),Á:d(`A`,s.acute),À:d(`A`,s.grave),Â:d(`A`,s.circumflex),Ã:d(`A`,s.tilde),É:d(`E`,s.acute),Ê:d(`E`,s.circumflex),Í:d(`I`,s.acute),Ó:d(`O`,s.acute),Ô:d(`O`,s.circumflex),Õ:d(`O`,s.tilde),Ú:d(`U`,s.acute)});var f=new Map;function p(e,t){if(e.length!==1)throw Error(`registerGlyph expects a single character, got "${e}".`);i(t),o[e]=t,f.delete(e)}function m(){return Object.keys(o)}function h(e){let t=o[e];if(!t)return;let n=f.get(e);if(n)return n;let r=i(t);return f.set(e,r),r}function g(e){return e in o}function _(e){return Array.from(e,e=>{let t=h(e);return t?{character:e,matrix:t,isFallback:!1}:{character:e,matrix:h(` `)??a(),isFallback:!0}})}function v(e){let t=1/0,n=-1/0;for(let i of e)for(let e=0;e<i.length;e++)r(i[e])&&(e<t&&(t=e),e>n&&(n=e));return n===-1/0?null:{start:t,end:n}}function y(e){return typeof e==`number`?`${e}px`:e}function b(e,t,n){return!!e[t]?.[n]&&e[t][n]!==`off`}function x(e){return e.reduce((e,t)=>e+t.filter(r).length,0)}function S({text:t,pixelSize:i,gap:a,letterSpacing:o,color:s,offColor:c,pixelShape:l=`dot`,smartCorners:u=!1,smoothness:d=.6,proportional:f=!0,spaceWidth:p=4,renderOff:m=!0,fluid:h=!1,gapRatio:g=.16,letterSpacingRatio:S=.5,className:C,style:w,...T}){let E=_(t),D=T[`aria-label`]??t,O=n.width,k=E.map(e=>f?v(e.matrix):{start:0,end:O-1}),A={...w};if(h){let e=0;k.forEach((t,n)=>{if(t===null)e+=p;else{let n=t.end-t.start+1;e+=n+(n-1)*g}n<E.length-1&&(e+=S)}),A[`--ph-units`]=e>0?e:1,A[`--ph-gap-ratio`]=g,A[`--ph-letter-ratio`]=S}else i!==void 0&&(A[`--ph-pixel-size`]=y(i)),a!==void 0&&(A[`--ph-gap`]=y(a)),o!==void 0&&(A[`--ph-letter-spacing`]=y(o));s!==void 0&&(A[`--ph-on-color`]=s),c!==void 0&&(A[`--ph-off-color`]=c);let j=u&&(l===`square`||l===`squircle`),M=`calc(var(--ph-pixel-size) * ${d/2})`,N=[`pharos`,`ph-shape-${l}`,h&&`pharos--fluid`,C].filter(Boolean).join(` `),P=E.reduce((e,t)=>e+x(t.matrix),0),F=0;return(0,e.jsx)(`span`,{...T,role:`img`,"aria-label":D,className:N,style:A,children:E.map((t,i)=>{let a=k[i];if(a===null)return(0,e.jsx)(`span`,{"aria-hidden":`true`,className:`pharos__space`,style:{width:`calc(var(--ph-pixel-size) * ${p})`}},`${t.character}-${i}`);let{start:o,end:s}=a;return(0,e.jsx)(`span`,{"aria-hidden":`true`,className:`pharos__char`,style:{"--ph-cols":s-o+1,"--ph-rows":n.height},children:t.matrix.flatMap((n,i)=>n.slice(o,s+1).map((n,a)=>{let s=o+a,c=r(n);if(!m&&!c)return null;let l=[`pharos__pixel`],u={"--ph-row":i,"--ph-col":s};return m||(u.gridColumn=s-o+1,u.gridRow=i+1),c&&(l.push(`pharos__pixel--on`),u[`--ph-i`]=F++,u[`--ph-n`]=P),n!==`on`&&n!==`off`?l.push(`ph-tri-${n}`):j&&n===`on`&&(u.borderRadius=`${!b(t.matrix,i-1,s)&&!b(t.matrix,i,s-1)?M:`0`} ${!b(t.matrix,i-1,s)&&!b(t.matrix,i,s+1)?M:`0`} ${!b(t.matrix,i+1,s)&&!b(t.matrix,i,s+1)?M:`0`} ${!b(t.matrix,i+1,s)&&!b(t.matrix,i,s-1)?M:`0`}`),(0,e.jsx)(`span`,{className:l.join(` `),style:u},`${i}-${s}`)}))},`${t.character}-${i}`)})})}exports.GLYPHS=o,exports.METRICS=n,exports.PixelText=S,exports.getCharacters=m,exports.getGlyphMatrix=h,exports.glyphBounds=v,exports.hasGlyph=g,exports.isLit=r,exports.registerGlyph=p,exports.renderText=_;
@@ -0,0 +1,2 @@
1
+ .pharos{--ph-pixel-size:6px;--ph-gap:1px;--ph-letter-spacing:calc(var(--ph-pixel-size) * .5);--ph-on-color:currentColor;--ph-off-color:transparent;align-items:flex-start;gap:var(--ph-letter-spacing);flex-flow:row;line-height:0;display:inline-flex}.pharos--fluid{--ph-pixel-size:calc(100cqw / var(--ph-units));--ph-gap:calc(var(--ph-pixel-size) * var(--ph-gap-ratio));--ph-letter-spacing:calc(var(--ph-pixel-size) * var(--ph-letter-ratio));width:100%;display:flex;container-type:inline-size}.pharos__char{grid-template-columns:repeat(var(--ph-cols), var(--ph-pixel-size));grid-template-rows:repeat(var(--ph-rows), var(--ph-pixel-size));gap:var(--ph-gap);display:grid}.pharos__space{flex:none}.pharos__pixel{width:var(--ph-pixel-size);height:var(--ph-pixel-size);background-color:var(--ph-off-color)}.pharos__pixel--on{background-color:var(--ph-on-color)}.ph-shape-squircle .pharos__pixel{border-radius:28%}.ph-shape-dot .pharos__pixel{border-radius:50%}.ph-shape-diamond .pharos__pixel{clip-path:polygon(50% 0,100% 50%,50% 100%,0 50%)}.ph-shape-ring .pharos__pixel--on{box-shadow:inset 0 0 0 max(1px, calc(var(--ph-pixel-size) * .24)) var(--ph-on-color);background-color:#0000;border-radius:50%}.pharos__pixel.ph-tri-tl{clip-path:polygon(0 0,100% 0,0 100%);border-radius:0}.pharos__pixel.ph-tri-tr{clip-path:polygon(0 0,100% 0,100% 100%);border-radius:0}.pharos__pixel.ph-tri-bl{clip-path:polygon(0 0,0 100%,100% 100%);border-radius:0}.pharos__pixel.ph-tri-br{clip-path:polygon(100% 0,100% 100%,0 100%);border-radius:0}
2
+ /*$vite$:1*/