forked from rufuspollock-okfn/bubbletree
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathline.js
40 lines (34 loc) · 1.08 KB
/
line.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
/*jshint undef: true, browser:true, jquery: true, devel: true */
/*global Raphael, TWEEN, BubbleTree */
/*
* represents a radial line
*/
BubbleTree.Line = function(bc, attr, origin, angle, fromRad, toRad) {
this.bc = bc;
this.o = origin;
this.angle = angle;
this.fromRad = fromRad;
this.attr = attr;
this.toRad = toRad;
this.getXY = function() {
this.x1 = this.o.x + Math.cos(this.angle) * this.fromRad;
this.y1 = this.o.y -Math.sin(this.angle) * this.fromRad;
this.x2 = this.o.x + Math.cos(this.angle) * this.toRad;
this.y2 = this.o.y -Math.sin(this.angle) * this.toRad;
};
this.init = function() {
this.getXY();
console.log("foo", "M"+this.x1+" "+this.y1+"L"+this.x2+" "+this.y2, attr);
this.path = this.bc.paper.path(
"M"+this.x1+" "+this.y1+"L"+this.x2+" "+this.y2
).attr(this.attr);
};
this.draw = function() {
//console.log('line.draw()', this.angle, this.fromRad, this.toRad);
//console.log(this.x1, this);
this.getXY();
//console.log(this.x1);
this.path.attr({ path: "M"+this.x1+" "+this.y1+"L"+this.x2+" "+this.y2 });
};
this.init();
};