-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSampleSliderTest-004.html
More file actions
184 lines (164 loc) · 8.69 KB
/
SampleSliderTest-004.html
File metadata and controls
184 lines (164 loc) · 8.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Smooth Element Movement</title>
<style>
@font-face {
font-family: 'TYPETR-Bitcount-VF';
src: url('fonts/ttf/variable/BitcountInk[CRSV,ELSH,ELXP,SZP1,SZP2,XPN1,XPN2,YPN1,YPN2,slnt,wght].ttf') format('truetype');
/* Add other font properties if needed */
}
#text-container {
width: 80%;
margin: 50px auto;
}
#sample-text {
font-family: 'TYPETR-Bitcount-VF', sans-serif;
font-size: 400px;
}
.slider-container {
margin-bottom: 0px;
}
.slider-container label {
display: block;
}
/*body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f0f0f0;
overflow: hidden;
}*/
#movingElement {
position: absolute;
width: 50px;
height: 50px;
background-color: red;
border-radius: 50%;
}
</style>
</head>
<body>
<div id="text-container">
<div id="sample-text">/canvasBitc</div>
</div>
<!--<div id="movingElement"></div>-->
<script>
const positions = [
{ x: 100, y: 100, wght: 400, ELXP: 0, ELSH:0, XPN1: 53, XPN2:50, SZP1:30, SZP2:30, YPN1: 55.5, YPN2: 54.4},
{ x: 150, y: 150, wght: 400, ELXP: 0, ELSH:0, XPN1: 56.2, XPN2:50, SZP1:51.4, SZP2:10.2, YPN1: 50, YPN2: 50},
{ x: 160, y: 160, wght: 400, ELXP: 100 , ELSH:0, XPN1: 56.2, XPN2:50, SZP1:51.4, SZP2:10.2, YPN1: 50, YPN2: 50},
{ x: 200, y: 200, wght: 400, ELXP: 0, ELSH:40, XPN1: 53, XPN2:50, SZP1:30, SZP2:20.9, YPN1: 55.5, YPN2: 54.4},
{ x: 250, y: 250, wght: 400, ELXP: 0, ELSH:0, XPN1: 56.2, XPN2:50, SZP1:51.4, SZP2:10.2, YPN1: 50, YPN2: 56.7},
{ x: 260, y: 260, wght: 400, ELXP: 100, ELSH:0, XPN1: 56.2, XPN2:50, SZP1:51.4, SZP2:10.2, YPN1: 50, YPN2: 56.7},
{ x: 300, y: 300, wght: 400, ELXP: 0, ELSH:45, XPN1: 45, XPN2:55.7, SZP1:50, SZP2:30, YPN1: 57.7, YPN2: 64.8},
{ x: 350, y: 350, wght: 400, ELXP: 0, ELSH:45, XPN1: 45, XPN2:59.9, SZP1:30, SZP2:30, YPN1: 57.7, YPN2: 65.4},
{ x: 400, y: 400, wght: 400, ELXP: 40, ELSH:50, XPN1: 53, XPN2:66.7, SZP1:30, SZP2:20.9, YPN1: 55.4, YPN2: 57.9},
{ x: 450, y: 450, wght: 400, ELXP: 0, ELSH:0, XPN1: 56.2, XPN2:50, SZP1:51.4, SZP2:39.6, YPN1: 34.9, YPN2: 58.1},
{ x: 460, y: 460, wght: 580.8, ELXP: 0, ELSH:3.6, XPN1: 31.1, XPN2:61.8, SZP1:26.9, SZP2:58.6, YPN1: 76.3, YPN2: 65.8},
{ x: 470, y: 470, wght: 600 , ELXP: 100, ELSH:3.6, XPN1: 31.1, XPN2:61.8, SZP1:26.9, SZP2:58.6, YPN1: 75.7, YPN2: 65.8},
{ x: 500, y: 500, wght: 400, ELXP: 20, ELSH:60, XPN1: 53, XPN2:44.8, SZP1:30, SZP2:30.1, YPN1: 59.7, YPN2: 57.9},
{ x: 600, y: 600, wght: 400, ELXP: 0, ELSH:50, XPN1: 53, XPN2:46.6, SZP1:30, SZP2:30.1, YPN1: 57.8, YPN2: 49.2},
{ x: 700, y: 700, wght: 700, ELXP: 0, ELSH:75, XPN1: 58.2, XPN2:50.4, SZP1:30, SZP2:30.1, YPN1: 57.8, YPN2: 49.2},
{ x: 800, y: 800, wght: 635, ELXP: 0, ELSH:100, XPN1: 53, XPN2:39.4, SZP1:30, SZP2:20.9, YPN1: 55.4, YPN2: 37},
{ x: 900, y: 900, wght: 750, ELXP: 0, ELSH:5.4, XPN1: 74.5, XPN2:50.4, SZP1:0, SZP2:7.6, YPN1: 29.5, YPN2: 39.6},
//{ x: 700, y: 300 },
//{ x: 400, y: 400 }
];
var currentIndex = 0;
var nextIndex = 1;
//const element = document.getElementById("movingElement");
const sampleText = document.getElementById('sample-text');
const speed = 1000; // Time in ms for movement
const pauseTime = 1000; // Time to pause at each position
var newwght = positions[0].wght;
var newELSH = positions[0].ELSH;
var newELXP = positions[0].ELXP;
var newSZP1 = positions[0].SZP1;
var newXPN1 = positions[0].XPN1;
var newYPN1 = positions[0].YPN1;
var newSZP2 = positions[0].SZP2;
var newXPN2 = positions[0].XPN2;
var newYPN2 = positions[0].YPN2;
var startwght = positions[0].wght;
var startELSH = positions[0].ELSH;
var startELXP = positions[0].ELXP;
var startSZP1 = positions[0].SZP1;
var startXPN1 = positions[0].XPN1;
var startYPN1 = positions[0].YPN1;
var startSZP2 = positions[0].SZP2;
var startXPN2 = positions[0].XPN2;
var startYPN2 = positions[0].YPN2;
function moveToNextPosition() {
//let startX = parseFloat(element.style.left) || positions[0].x;
//let startY = parseFloat(element.style.top) || positions[0].y;
let targetX = positions[currentIndex].x;
let targetY = positions[currentIndex].y;
let slant = 0;
let startTime = performance.now();
var startwght = positions[currentIndex].wght;
var startELSH = positions[currentIndex].ELSH;
var startELXP = positions[currentIndex].ELXP;
var startSZP1 = positions[currentIndex].SZP1;
var startXPN1 = positions[currentIndex].XPN1;
var startYPN1 = positions[currentIndex].YPN1;
var startSZP2 = positions[currentIndex].SZP2;
var startXPN2 = positions[currentIndex].XPN2;
var startYPN2 = positions[currentIndex].YPN2;
var targetwght = positions[nextIndex].wght;
var targetELSH = positions[nextIndex].ELSH;
var targetELXP = positions[nextIndex].ELXP;
var targetSZP1 = positions[nextIndex].SZP1;
var targetXPN1 = positions[nextIndex].XPN1;
var targetYPN1 = positions[nextIndex].YPN1;
var targetSZP2 = positions[nextIndex].SZP2;
var targetXPN2 = positions[nextIndex].XPN2;
var targetYPN2 = positions[nextIndex].YPN2;
function animate(time) {
let elapsed = time - startTime;
let progress = Math.min(elapsed / speed, 1);
let ease = Math.sin(progress * (Math.PI / 2)); // Smooth acceleration/deceleration
//let newX = startX + (targetX - startX) * ease;
//let newY = startY + (targetY - startY) * ease;
//element.style.left = `${newX}px`;
//element.style.top = `${newY}px`;
newwght = Math.round(startwght + (targetwght - startwght) * ease);
newELSH = Math.round(startELSH + (targetELSH - startELSH) * ease);
newELXP = Math.round(startELXP + (targetELXP - startELXP) * ease);
newSZP1 = Math.round(startSZP1 + (targetSZP1 - startSZP1) * ease);
newXPN1 = Math.round(startXPN1 + (targetXPN1 - startXPN1) * ease);
newYPN1 = Math.round(startYPN1 + (targetYPN1 - startYPN1) * ease);
newSZP2 = Math.round(startSZP2 + (targetSZP2 - startSZP2) * ease);
newXPN2 = Math.round(startXPN2 + (targetXPN2 - startXPN2) * ease);
newYPN2 = Math.round(startYPN2 + (targetYPN2 - startYPN2) * ease);
sampleText.style.fontVariationSettings = `'wght' ${newwght}, 'ELXP' ${newELXP}, 'ELSH' ${newELSH},
'SZP1' ${newSZP1}, 'XPN1' ${newXPN1}, 'YPN1' ${newYPN1},
'SZP2' ${newSZP2}, 'XPN2' ${newXPN2}, 'YPN2' ${newYPN2}`;
//sampleText.style.fontVariationSettings = `'wght' ${weight}, 'ELXP' ${newELXP}, 'ELSH' ${newELSH}, 'slnt' ${slant},
// 'SZP1' ${newSZP1}, 'XPN1' ${newXPN1}, 'YPN1' ${newYPN1},
// 'SZP2' ${newSZP2}, 'XPN2' ${newXPN2}, 'YPN2' ${newYPN2}`;
//sampleText.textContent = '/canvasABC';
if (progress < 1) {
requestAnimationFrame(animate);
} else {
setTimeout(() => {
currentIndex = (currentIndex + 1) % positions.length;
nextIndex = currentIndex + 1;
if (nextIndex >= positions.length)
nextIndex = 0;
moveToNextPosition();
}, pauseTime);
}
}
requestAnimationFrame(animate);
}
// Start the animation
//element.style.left = `${positions[0].x}px`;
//element.style.top = `${positions[0].y}px`;
setTimeout(moveToNextPosition, pauseTime);
</script>
</body>
</html>