@massimo-cassandro/minimo 1.2.0 → 1.3.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,56 @@
1
+ export function ratindDisplayAnimation() {
2
+ const runAnimation = () => {
3
+
4
+ const animationStepValue = parsedDisplayValue / animation_ms;
5
+
6
+ let fpsInterval = animation_ms / animation_fps,
7
+ currentDisplayValue = displayScaleStartValue, // valore iniziale. La scala parte da 1
8
+ startTimestamp = Date.now(),
9
+ animationEnd = false;
10
+
11
+ const step = () => {
12
+ let now = Date.now(),
13
+ elapsed = now - startTimestamp;
14
+
15
+ currentDisplayValue = Math.min(currentDisplayValue, parsedDisplayValue);
16
+
17
+ if(currentDisplayValue >= parsedDisplayValue) {
18
+ animationEnd = true;
19
+ }
20
+
21
+ // request another frame
22
+ const animationRequest = window.requestAnimationFrame(step);
23
+
24
+ // if enough time has elapsed, draw the next frame
25
+ if (elapsed >= fpsInterval) {
26
+
27
+ // Get ready for next frame by setting startTimestamp=now, but...
28
+ // Also, adjust for fpsInterval not being multiple of 16.67
29
+ startTimestamp = now - (elapsed % fpsInterval);
30
+
31
+ svgElement.style.setProperty(
32
+ '--rd-rot',
33
+ Math.max(0, ((currentDisplayValue - displayScaleStartValue) * 240) / (scale - .001))
34
+ );
35
+
36
+ if(animationEnd) {
37
+ window.cancelAnimationFrame(animationRequest);
38
+
39
+ } else {
40
+ currentDisplayValue += animationStepValue;
41
+ // easing out a 2/3 del valore
42
+ // if(currentDisplayValue >= parsedDisplayValue * 2/3) {
43
+ // fpsInterval += 1;
44
+ // }
45
+
46
+ }
47
+ }
48
+
49
+ };// end step
50
+
51
+ step();
52
+ }; // end animazione_arco
53
+
54
+ runAnimation();
55
+
56
+ }; // end display_animation
@@ -0,0 +1,102 @@
1
+ import { toRadians, polarToCartesianString } from '../../chart-utils.js';
2
+
3
+ // 30 gradi in radianti
4
+ // ampiezza dell'angolo della parte eccedente il raggio della circonferenza che include l'arco di cerchio
5
+ export const rad30 = toRadians(30);
6
+
7
+ // getDisplayBackgroundPath: calcola il path dell'elemento di background, usato anche per i miniDisplay
8
+ export function getDisplayBackgroundPath(radius, cx, cy) {
9
+ const startPointX = cx - (radius * Math.cos(rad30)),
10
+ startPointY = cy + (radius * Math.sin(rad30)),
11
+
12
+ endPointX = cx + (radius * Math.cos(rad30)),
13
+ endPointY = startPointY;
14
+
15
+ return `M${startPointX},${startPointY}` +
16
+ // rx ry x-axis-angle large-arc-flag sweep-flag end-x end-y
17
+ `A${radius} ${radius} 0 1 1 ${endPointX} ${endPointY}`;
18
+ };
19
+
20
+
21
+
22
+
23
+ /**
24
+ * restituisce la proiezione di un punto sulla circonferenza esterna sulla circonferenza interna
25
+ // di centro e raggio dati
26
+ * @param {object} centro - Coordinate del centro della circonferenza interna
27
+ * @param {number} centro.x - Coordinata x del centro
28
+ * @param {number} centro.y - Coordinata y del centro
29
+ * @param {number} r - Raggio della circonferenza interna
30
+ * @param {number} alphaDeg - Angolo alpha in gradi
31
+ * @returns @returns {{x: number, y: number}} - Coordinate {x, y}
32
+ */
33
+ function calcolaProiezionePuntoOLD(centro, r, alphaDeg) {
34
+
35
+ // Conversione da gradi a radianti
36
+ const alphaRad = toRadians(alphaDeg);
37
+
38
+ return {
39
+ x: centro.x + r * Math.cos(alphaRad),
40
+ y: centro.y + r * Math.sin(alphaRad)
41
+ };
42
+ }
43
+
44
+
45
+ export function normalizeAngle(angle) {
46
+ angle = angle % 360;
47
+ if (angle < 0) angle += 360;
48
+
49
+ return angle;
50
+ }
51
+
52
+ export function isCircleDx(nomalizedAngle) {
53
+ return (nomalizedAngle > 30 && nomalizedAngle <= 210)? false : true;
54
+ }
55
+
56
+ /**
57
+ * Calcola il punto della circonferenza interna per l'angolo dato
58
+
59
+ * @param {number} angoloDeg - angolo (normalizzato)
60
+ // * @param {object} centroSx - Coordinate {x, y} del centro sinistro
61
+ // * @param {object} centroDx - Coordinate {x, y} del centro destro
62
+ * @param {number} rSx - Raggio della circonferenza sinistra (c)
63
+ * @param {number} rDx - Raggio della circonferenza destra (b)
64
+ * @param {object} mainCenter - Coordinate {x, y} dell'origine A
65
+ * @param {number} centerGap - Distanza d tra mainCenter e i centri delle circonferenze interne
66
+ * @returns {string} - Coordinate "x,y" del punto C
67
+ */
68
+ export function calcolaPuntoInterno({ angoloDeg, centroSx, rSx, centroDx, rDx, mainCenter, centerGap }) {
69
+
70
+ // nella documentazione:
71
+ // mainRadius corrisponde a rA
72
+ // mainCenter corrisponde al punto A (centro della circonferenza a)
73
+ // centerGap corrisponde a d
74
+ // scaleEndThickness corrisponde a s
75
+
76
+ let phi, r, center;
77
+
78
+ if(isCircleDx(angoloDeg)) {
79
+ center = centroDx;
80
+ r = rDx; // raggio rB
81
+ phi = 330;
82
+
83
+ } else {
84
+ center = centroSx;
85
+ r = rSx; // raggio rC
86
+ phi = 210;
87
+ }
88
+
89
+ // Differenza angoli e conversione in radianti
90
+ const delta = toRadians(angoloDeg) - toRadians(phi);
91
+
92
+ // rho1 = ipotenusa del triangolo rettangolo in centroDx o centroSx
93
+ // rho2 = ipotenusa per coseno angolo adiacente al cateto rho2
94
+ // vedi documentazione
95
+ const rho =
96
+ Math.sqrt(Math.pow(r, 2) - Math.pow(centerGap * Math.sin(delta), 2)) + // rho1
97
+ centerGap * Math.cos(delta); // rho2
98
+
99
+
100
+ return polarToCartesianString(angoloDeg, center.x, center.y, rho);
101
+
102
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@massimo-cassandro/minimo",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Light css framework & utilities",
5
5
  "type": "module",
6
6
  "homepage": "https://github.com/massimo-cassandro/minimo#readme",
@@ -38,7 +38,8 @@
38
38
  "src/**/*.{js,mjs,css,svg,md}",
39
39
  "design-tokens/**/*.{tokens.json,tokens.jsonc}",
40
40
  "design-tokens-src/**/*.{tokens.json,tokens.jsonc,mjs,js,md}",
41
- "design-tokens-utilities/**/*.{mjs,md}"
41
+ "design-tokens-utilities/**/*.{mjs,md}",
42
+ "charts/**/*.{js,md}"
42
43
  ],
43
44
  "devDependencies": {
44
45
  "@babel/core": "^7.29.0",