@leftium/logo 0.3.0 → 0.4.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.
@@ -0,0 +1,77 @@
1
+ /**
2
+ * L-only ligature geometry for the Leftium favicon.
3
+ *
4
+ * The "L" is defined on a grid of 5 equal squares:
5
+ * - Vertical stem: 1 square wide, 5 squares tall
6
+ * - Horizontal foot: 3 squares wide (2 for L + 1 shared), 1 square tall
7
+ *
8
+ * Unrotated vertices (in grid units, origin at top-left):
9
+ * (0,0) → (1,0) → (1,4) → (3,4) → (3,5) → (0,5)
10
+ *
11
+ * The shape is then rotated 45° clockwise for the final favicon mark.
12
+ */
13
+ // ─── Unrotated L polygon (grid units) ────────────────────────────────────────
14
+ /** Vertices of the L shape in grid units before rotation. */
15
+ export const L_VERTICES = [
16
+ [0, 0],
17
+ [1, 0],
18
+ [1, 4],
19
+ [3, 4],
20
+ [3, 5],
21
+ [0, 5]
22
+ ];
23
+ /** Grid columns (unrotated width in grid units). */
24
+ export const L_COLS = 3;
25
+ /** Grid rows (unrotated height in grid units). */
26
+ export const L_ROWS = 5;
27
+ // ─── 45° CW rotation ────────────────────────────────────────────────────────
28
+ const R = Math.SQRT2 / 2; // cos(45°) = sin(45°)
29
+ /** Rotate a point 45° clockwise (in screen/SVG coordinates where Y points down). */
30
+ function rotateCW45(x, y) {
31
+ return [x * R - y * R, x * R + y * R];
32
+ }
33
+ /** Rotated L vertices (in grid units, not yet translated to origin). */
34
+ export const L_ROTATED_RAW = L_VERTICES.map(([x, y]) => rotateCW45(x, y));
35
+ // Compute bounding box of the rotated shape
36
+ const rxs = L_ROTATED_RAW.map(([x]) => x);
37
+ const rys = L_ROTATED_RAW.map(([, y]) => y);
38
+ const rMinX = Math.min(...rxs);
39
+ const rMinY = Math.min(...rys);
40
+ const rMaxX = Math.max(...rxs);
41
+ const rMaxY = Math.max(...rys);
42
+ /** Width of rotated L bounding box (in grid units). */
43
+ export const L_ROTATED_W = rMaxX - rMinX;
44
+ /** Height of rotated L bounding box (in grid units). */
45
+ export const L_ROTATED_H = rMaxY - rMinY;
46
+ /** Rotated L vertices, translated so bounding box starts at (0,0). */
47
+ export const L_ROTATED = L_ROTATED_RAW.map(([x, y]) => [x - rMinX, y - rMinY]);
48
+ /** Center of the rotated L bounding box (in grid units, origin-translated). */
49
+ export const L_ROTATED_CX = L_ROTATED_W / 2;
50
+ export const L_ROTATED_CY = L_ROTATED_H / 2;
51
+ // ─── SVG polygon generation ─────────────────────────────────────────────────
52
+ /**
53
+ * Generate an SVG `points` attribute string for the rotated L polygon,
54
+ * scaled and positioned within a container.
55
+ *
56
+ * @param containerSize - Side length of the square container (px)
57
+ * @param scale - Scale factor (1 = fill container width)
58
+ * @param offsetX - Horizontal offset as fraction of container (-0.5 to 0.5)
59
+ * @param offsetY - Vertical offset as fraction of container (-0.5 to 0.5)
60
+ * @returns SVG polygon `points` string
61
+ */
62
+ export function generateLPolygonPoints(containerSize, scale = 1, offsetX = 0, offsetY = 0) {
63
+ // The rotated L has a certain aspect ratio; scale to fit container
64
+ const maxDim = Math.max(L_ROTATED_W, L_ROTATED_H);
65
+ const baseScale = (containerSize / maxDim) * scale;
66
+ // Scaled dimensions
67
+ const scaledW = L_ROTATED_W * baseScale;
68
+ const scaledH = L_ROTATED_H * baseScale;
69
+ // Center in container, then apply offset
70
+ const tx = (containerSize - scaledW) / 2 + offsetX * containerSize;
71
+ const ty = (containerSize - scaledH) / 2 + offsetY * containerSize;
72
+ return L_ROTATED.map(([x, y]) => `${rd(x * baseScale + tx)},${rd(y * baseScale + ty)}`).join(' ');
73
+ }
74
+ /** Round to 4 decimal places for clean SVG output. */
75
+ function rd(n) {
76
+ return Math.round(n * 10000) / 10000;
77
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leftium/logo",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/Leftium/leftium-logo.git"