-
Notifications
You must be signed in to change notification settings - Fork 0
/
journey.js
53 lines (47 loc) · 1.93 KB
/
journey.js
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
// JOURNEYYYYYYYY
function Journey(dates, min, max){
this.colour = '#000000';
this.from = dates.from;
this.to = dates.to;
this.angles = {};
this.angles.from = degreesToRadians(getPosition(Math.pow(min, 0.6),Math.pow(max, 0.6), Math.pow(dates.from, 0.6)));
this.angles.to = degreesToRadians(getPosition(Math.pow(min, 0.6), Math.pow(max, 0.6), Math.pow(dates.to, 0.6)));
//console.log("jmin", Math.pow(min, 0.6), "jmax", Math.pow(max, 0.6))
this.anglefrom = this.angles.from;
this.angleto = this.angles.to;
// console.log( 'DATES FROM: ' + this.from + 'DATES TO: ' + this.to + ' ANGLES FROM ' + this.angles.from + ' ANGLES TO ' + this.angles.to);
this.positions = {
from: {
point: getLocationOnCircle(centerX, centerY, radius, this.angles.from),
bezier: getLocationOnCircle(centerX, centerY, (radius - 100), this.angles.from)
},
to: {
point: getLocationOnCircle(centerX, centerY, radius, this.angles.to),
bezier: getLocationOnCircle(centerX, centerY, (radius - 100), this.angles.to)
}
};
if(this.positions.from.point.x === this.positions.to.point.x){
if(this.positions.from.point.y === this.positions.to.point.y){
this.still = true;
}
}
};
Journey.prototype.draw = function(context, colour) {
if(this.still){ return; }
context.beginPath();
context.moveTo(this.positions.from.point.x, this.positions.from.point.y);
context.strokeStyle = this.colour;
context.lineWidth = 2;
context.bezierCurveTo(
this.positions.from.bezier.x,
this.positions.from.bezier.y,
this.positions.to.bezier.x,
this.positions.to.bezier.y,
this.positions.to.point.x,
this.positions.to.point.y
);
// context.lineTo(this.positions.to.point.x, this.positions.to.point.y);
// console.log('from: ' + this.positions.from.point.x + ' ' + this.positions.from.point.y + ' to: ' + this.positions.to.point.x + ' ' + this.positions.to.point.y);
context.stroke();
context.closePath();
};