@jannchie/icons 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.
Files changed (111) hide show
  1. package/dist/all.js +30 -0
  2. package/dist/icons/c.js +8 -0
  3. package/dist/icons/cpp.js +8 -0
  4. package/dist/icons/csharp.js +8 -0
  5. package/dist/icons/golang.js +8 -0
  6. package/dist/icons/haskell.js +8 -0
  7. package/dist/icons/java.js +8 -0
  8. package/dist/icons/javascript.js +8 -0
  9. package/dist/icons/kotlin.js +8 -0
  10. package/dist/icons/lua.js +8 -0
  11. package/dist/icons/php.js +8 -0
  12. package/dist/icons/python.js +8 -0
  13. package/dist/icons/ruby.js +8 -0
  14. package/dist/icons/rust.js +8 -0
  15. package/dist/icons/swift.js +8 -0
  16. package/dist/icons/typescript.js +8 -0
  17. package/dist/index.d.ts +30 -0
  18. package/dist/index.js +16 -1
  19. package/dist/src/battery.js +22 -1
  20. package/dist/src/cc.js +2 -1
  21. package/dist/src/controller.js +5 -2
  22. package/dist/src/icons/api.js +2 -2
  23. package/dist/src/icons/battery-full.js +1 -1
  24. package/dist/src/icons/battery-low.js +1 -1
  25. package/dist/src/icons/battery-medium.js +1 -1
  26. package/dist/src/icons/bee.js +3 -2
  27. package/dist/src/icons/bike.js +5 -13
  28. package/dist/src/icons/billiards.js +2 -2
  29. package/dist/src/icons/bingo.js +2 -2
  30. package/dist/src/icons/c.js +12 -0
  31. package/dist/src/icons/card-plus-four.js +2 -2
  32. package/dist/src/icons/card-plus-two.js +2 -2
  33. package/dist/src/icons/cat.js +4 -3
  34. package/dist/src/icons/cpp.js +21 -0
  35. package/dist/src/icons/csharp.js +17 -0
  36. package/dist/src/icons/element.js +3 -3
  37. package/dist/src/icons/fog.js +2 -2
  38. package/dist/src/icons/golang.js +10 -0
  39. package/dist/src/icons/haskell.js +10 -0
  40. package/dist/src/icons/html.js +6 -2
  41. package/dist/src/icons/java.js +10 -0
  42. package/dist/src/icons/javascript.js +14 -0
  43. package/dist/src/icons/json.js +2 -2
  44. package/dist/src/icons/kotlin.js +15 -0
  45. package/dist/src/icons/list-ordered.js +4 -3
  46. package/dist/src/icons/lua.js +9 -0
  47. package/dist/src/icons/medal-1.js +2 -2
  48. package/dist/src/icons/medal-2.js +2 -2
  49. package/dist/src/icons/medal-3.js +2 -2
  50. package/dist/src/icons/microscope.js +10 -10
  51. package/dist/src/icons/mushroom.js +5 -5
  52. package/dist/src/icons/php.js +8 -0
  53. package/dist/src/icons/pig.js +4 -3
  54. package/dist/src/icons/python.js +25 -0
  55. package/dist/src/icons/ruby.js +16 -0
  56. package/dist/src/icons/rust.js +16 -0
  57. package/dist/src/icons/scooter.js +3 -8
  58. package/dist/src/icons/sudoku.js +2 -2
  59. package/dist/src/icons/swift.js +4 -0
  60. package/dist/src/icons/tag-0.js +2 -2
  61. package/dist/src/icons/tag-1.js +2 -2
  62. package/dist/src/icons/tag-2.js +2 -2
  63. package/dist/src/icons/tag-3.js +2 -2
  64. package/dist/src/icons/tag-4.js +2 -2
  65. package/dist/src/icons/tag-5.js +2 -2
  66. package/dist/src/icons/tag-6.js +2 -2
  67. package/dist/src/icons/tag-7.js +2 -2
  68. package/dist/src/icons/tag-8.js +2 -2
  69. package/dist/src/icons/tag-9.js +2 -2
  70. package/dist/src/icons/tag-a.js +2 -2
  71. package/dist/src/icons/tag-b.js +2 -2
  72. package/dist/src/icons/tag-c.js +2 -2
  73. package/dist/src/icons/tag-d.js +2 -2
  74. package/dist/src/icons/tag-e.js +2 -2
  75. package/dist/src/icons/tag-f.js +2 -2
  76. package/dist/src/icons/tag-g.js +2 -2
  77. package/dist/src/icons/tag-h.js +2 -2
  78. package/dist/src/icons/tag-i.js +2 -2
  79. package/dist/src/icons/tag-j.js +2 -2
  80. package/dist/src/icons/tag-k.js +2 -2
  81. package/dist/src/icons/tag-l.js +2 -2
  82. package/dist/src/icons/tag-m.js +2 -2
  83. package/dist/src/icons/tag-n.js +2 -2
  84. package/dist/src/icons/tag-o.js +2 -2
  85. package/dist/src/icons/tag-p.js +2 -2
  86. package/dist/src/icons/tag-q.js +2 -2
  87. package/dist/src/icons/tag-r.js +2 -2
  88. package/dist/src/icons/tag-s.js +2 -2
  89. package/dist/src/icons/tag-t.js +2 -2
  90. package/dist/src/icons/tag-u.js +2 -2
  91. package/dist/src/icons/tag-v.js +2 -2
  92. package/dist/src/icons/tag-w.js +2 -2
  93. package/dist/src/icons/tag-x.js +2 -2
  94. package/dist/src/icons/tag-y.js +2 -2
  95. package/dist/src/icons/tag-z.js +2 -2
  96. package/dist/src/icons/taxi.js +1 -1
  97. package/dist/src/icons/traffic-cone.js +9 -8
  98. package/dist/src/icons/typescript.js +14 -0
  99. package/dist/src/laundry.js +3 -3
  100. package/dist/src/letters.js +35 -16
  101. package/dist/src/license.js +3 -3
  102. package/dist/src/loading.js +3 -3
  103. package/dist/src/quality.js +3 -3
  104. package/dist/src/rate.js +3 -3
  105. package/dist/src/rating.js +15 -12
  106. package/dist/src/resin.js +3 -3
  107. package/dist/src/scene.js +5 -1
  108. package/dist/src/sensor.js +7 -6
  109. package/dist/src/symbols.js +35 -22
  110. package/dist/src/unit.js +2 -2
  111. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  import { rounded } from "./geometry.js";
2
- import { line } from "./letters.js";
2
+ import { LABEL, line, snap } from "./letters.js";
3
3
  //#region src/quality.js
4
4
  var H = 1.2;
5
5
  var widthOf = (n) => n > 2 ? .85 : 1.2;
@@ -48,9 +48,9 @@ function quality(text, radius) {
48
48
  [21.5, 5.5],
49
49
  [21.5, 18.5],
50
50
  [2.5, 18.5]
51
- ], Math.min(radius, 2.5)), ...line(text, [12, 12], widthOf(text.length), GAP, H).map((d) => ({
51
+ ], Math.min(radius, 2.5)), ...snap(line(text, [12, 12], widthOf(text.length), GAP, H, LABEL)).map((d) => ({
52
52
  d,
53
- detail: true
53
+ thin: true
54
54
  }))];
55
55
  }
56
56
  //#endregion
package/dist/src/rate.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { dot } from "./scene.js";
2
- import { advance, glyph, shift, snap } from "./letters.js";
2
+ import { LABEL, advance, glyph, shift, snap } from "./letters.js";
3
3
  //#region src/rate.js
4
4
  var H = 7;
5
5
  var TOP = 12 - H / 2;
@@ -31,8 +31,8 @@ function rate(text) {
31
31
  out.push(dot(x + POINT / 2, 15.25));
32
32
  x += POINT;
33
33
  } else {
34
- out.push(glyph(c, x - shift(c) * sx, TOP, sx, sy));
35
- x += advance(c) * sx;
34
+ out.push(glyph(c, x - shift(c, LABEL) * sx, TOP, sx, sy, LABEL));
35
+ x += advance(c, LABEL) * sx;
36
36
  }
37
37
  x += gapAfter(i);
38
38
  });
@@ -1,5 +1,5 @@
1
1
  import { circle, rounded } from "./geometry.js";
2
- import { line, textWidth } from "./letters.js";
2
+ import { LABEL, line, snap, textWidth } from "./letters.js";
3
3
  import { tagShape } from "./marks.js";
4
4
  //#region src/rating.js
5
5
  var sq = (x0, y0, x1, y1) => [
@@ -21,9 +21,9 @@ var FRAMES = {
21
21
  tall: {
22
22
  shape: (r) => rounded(sq(3.5, 2.5, 20.5, 21.5), Math.min(r, 2.5)),
23
23
  box: [
24
- 7,
24
+ 6.5,
25
25
  5,
26
- 17,
26
+ 17.5,
27
27
  19
28
28
  ]
29
29
  },
@@ -265,26 +265,29 @@ var SYSTEMS = {
265
265
  }
266
266
  };
267
267
  var GAP = 2;
268
+ var ROW_GAP = 3;
268
269
  var PLUS = 3;
269
270
  var PLUS_GAP = 2;
270
271
  var MAX_SY = 1.2;
271
272
  var ASPECT = .95;
272
273
  function layout(rows, [x0, y0, x1, y1]) {
273
274
  const extra = (r) => r.plus ? 5 : 0;
274
- const sy = Math.min(MAX_SY, (y1 - y0 - GAP * (rows.length - 1)) / (6 * rows.length));
275
- const sx = Math.min(sy * ASPECT, ...rows.map((r) => (x1 - x0 - extra(r) - GAP * (r.chars.length - 1)) / textWidth(r.chars, 1, 0)));
275
+ const sy = Math.min(MAX_SY, (y1 - y0 - ROW_GAP * (rows.length - 1)) / (6 * rows.length));
276
+ const sx = Math.min(sy * ASPECT, ...rows.map((r) => (x1 - x0 - extra(r) - GAP * (r.chars.length - 1)) / textWidth(r.chars, 1, 0, LABEL)));
276
277
  const h = 6 * sy;
277
- const top = (y0 + y1) / 2 - (h * rows.length + GAP * (rows.length - 1)) / 2;
278
+ const top = (y0 + y1) / 2 - (h * rows.length + ROW_GAP * (rows.length - 1)) / 2;
278
279
  return rows.flatMap((r, i) => {
279
- const width = textWidth(r.chars, sx, GAP);
280
+ const width = textWidth(r.chars, sx, GAP, LABEL);
280
281
  const left = (x0 + x1) / 2 - (width + extra(r)) / 2;
281
- const y = top + i * (h + GAP);
282
- const out = line(r.chars, [left + width / 2, y + h / 2], sx, GAP, sy);
282
+ const y = top + i * (h + ROW_GAP);
283
+ const out = line(r.chars, [left + width / 2, y + h / 2], sx, GAP, sy, LABEL);
284
+ const row = snap(out);
283
285
  if (r.plus) {
284
- const [px, py] = [left + width + PLUS_GAP + PLUS / 2, y + PLUS / 2];
285
- out.push(`M${px - PLUS / 2} ${py}H${px + PLUS / 2}M${px} ${py - PLUS / 2}V${py + PLUS / 2}`);
286
+ const half = (v) => Math.round(v - .5) + .5;
287
+ const [px, py] = [half(left + width + PLUS_GAP + PLUS / 2), half(y + PLUS / 2)];
288
+ row.push(`M${px - PLUS / 2} ${py}H${px + PLUS / 2}M${px} ${py - PLUS / 2}V${py + PLUS / 2}`);
286
289
  }
287
- return out;
290
+ return row;
288
291
  });
289
292
  }
290
293
  function rating(system, text, radius) {
package/dist/src/resin.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { crisp, rounded } from "./geometry.js";
2
- import { line } from "./letters.js";
2
+ import { LABEL, line, snap } from "./letters.js";
3
3
  //#region src/resin.js
4
4
  var V = [
5
5
  [12, 3],
@@ -44,9 +44,9 @@ var RESIN = Object.fromEntries([
44
44
  0,
45
45
  1,
46
46
  2
47
- ].flatMap((k) => arrow(k, radius)), ...line(n, [12, 14]).map((d) => ({
47
+ ].flatMap((k) => arrow(k, radius)), ...snap(line(n, [12, 14], 1, 1.5, 1, LABEL)).map((d) => ({
48
48
  d,
49
- detail: true
49
+ thin: true
50
50
  }))]
51
51
  }]));
52
52
  //#endregion
package/dist/src/scene.js CHANGED
@@ -17,5 +17,9 @@ var opening = (cx, w, h) => [
17
17
  [cx + w / 2, 20 - h],
18
18
  [cx + w / 2, GROUND]
19
19
  ];
20
+ var softEar = (a, t, b, k = 1.3) => {
21
+ const c = (p) => [p[0] + (t[0] - p[0]) * k, p[1] + (t[1] - p[1]) * k].map((v) => +v.toFixed(3)).join(" ");
22
+ return `C${c(a)} ${c(b)} ${b.map((v) => +v.toFixed(3)).join(" ")}`;
23
+ };
20
24
  //#endregion
21
- export { GROUND, dot, eye, groundLine, opening };
25
+ export { GROUND, dot, eye, groundLine, opening, softEar };
@@ -1,4 +1,4 @@
1
- import { line, textWidth } from "./letters.js";
1
+ import { LABEL, line, snap, textWidth } from "./letters.js";
2
2
  //#region src/sensor.js
3
3
  var L = 2.5;
4
4
  var [X0, Y0, X1, Y1] = [
@@ -13,11 +13,12 @@ var cropMarks = () => [
13
13
  `M${X1} ${Y1 - L}V${Y1}H${X1 - L}`,
14
14
  `M${X0 + L} ${Y1}H${X0}V${Y1 - L}`
15
15
  ];
16
- var SPAN = 16;
17
- var GAP = 1.75;
16
+ var SPAN = 14;
17
+ var GAP = 2;
18
+ var SY = 5 / 6;
18
19
  var label = (text) => {
19
- const sx = Math.min(1, (SPAN - GAP * (text.length - 1)) / textWidth(text, 1, 0));
20
- return line(text, [12, 12], sx, GAP, 1).map((d) => ({
20
+ const sx = Math.min(1, (SPAN - GAP * (text.length - 1)) / textWidth(text, 1, 0, LABEL));
21
+ return snap(line(text, [12, 12], sx, GAP, SY, LABEL)).map((d) => ({
21
22
  d,
22
23
  thin: true
23
24
  }));
@@ -41,7 +42,7 @@ var SENSORS = {
41
42
  },
42
43
  "one-inch": {
43
44
  zh: "1 英寸",
44
- paths: () => [...line("1", [10.5, 12], 1, GAP, 1), "M14 9V11M16 9V11"].map((d) => ({
45
+ paths: () => snap([...line("1", [10.5, 12], 1, GAP, SY, LABEL), "M13.5 9.5V11.5M15.5 9.5V11.5"]).map((d) => ({
45
46
  d,
46
47
  thin: true
47
48
  }))
@@ -31,7 +31,7 @@ var cornerScale = Object.fromEntries(Object.entries({
31
31
  gauge: 1,
32
32
  lock: 1,
33
33
  code: 1,
34
- search: 1,
34
+ search: .85,
35
35
  heart: 1,
36
36
  question: 1,
37
37
  exclaim: 1,
@@ -91,10 +91,10 @@ var outlines = {
91
91
  ring: { circle: 3 },
92
92
  star: { circle: 3.45 },
93
93
  cloud: { box: [
94
- -3.65,
95
- -2.65,
94
+ -3.66,
95
+ -1.66,
96
96
  3.6,
97
- 2.65
97
+ 2.67
98
98
  ] },
99
99
  shield: { box: [
100
100
  -3.01,
@@ -334,19 +334,24 @@ var drawStar = ([x, y], k = 1, radius = 0) => {
334
334
  };
335
335
  var cloudCircles = [
336
336
  [
337
- -1.95,
338
- .95,
339
- 1.7
337
+ -2.68,
338
+ 1.67,
339
+ .98
340
340
  ],
341
341
  [
342
- .1,
343
- -.25,
344
- 2.4
342
+ -1.11,
343
+ .29,
344
+ 1.57
345
345
  ],
346
346
  [
347
- 2,
348
347
  1.05,
349
- 1.6
348
+ .1,
349
+ 1.76
350
+ ],
351
+ [
352
+ 2.42,
353
+ 1.49,
354
+ 1.18
350
355
  ]
351
356
  ];
352
357
  var cloudFillet = .5;
@@ -366,23 +371,31 @@ function arcTo([cx, cy, r], from, to) {
366
371
  return `A${r} ${r} 0 ${((Math.atan2(to[1] - cy, to[0] - cx) - a0) % (2 * Math.PI) + 2 * Math.PI) % (2 * Math.PI) > Math.PI ? 1 : 0} 1 ${to[0]} ${to[1]}`;
367
372
  }
368
373
  function cloudTop([x, y], k) {
369
- const [left, mid, right] = cloudCircles.map(([cx, cy, r]) => [
374
+ const cs = cloudCircles.map(([cx, cy, r]) => [
370
375
  x + cx * k,
371
376
  y + cy * k,
372
377
  r * k
373
378
  ]);
374
379
  const f = cloudFillet * k;
375
- const p1 = upperIntersection(left, mid);
376
- const p2 = upperIntersection(mid, right);
377
- const l1 = pointOn(left, angleOn(left, p1) - f / left[2]);
378
- const m1 = pointOn(mid, angleOn(mid, p1) + f / mid[2]);
379
- const m2 = pointOn(mid, angleOn(mid, p2) - f / mid[2]);
380
- const r1 = pointOn(right, angleOn(right, p2) + f / right[2]);
381
- const start = [left[0], left[1] + left[2]];
382
- const end = [right[0], right[1] + right[2]];
383
380
  const pt = (p) => `${p[0]} ${p[1]}`;
381
+ const start = [cs[0][0], cs[0][1] + cs[0][2]];
382
+ const end = [cs.at(-1)[0], cs.at(-1)[1] + cs.at(-1)[2]];
383
+ let arcs = "";
384
+ let from = start;
385
+ cs.forEach((c, i) => {
386
+ const next = cs[i + 1];
387
+ if (!next) {
388
+ arcs += arcTo(c, from, end);
389
+ return;
390
+ }
391
+ const p = upperIntersection(c, next);
392
+ const out = pointOn(c, angleOn(c, p) - f / c[2]);
393
+ const into = pointOn(next, angleOn(next, p) + f / next[2]);
394
+ arcs += `${arcTo(c, from, out)}Q${pt(p)} ${pt(into)}`;
395
+ from = into;
396
+ });
384
397
  return {
385
- arcs: `${arcTo(left, start, l1)}Q${pt(p1)} ${pt(m1)}${arcTo(mid, m1, m2)}Q${pt(p2)} ${pt(r1)}${arcTo(right, r1, end)}`,
398
+ arcs,
386
399
  start,
387
400
  end
388
401
  };
package/dist/src/unit.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { dot } from "./scene.js";
2
2
  import { circle, crisp, rounded } from "./geometry.js";
3
- import { line, snap } from "./letters.js";
3
+ import { LABEL, line, snap } from "./letters.js";
4
4
  //#region src/unit.js
5
5
  var [X0, Y0, X1, Y1] = [
6
6
  3.5,
@@ -17,7 +17,7 @@ var cross = [`M${X0} ${Y0}L${X1} ${Y1}`, `M${X1} ${Y0}L${X0} ${Y1}`];
17
17
  var track = `M9.5 9.5H15.5A3 3 0 0 1 15.5 15.5H9.5A3 3 0 0 1 9.5 9.5Z`;
18
18
  var wings = `M9.5 ${Y1}A1.5 1.5 0 0 1 ${CX} ${Y1}A1.5 1.5 0 0 1 15.5 ${Y1}`;
19
19
  var slash = `M${X0} ${Y1}L${X1} ${Y0}`;
20
- var text = (str) => [snap(line(str, [CX, CY], 1, 2, 1))].flat().map((d) => ({
20
+ var text = (str) => [snap(line(str, [CX, CY], 1, 2, 1, LABEL))].flat().map((d) => ({
21
21
  d,
22
22
  thin: true
23
23
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jannchie/icons",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Line icons on a 24-unit grid, redrawn for every corner radius and stroke weight, with pixel hinting and duo-tone colors",
5
5
  "license": "MIT",
6
6
  "author": "Jianqi Pan",