aboutsummaryrefslogtreecommitdiff
path: root/js/lib/geom/line.js
diff options
context:
space:
mode:
authorPushkar Joshi2012-05-22 13:22:26 -0700
committerPushkar Joshi2012-05-22 13:22:26 -0700
commit01dbc1f329a95bc7e3b93224543d88ad5bdbd315 (patch)
treeceb527713554f506c537168e36a10452cd09ad10 /js/lib/geom/line.js
parentb9262c831952e77135b79c2de7c455d5e7ff0589 (diff)
parentc37a876b373ddc7cb19277aaeaa6bb2d2d5a50ac (diff)
downloadninja-01dbc1f329a95bc7e3b93224543d88ad5bdbd315.tar.gz
Merge branch 'master' into brushtool
Diffstat (limited to 'js/lib/geom/line.js')
-rwxr-xr-xjs/lib/geom/line.js914
1 files changed, 456 insertions, 458 deletions
diff --git a/js/lib/geom/line.js b/js/lib/geom/line.js
index bb198d83..3c811698 100755
--- a/js/lib/geom/line.js
+++ b/js/lib/geom/line.js
@@ -12,500 +12,498 @@ var MaterialsModel = require("js/models/materials-model").MaterialsModel;
12// GL representation of a line. 12// GL representation of a line.
13// Derived from class GeomObj 13// Derived from class GeomObj
14/////////////////////////////////////////////////////////////////////// 14///////////////////////////////////////////////////////////////////////
15var Line = function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, strokeColor, strokeMaterial, strokeStyle, xAdj, yAdj) { 15exports.Line = Object.create(GeomObj, {
16 /////////////////////////////////////////////////////////////////////// 16 ///////////////////////////////////////////////////////////////////////
17 // Instance variables 17 // Instance variables
18 /////////////////////////////////////////////////////////////////////// 18 ///////////////////////////////////////////////////////////////////////
19 this._width = 2.0; 19 _width: { value : 2.0, writable: true },
20 this._height = 2.0; 20 _height: { value : 2.0, writable: true },
21 this._xOffset = 0; 21 _xOffset: { value : 0, writable: true },
22 this._yOffset = 0; 22 _yOffset: { value : 0, writable: true },
23 23
24 // If line doesn't fit in canvas world, we had to grow the canvas by this much on either side 24 // If line doesn't fit in canvas world, we had to grow the canvas by this much on either side
25 this._xAdj = 0; 25 _xAdj: { value : 0, writable: true },
26 this._yAdj = 0; 26 _yAdj: { value : 0, writable: true },
27
28 this._slope = 0;
29 27
30 this._strokeWidth = 0.25; 28 _slope: { value : 0, writable: true },
31 29
32 this._strokeStyle = "Solid"; 30 _strokeWidth: { value : 0.25, writable: true },
33 this._scaleX = 1.0; 31 _strokeStyle: { value : "Solid", writable: true },
34 this._scaleY = 1.0;
35 32
36 this.canFill = false; 33 _scaleX: { value : 1.0, writable: true },
34 _scaleY: { value : 1.0, writable: true },
37 35
38 if (arguments.length > 0) { 36 canFill: { value : false, writable: false },
39 this._width = width;
40 this._height = height;
41 this._xOffset = xOffset;
42 this._yOffset = yOffset;
43 37
44 this._xAdj = xAdj; 38 init: {
45 this._yAdj = yAdj; 39 value: function(world, xOffset, yOffset, width, height, slope, strokeSize, strokeColor, strokeMaterial, strokeStyle, xAdj, yAdj) {
40 if (arguments.length > 0) {
41 this._width = width;
42 this._height = height;
43 this._xOffset = xOffset;
44 this._yOffset = yOffset;
46 45
47 this._slope = slope; 46 this._xAdj = xAdj;
48 this._strokeWidth = strokeSize; 47 this._yAdj = yAdj;
49 this._strokeColor = strokeColor;
50 48
51 this._strokeStyle = strokeStyle; 49 this._slope = slope;
52 this._scaleX = (world.getViewportWidth())/(world.getViewportHeight()); 50 this._strokeWidth = strokeSize;
53 } 51 this._strokeColor = strokeColor;
54 52
55 this._strokeVerticesLen = 0; 53 this._strokeStyle = strokeStyle;
54 this._scaleX = (world.getViewportWidth())/(world.getViewportHeight());
55 }
56 56
57 this.m_world = world; 57 this._strokeVerticesLen = 0;
58 58
59 this._materialAmbient = [0.2, 0.2, 0.2, 1.0]; 59 this.m_world = world;
60 this._materialDiffuse = [0.4, 0.4, 0.4, 1.0];
61 this._materialSpecular = [0.4, 0.4, 0.4, 1.0];
62 60
63 if(strokeMaterial) { 61 this._materialAmbient = [0.2, 0.2, 0.2, 1.0];
64 this._strokeMaterial = strokeMaterial; 62 this._materialDiffuse = [0.4, 0.4, 0.4, 1.0];
65 } 63 this._materialSpecular = [0.4, 0.4, 0.4, 1.0];
66 64
67 /////////////////////////////////////////////////////////////////////// 65 if(strokeMaterial) {
68 // Property Accessors 66 this._strokeMaterial = strokeMaterial;
69 /////////////////////////////////////////////////////////////////////// 67 }
70 this.getStrokeWidth = function() { return this._strokeWidth; } 68 }
71 this.setStrokeWidth = function(w) { this._strokeWidth = w; } 69 },
70
71 ////////////////////////////////////////////////////////////////////////
72 // Property Accessors
73 ///////////////////////////////////////////////////////////////////////
74 // TODO - Use getters/setters in the future
75 getStrokeWidth: {
76 value: function() {
77 return this._strokeWidth;
78 }
79 },
80
81 setStrokeWidth: {
82 value: function(w) {
83 this._strokeWidth = w;
84 }
85 },
86
87 getStrokeMaterial: {
88 value: function() {
89 return this._strokeMaterial;
90 }
91 },
92
93 setStrokeMaterial: {
94 value: function(m) {
95 this._strokeMaterial = m;
96 }
97 },
72 98
73 this.getStrokeMaterial = function() { return this._strokeMaterial; } 99 getFillMaterial: {
74 this.setStrokeMaterial = function(m) { this._strokeMaterial = m; } 100 value: function() {
101 return null;
102 }
103 },
75 104
76 this.getStrokeColor = function() { return this._strokeColor; } 105 getStrokeColor: {
77 //this.setStrokeColor = function(c) { this._strokeColor = c; } 106 value: function() {
107 return this._strokeColor;
108 }
109 },
78 110
79 this.getStrokeStyle = function() { return this._strokeStyle; } 111// setStrokeColor: {
80 this.setStrokeStyle = function(s) { this._strokeStyle = s; } 112// value: function(c) {
113// this._strokeColor = c;
114// }
115// },
81 116
82 this.getFillMaterial = function() { return null; } 117 getStrokeStyle: {
83 118 value: function() {
84 this.setStrokeMaterial = function(m) { this._strokeMaterial = m; } 119 return this._strokeStyle;
85 this.getStrokeMaterial = function() { return this._strokeMaterial; } 120 }
121 },
86 122
87 this.getWidth = function() { return this._width; } 123 setStrokeStyle: {
88 this.setWidth = function(w) { this._width = w; } 124 value: function(s) {
125 this._strokeStyle = s;
126 }
127 },
89 128
90 this.getHeight = function() { return this._height; } 129 getWidth: {
91 this.setHeight = function(h) { this._height = h; } 130 value: function() {
131 return this._width;
132 }
133 },
134
135 setWidth: {
136 value: function(w) {
137 this._width = w;
138 }
139 },
92 140
93 this.getXAdj = function() { return this._xAdj; } 141 getHeight: {
94 this.setXAdj = function(x) { this._xAdj = x; } 142 value: function() {
143 return this._height;
144 }
145 },
95 146
96 this.getYAdj = function() { return this._yAdj; } 147 setHeight: {
97 this.setYAdj = function(y) { this._yAdj = y; } 148 value: function(h) {
149 this._height = h;
150 }
151 },
98 152
99 this.getSlope = function() { return this._slope; } 153 getXAdj: {
100 this.setSlope = function(m) { this._slope = m; } 154 value: function() {
155 return this._xAdj;
156 }
157 },
101 158
102 this.geomType = function() { return this.GEOM_TYPE_LINE; } 159 setXAdj: {
160 value: function(x) {
161 this._xAdj = x;
162 }
163 },
103 164
104 /////////////////////////////////////////////////////////////////////// 165 getYAdj: {
105 // Methods 166 value: function() {
106 /////////////////////////////////////////////////////////////////////// 167 return this._yAdj;
107 this.exportJSON = function()
108 {
109 var jObj =
110 {
111 'type' : this.geomType(),
112 'xoff' : this._xOffset,
113 'yoff' : this._yOffset,
114 'width' : this._width,
115 'height' : this._height,
116 'xAdj' : this._xAdj,
117 'yAdj' : this._yAdj,
118 'slope' : this._slope,
119 'strokeWidth' : this._strokeWidth,
120 'strokeColor' : this._strokeColor,
121 'strokeStyle' : this._strokeStyle,
122 'strokeMat' : this._strokeMaterial ? this._strokeMaterial.getName() : MaterialsModel.getDefaultMaterialName(),
123 'materials' : this.exportMaterialsJSON()
124 };
125