This repository was archived by the owner on Dec 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathThreadPoint.js
More file actions
60 lines (40 loc) · 1.27 KB
/
ThreadPoint.js
File metadata and controls
60 lines (40 loc) · 1.27 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
define(['ofio/ofio', 'ofio/ofio.model', 'ofio/ofio.cache', 'vendor/underscore'], function(Ofio){
var ThreadPoint = new Ofio({
modules : arguments
});
ThreadPoint.prototype.attributes = function(){
this.thread = null;
this.point = null;
this.n = null;
};
ThreadPoint.prototype.init = function(){
this.point.on('change:value', this.reset_cache.bind(this));
};
ThreadPoint.prototype.reset_cache = function(){
this.x.reset_cache();
this.y.reset_cache();
this.back_x.reset_cache();
this.back_y.reset_cache();
this.front_x.reset_cache();
this.front_y.reset_cache();
};
ThreadPoint.prototype.x = function(){
return Math.round((this.n - this.thread.start_point()) * this.thread.step_width());
}.cache();
ThreadPoint.prototype.y = function(){
return Math.round(this.thread.height() - this.point.value + 10);
}.cache();
ThreadPoint.prototype.back_x = function(){
return this.x() - this.thread.bezier_width;
}.cache();
ThreadPoint.prototype.back_y = function(){
return this.y();
}.cache();
ThreadPoint.prototype.front_x = function(){
return this.x() + this.thread.bezier_width;
}.cache();
ThreadPoint.prototype.front_y = function(){
return this.y();
}.cache();
return ThreadPoint;
});