Skip to content

Commit a115675

Browse files
committed
Save primes as they're found
1 parent 4ef7e52 commit a115675

File tree

4 files changed

+30
-61
lines changed

4 files changed

+30
-61
lines changed

src/timeline/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
<!-- RULER NAME (left of screen) -->
4444
<div tl-rulertime id="ruler_label">
45-
<div id="ruler_time">{{playheadTime.hour}}:{{playheadTime.min}}:{{playheadTime.sec}}:{{playheadTime.frame}}</div>
45+
<div id="ruler_time">{{playheadTime.hour}}:{{playheadTime.min}}:{{playheadTime.sec}},{{playheadTime.frame}}</div>
4646
</div>
4747
<!-- RULER (right of screen) -->
4848
<div id="scrolling_ruler">

src/timeline/js/controllers.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ App.controller("TimelineCtrl", function ($scope) {
9393
// Use JQuery to move playhead (for performance reasons) - scope.apply is too expensive here
9494
$(".playhead-top").css("left", ($scope.project.playhead_position * $scope.pixelsPerSecond) + "px");
9595
$(".playhead-line").css("left", ($scope.project.playhead_position * $scope.pixelsPerSecond) + "px");
96-
$("#ruler_time").text($scope.playheadTime.hour + ":" + $scope.playheadTime.min + ":" + $scope.playheadTime.sec + ":" + $scope.playheadTime.frame);
96+
$("#ruler_time").text($scope.playheadTime.hour + ":" + $scope.playheadTime.min + ":" + $scope.playheadTime.sec + "," + $scope.playheadTime.frame);
9797
};
9898

9999
// Move the playhead to a specific frame

src/timeline/js/directives/ruler.js

+17-51
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ App.directive("tlRuler", function ($timeout) {
163163
/**
164164
*
165165
*/
166-
function drawTimesHighZoom() {
166+
function drawTimes() {
167167
// Delete old tick marks
168168
ruler = $('#ruler');
169169
ruler.addClass('no_bg');
@@ -178,27 +178,23 @@ App.directive("tlRuler", function ($timeout) {
178178
time[0] -= time[0]%1;
179179
time[1] -= time[1]%1 - 1;
180180

181+
startFrame = time[0] * Math.round(fps);
182+
endFrame = time[1] * Math.round(fps);
183+
181184
t = time[0];
182185
let tPrev;
183186
showTime = true;
184187

185188
// timePerTick = framesPerTick(scope.pixelsPerSecond, scope.project.fps.num ,scope.project.fps.num) / fps;
186189
// console.log('FPT: ' + framesPerTick(scope.pixelsPerSecond, scope.project.fps.num ,scope.project.fps.num));
187-
dF = 1;
188-
dT = () => { return dF / fps };
189-
dP = () => { return dT() * scope.pixelsPerSecond};
190-
while (dP() < 50) {
191-
dF *= 2;
192-
}
193-
timePerTick = dT();
194190
fpt = framesPerTick(scope.pixelsPerSecond, scope.project.fps.num ,scope.project.fps.den)
195-
timePerTick = fpt / fps;
196-
while (t <= time[1]){
197-
if (Math.floor(t) != Math.floor(tPrev)) {
198-
// In the case that FPS is not a whole number.
199-
// Every new second, make sure we start ON the second.
200-
t = Math.floor(t);
201-
}
191+
frame = startFrame
192+
console.log ("Start: "+ startFrame)
193+
console.log ("End : "+ endFrame)
194+
console.log ("FPT : "+ fpt)
195+
console.log ("start Time : "+ time[0])
196+
while ( frame <= endFrame){
197+
t = frame / fps;
202198
pos = t * scope.pixelsPerSecond;
203199
tickSpan = $('<span style="left:'+pos+'px;"></span>');
204200
tickSpan.addClass("tick_mark");
@@ -209,8 +205,11 @@ App.directive("tlRuler", function ($timeout) {
209205
timeText = secondsToTime(t, scope.project.fps.num, scope.project.fps.den);
210206
timeSpan[0].innerText = timeText['hour'] + ':' +
211207
timeText['min'] + ':' +
212-
timeText['sec'] + ',' +
213-
timeText['frame'];
208+
timeText['sec'];
209+
if (fpt < Math.round(fps)) {
210+
timeSpan[0].innerText += ',' + timeText['frame'];
211+
}
212+
// timeText['frame'];
214213
tickSpan[0].style['height'] = '20px';
215214
showTime = false;
216215
} else {
@@ -219,44 +218,11 @@ App.directive("tlRuler", function ($timeout) {
219218
ruler.append(timeSpan);
220219
ruler.append(tickSpan);
221220

222-
tPrev = t;
223-
t += timePerTick;
221+
frame += fpt;
224222
}
225223
return;
226224
}
227225

228-
drawTimes = () => {
229-
/*scope.project.scale < 0.340522133938706*/
230-
if (scope.project.scale < 1) {
231-
drawTimesHighZoom();
232-
return;
233-
}
234-
ruler = $("#ruler");
235-
if (ruler[0].className.includes('no_bg')) { ruler.removeClass('no_bg') }
236-
width = $("body").width();
237-
$("#ruler span").remove();
238-
start = Math.max(scope.scrollLeft - width, 100);
239-
end = Math.min(scope.scrollLeft + (2*width), $('#ruler').width());
240-
241-
scale = scope.project.scale;
242-
243-
for (var i = start - (start % 100) ; i < end; i += 100) {
244-
/* create and format span */
245-
s = $('<span style="left: ' + i + 'px;">');
246-
s.addClass("ruler_time");
247-
248-
/* Calculate Time */
249-
var time = i / scope.pixelsPerSecond;
250-
var text_time = secondsToTime(time, scope.project.fps.num, scope.project.fps.den);
251-
s[0].innerText= text_time["hour"] + ":" + text_time["min"] + ":" + text_time["sec"];
252-
if (scope.project.scale < 1) {
253-
s[0].innerText += ',' + text_time['frame'];
254-
}
255-
256-
ruler.append(s);
257-
}
258-
}
259-
260226
scope.$watch("project.scale + project.duration + scrollLeft", function (val) {
261227
if (val) {
262228
$timeout(function () {

src/timeline/js/functions.js

+11-8
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ function secondsToTime(secs, fps_num, fps_den) {
166166
var week = Math.floor(day / 7);
167167
day = day % 7;
168168

169-
var frame = Math.round((milli / 1000.0) * (fps_num / fps_den)) + 1;
169+
var frame = Math.floor((milli / 1000.0) * (fps_num / fps_den)) + 1;
170170
return {
171171
"week": padNumber(week, 2),
172172
"day": padNumber(day, 2),
@@ -342,8 +342,11 @@ function primesUpTo(n) {
342342
primes = [...Array(n+1).keys()]; // List from 0 to n
343343
primes = primes.slice(2,primes.length -1); // 0 and 1 divide nothing and everything
344344
primes.forEach( p => {
345-
primes = primes.filter( test => { return (test % p != 0) || (test == p) } );
345+
primes = primes.filter( test => { return (test % p != 0) || (test == p) } );
346346
});
347+
primes.forEach( p => {
348+
global_primes.add(p);
349+
})
347350
return primes;
348351
}
349352

@@ -377,15 +380,15 @@ function primeFactorsOf(n) {
377380
*/
378381
function framesPerTick(pps, fps_num, fps_den) {
379382
fps = fps_num / fps_den;
380-
dF = 1;
381-
dT = () => { return dF / fps };
382-
dP = () => { return dT() * pps };
383+
frames = 1;
384+
seconds = () => { return frames / fps };
385+
pixels = () => { return seconds() * pps };
383386
factors = primeFactorsOf(Math.round(fps));
384-
while (dP() < 50) {
385-
dF *= factors.shift() || 2;
387+
while (pixels() < 35) {
388+
frames *= factors.shift() || 2;
386389
}
387390

388-
return dF;
391+
return frames;
389392
}
390393

391394
/**

0 commit comments

Comments
 (0)