diff options
-rwxr-xr-x | js/lib/drawing/world.js | 6 | ||||
-rwxr-xr-x | js/lib/geom/brush-stroke.js | 2 | ||||
-rwxr-xr-x | js/lib/geom/geom-obj.js | 852 | ||||
-rwxr-xr-x | js/lib/geom/rectangle.js | 15 | ||||
-rwxr-xr-x | js/lib/geom/sub-path.js | 2 | ||||
-rwxr-xr-x | js/tools/LineTool.js | 2 | ||||
-rwxr-xr-x | js/tools/OvalTool.js | 2 | ||||
-rwxr-xr-x | js/tools/RectTool.js | 2 |
8 files changed, 471 insertions, 412 deletions
diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js index 7ce23921..0dde9af4 100755 --- a/js/lib/drawing/world.js +++ b/js/lib/drawing/world.js | |||
@@ -874,17 +874,17 @@ World.prototype.importObjectJSON = function( jObj, parentGeomObj ) | |||
874 | switch (type) | 874 | switch (type) |
875 | { | 875 | { |
876 | case 1: | 876 | case 1: |
877 | obj = new Rectangle(); | 877 | obj = Object.create(Rectangle, {}); |
878 | obj.importJSON( jObj ); | 878 | obj.importJSON( jObj ); |
879 | break; | 879 | break; |
880 | 880 | ||
881 | case 2: // circle | 881 | case 2: // circle |
882 | obj = new Circle(); | 882 | obj = Object.create(Circle, {}); |
883 | obj.importJSON( jObj ); | 883 | obj.importJSON( jObj ); |
884 | break; | 884 | break; |
885 | 885 | ||
886 | case 3: // line | 886 | case 3: // line |
887 | obj = new Line(); | 887 | obj = Object.create(Line, {}); |
888 | obj.importJSON( jObj ); | 888 | obj.importJSON( jObj ); |
889 | break; | 889 | break; |
890 | 890 | ||
diff --git a/js/lib/geom/brush-stroke.js b/js/lib/geom/brush-stroke.js index 1fae0c1d..6facdd5d 100755 --- a/js/lib/geom/brush-stroke.js +++ b/js/lib/geom/brush-stroke.js | |||
@@ -768,7 +768,7 @@ var BrushStroke = function GLBrushStroke() { | |||
768 | 768 | ||
769 | }; //function BrushStroke ...class definition | 769 | }; //function BrushStroke ...class definition |
770 | 770 | ||
771 | BrushStroke.prototype = new GeomObj(); | 771 | BrushStroke.prototype = Object.create(GeomObj, {}); |
772 | 772 | ||
773 | BrushStroke.prototype._CatmullRomSplineInterpolate = function(ctrlPts, t) | 773 | BrushStroke.prototype._CatmullRomSplineInterpolate = function(ctrlPts, t) |
774 | { | 774 | { |
diff --git a/js/lib/geom/geom-obj.js b/js/lib/geom/geom-obj.js index 7cb9b80f..4cb21a25 100755 --- a/js/lib/geom/geom-obj.js +++ b/js/lib/geom/geom-obj.js | |||
@@ -10,184 +10,239 @@ var MaterialsModel = require("js/models/materials-model").MaterialsModel; | |||
10 | // Class GLGeomObj | 10 | // Class GLGeomObj |
11 | // Super class for all geometry classes | 11 | // Super class for all geometry classes |
12 | /////////////////////////////////////////////////////////////////////// | 12 | /////////////////////////////////////////////////////////////////////// |
13 | var GeomObj = function GLGeomObj() { | 13 | exports.GeomObj = Object.create(Object.prototype, { |
14 | /////////////////////////////////////////////////////////////////////// | 14 | /////////////////////////////////////////////////////////////////////// |
15 | // Constants | 15 | // Constants |
16 | /////////////////////////////////////////////////////////////////////// | 16 | /////////////////////////////////////////////////////////////////////// |
17 | this.GEOM_TYPE_RECTANGLE = 1; | 17 | // TODO - Is there a way to make these static constants? |
18 | this.GEOM_TYPE_CIRCLE = 2; | 18 | GEOM_TYPE_RECTANGLE: { value : 1, writable: false }, |
19 | this.GEOM_TYPE_LINE = 3; | 19 | GEOM_TYPE_CIRCLE: { value : 2, writable: false }, |
20 | this.GEOM_TYPE_PATH = 4; | 20 | GEOM_TYPE_LINE: { value : 3, writable: false }, |
21 | this.GEOM_TYPE_CUBIC_BEZIER = 5; | 21 | GEOM_TYPE_PATH: { value : 4, writable: false }, |
22 | this.GEOM_TYPE_BRUSH_STROKE = 6; | 22 | GEOM_TYPE_CUBIC_BEZIER: { value : 5, writable: false }, |
23 | this.GEOM_TYPE_UNDEFINED = -1; | 23 | GEOM_TYPE_BRUSH_STROKE: { value : 6, writable: false }, |
24 | 24 | GEOM_TYPE_UNDEFINED: { value : -1, writable: false }, | |
25 | // Needed for calculating dashed/dotted strokes | ||
26 | this.DASH_LENGTH = 0.15; | ||
27 | this.DOT_LENGTH = 0.05; | ||
28 | this.GAP_LENGTH = 0.05; | ||
29 | 25 | ||
30 | /////////////////////////////////////////////////////////////////////// | 26 | /////////////////////////////////////////////////////////////////////// |
31 | // Instance variables | 27 | // Instance variables |
32 | /////////////////////////////////////////////////////////////////////// | 28 | /////////////////////////////////////////////////////////////////////// |
33 | this._matrix = Matrix.I(4); | 29 | _matrix: { value : Matrix.I(4), writable: true }, |
34 | 30 | ||
35 | this._next = undefined; | 31 | _next: { value : undefined, writable: true }, |
36 | this._prev = undefined; | 32 | _prev: { value : undefined, writable: true }, |
37 | this._child = undefined; | 33 | _child: { value : undefined, writable: true }, |
38 | this._parent = undefined; | 34 | _parent: { value : undefined, writable: true }, |
39 | 35 | ||
40 | this.m_world = null; | 36 | m_world: { value : null, writable: true }, |
41 | 37 | ||
42 | // stroke and fill colors | 38 | // stroke and fill colors |
43 | this._strokeColor = [0, 0, 0, 0]; | 39 | _strokeColor: { value : [0, 0, 0, 0], writable: true }, |
44 | this._fillColor = [0, 0, 0, 0]; | 40 | _fillColor: { value : [0, 0, 0, 0], writable: true }, |
45 | 41 | ||
46 | // stroke and fill materials | 42 | // stroke and fill materials |
47 | this._fillMaterial = null; | 43 | _fillMaterial: { value : null, writable: true }, |
48 | this._strokeMaterial = null; | 44 | _strokeMaterial: { value : null, writable: true }, |
49 | 45 | ||
50 | // Shapes (such as lines) that don't support fill should set this to false | 46 | // Shapes (such as lines) that don't support fill should set this to false |
51 | this.canFill = true; | 47 | canFill: { value : true, writable: true }, |
52 | 48 | ||
53 | // array of primitives - used in RDGE | 49 | // array of primitives - used in RDGE |
54 | this._primArray = []; | 50 | _primArray: { value : [], writable: true }, |
55 | this._materialNodeArray = []; | 51 | _materialNodeArray: { value : [], writable: true }, |
56 | this._materialArray = []; | 52 | _materialArray: { value : [], writable: true }, |
57 | this._materialTypeArray = []; | 53 | _materialTypeArray: { value : [], writable: true }, |
58 | 54 | ||
59 | // the transform node used by RDGE | 55 | // the transform node used by RDGE |
60 | this._trNode = null; | 56 | _trNode: { value : null, writable: true }, |
61 | 57 | ||
62 | /////////////////////////////////////////////////////////////////////// | 58 | /////////////////////////////////////////////////////////////////////// |
63 | // Property accessors | 59 | // Property accessors |
64 | /////////////////////////////////////////////////////////////////////// | 60 | /////////////////////////////////////////////////////////////////////// |
65 | this.setWorld = function (world) { | 61 | getWorld: { |
66 | this.m_world = world; | 62 | value: function() { |
67 | }; | 63 | return this.m_world; |
64 | } | ||
65 | }, | ||
68 | 66 | ||
69 | this.getWorld = function () { | 67 | setWorld: { |
70 | return this.m_world; | 68 | value: function(world) { |
71 | }; | 69 | this.m_world = world; |
70 | } | ||
71 | }, | ||
72 | 72 | ||
73 | this.getMatrix = function () { | 73 | getMatrix: { |
74 | return this._matrix.slice(0); | 74 | value: function() { |
75 | }; | 75 | return this._matrix.slice(0); |
76 | } | ||
77 | }, | ||
76 | 78 | ||
77 | this.setMatrix = function (m) { | 79 | setMatrix: { |
78 | this._matrix = m.slice(0); | 80 | value: function(m) { |
79 | }; | 81 | this._matrix = m.slice(0); |
82 | } | ||
83 | }, | ||
80 | 84 | ||
81 | this.setNext = function (next) { | 85 | getNext: { |
82 | this._next = next; | 86 | value: function() { |
83 | }; | 87 | return this._next; |
88 | } | ||
89 | }, | ||
84 | 90 | ||
85 | this.getNext = function () { | 91 | setNext: { |
86 | return this._next; | 92 | value: function(next) { |
87 | }; | 93 | this._next = next; |
94 | } | ||
95 | }, | ||
88 | 96 | ||
89 | this.setPrev = function (prev) { | 97 | getPrev: { |
90 | this._prev = prev; | 98 | value: function() { |
91 | }; | 99 | return this._prev; |
100 | } | ||
101 | }, | ||
92 | 102 | ||
93 | this.getPrev = function () { | 103 | setPrev: { |
94 | return this._prev; | 104 | value: function(prev) { |
95 | }; | 105 | this._prev = prev; |
106 | } | ||
107 | }, | ||
96 | 108 | ||
97 | this.setChild = function (child) { | 109 | getChild: { |
98 | this._child = child; | 110 | value: function() { |
99 | }; | 111 | return this._child; |
112 | } | ||
113 | }, | ||
100 | 114 | ||
101 | this.getChild = function () { | 115 | setChild: { |
102 | return this._child; | 116 | value: function(child) { |
103 | }; | 117 | this._child = child; |
118 | } | ||
119 | }, | ||
104 | 120 | ||
105 | this.setParent = function (parent) { | 121 | getParent: { |
106 | this._parent = parent; | 122 | value: function() { |
107 | }; | 123 | return this._parent; |
124 | } | ||
125 | }, | ||
108 | 126 | ||
109 | this.getParent = function () { | 127 | setParent: { |
110 | return this._parent; | 128 | value: function(parent) { |
111 | }; | 129 | this._parent = parent; |
130 | } | ||
131 | }, | ||
112 | 132 | ||
113 | this.geomType = function () { | 133 | geomType: { |
114 | return this.GEOM_TYPE_UNDEFINED; | 134 | value: function() { |
115 | }; | 135 | return this.GEOM_TYPE_UNDEFINED; |