Skip to content

Commit da36153

Browse files
committed
first try drawing on frames
1 parent ec56e40 commit da36153

File tree

2 files changed

+115
-1
lines changed

2 files changed

+115
-1
lines changed

src/timeline/js/directives/ruler.js

+104-1
Original file line numberDiff line numberDiff line change
@@ -160,16 +160,119 @@ App.directive("tlRuler", function ($timeout) {
160160
}
161161
});
162162

163+
/*function drawTimesSeconds() {
164+
ruler = $("#ruler");
165+
ruler.addClass('no_bg')
166+
width = $("body").width();
167+
// Clear all current tick marks
168+
$("#ruler span").remove();
169+
start = Math.max(0, ruler.left - width);
170+
end = ruler.left + (2 * width);
171+
172+
// time = Math.floor(start);
173+
time = Math.floor(start / (scope.project.fps.num / scope.project.fps.den));
174+
while (time <= end) {
175+
console.log("TIME: " + time);
176+
console.log("start: " + start);
177+
console.log("end: " + end);
178+
pos = time * scope.project.pixelsPerSecond;
179+
180+
ruler_mark = $('<span style="left: ' + pos + 'px;">');
181+
ruler_mark.addClass("tick_mark");
182+
time_display = $('<span style="left: ' + pos + 'px;">');
183+
time_display.addClass("ruler_time");
184+
185+
var text_time = secondsToTime(time, scope.project.fps.num, scope.project.fps.den);
186+
time_display[0].innerText = text_time["hour"] + ":" + text_time["min"] + ":" + text_time["sec"];
187+
if (scope.project.scale < 1) {
188+
time_display[0].innerText += ',' + text_time['frame'];
189+
}
190+
191+
ruler.append(ruler_mark);
192+
ruler.append(time_display);
193+
time += 1;
194+
}
195+
196+
}*/
197+
198+
function drawTimesHighZoom() {
199+
zoomLevels = [
200+
{
201+
// Mark every 10 frames
202+
'zoom': 0.2724177071509648 ,
203+
'mark_every' : 10
204+
},
205+
{
206+
// Mark every 10 frames
207+
'zoom' : 0.1743473325766175,
208+
'mark_every' : 5
209+
},
210+
] ;
211+
212+
ruler = $("#ruler");
213+
ruler.addClass('no_bg')
214+
width = $("body").width();
215+
// Clear all current tick marks
216+
$("#ruler span").remove();
217+
218+
start = Math.max(0, scope.scrollLeft - width);
219+
end = scope.scrollLeft + (2 * width);
220+
221+
console.log("SCALE: " + scope.project.scale);
222+
console.log("start: " + start);
223+
console.log("end: " + end);
224+
225+
226+
let tall = false;
227+
// frame = start;
228+
time = start / (scope.project.fps.num / scope.project.fps.den);
229+
pos = Math.floor(time * scope.pixelsPerSecond);
230+
while (pos < end) {
231+
// for (var i = 1; i < 100; i++) {
232+
ruler_mark = $('<span style="left: ' + pos + 'px;">');
233+
ruler_mark.addClass("tick_mark");
234+
time_display = $('<span style="left: ' + pos + 'px;">');
235+
time_display.addClass("ruler_time");
236+
237+
if (tall) {
238+
ruler_mark.css("height", 14);
239+
tall = false
240+
} else {
241+
tall = true;
242+
}
243+
244+
/* Calculate Time */
245+
var text_time = secondsToTime(time, scope.project.fps.num, scope.project.fps.den);
246+
time_display[0].innerText = text_time["hour"] + ":" + text_time["min"] + ":" + text_time["sec"];
247+
if (scope.project.scale < 1) {
248+
time_display[0].innerText += ',' + text_time['frame'];
249+
}
250+
251+
ruler.append(ruler_mark);
252+
ruler.append(time_display);
253+
254+
frame += (scope.project.fps.num / scope.project.fps.den)
255+
time = start / (scope.project.fps.num / scope.project.fps.den);
256+
pos = Math.floor(time * scope.pixelsPerSecond);
257+
}
258+
return;
259+
}
260+
163261
drawTimes = () => {
262+
// if (scope.project.scale < 0.340522133938706) {
263+
if (true) {
264+
drawTimesHighZoom();
265+
return;
266+
}
164267
ruler = $("#ruler");
268+
if (ruler[0].className.includes('no_bg')) { ruler.removeClass('no_bg') }
165269
width = $("body").width();
166270
$("#ruler span").remove();
167271
start = Math.max(scope.scrollLeft - width, 100);
168272
end = Math.min(scope.scrollLeft + (2*width), $('#ruler').width());
169273

170274
scale = scope.project.scale;
171275

172-
173276
for (var i = start - (start % 100) ; i < end; i += 100) {
174277
/* create and format span */
175278
s = $('<span style="left: ' + i + 'px;">');

src/timeline/media/css/main.css

+11
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,17 @@ img {
5555
background-image: url(../images/ruler-tick.svg);
5656
background-position: -50px;
5757
}
58+
#ruler.no_bg {
59+
background-image: none;
60+
}
61+
.tick_mark {
62+
position: absolute;
63+
height: 14px;
64+
width : 1px;
65+
bottom: 3px;
66+
background-color: #acacac;
67+
background-position: -50px;
68+
}
5869
.ruler_time {
5970
color: #c8c8c8;
6071
top: 6px;

0 commit comments

Comments
 (0)