aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/RDGE
diff options
context:
space:
mode:
Diffstat (limited to 'js/helper-classes/RDGE')
-rw-r--r--js/helper-classes/RDGE/GLBrushStroke.js1
-rw-r--r--js/helper-classes/RDGE/GLSubpath.js39
2 files changed, 36 insertions, 4 deletions
diff --git a/js/helper-classes/RDGE/GLBrushStroke.js b/js/helper-classes/RDGE/GLBrushStroke.js
index 89292ad8..f9ed6619 100644
--- a/js/helper-classes/RDGE/GLBrushStroke.js
+++ b/js/helper-classes/RDGE/GLBrushStroke.js
@@ -6,7 +6,6 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
6 6
7var VecUtils = require("js/helper-classes/3D/vec-utils").VecUtils; 7var VecUtils = require("js/helper-classes/3D/vec-utils").VecUtils;
8 8
9
10/////////////////////////////////////////////////////////////////////// 9///////////////////////////////////////////////////////////////////////
11// Class GLBrushStroke 10// Class GLBrushStroke
12// representation a sequence points (polyline) created by brush tool. 11// representation a sequence points (polyline) created by brush tool.
diff --git a/js/helper-classes/RDGE/GLSubpath.js b/js/helper-classes/RDGE/GLSubpath.js
index 25b12093..79940e06 100644
--- a/js/helper-classes/RDGE/GLSubpath.js
+++ b/js/helper-classes/RDGE/GLSubpath.js
@@ -155,6 +155,32 @@ function GLSubpath() {
155 return retAnchor; 155 return retAnchor;
156 } 156 }
157 157
158 this.deselectAnchorPoint = function(){
159 this._selectedAnchorIndex = -1;
160 }
161
162 this.reversePath = function() {
163 var revAnchors = [];
164 var numAnchors = this._Anchors.length;
165 var lastIndex = numAnchors-1;
166 if (lastIndex<0){
167 return; //cannot reverse empty path
168 }
169 for (var i=lastIndex;i>=0;i--) {
170 var newAnchor = new GLAnchorPoint();
171 var oldAnchor = this._Anchors[i];
172 newAnchor.setPos(oldAnchor.getPosX(),oldAnchor.getPosY(),oldAnchor.getPosZ());
173 newAnchor.setPrevPos(oldAnchor.getNextX(),oldAnchor.getNextY(),oldAnchor.getNextZ());
174 newAnchor.setNextPos(oldAnchor.getPrevX(),oldAnchor.getPrevY(),oldAnchor.getPrevZ());
175 revAnchors.push(newAnchor);
176 }
177 if (this._selectedAnchorIndex >= 0){
178 this._selectedAnchorIndex = (numAnchors-1) - this._selectedAnchorIndex;
179 }
180 this._Anchors = revAnchors;
181 this._dirty=true;
182 }
183
158 //remove all the anchor points 184 //remove all the anchor points
159 this.clearAllAnchors = function () { 185 this.clearAllAnchors = function () {
160 this._Anchors = []; 186 this._Anchors = [];
@@ -220,7 +246,10 @@ function GLSubpath() {
220 //check whether the point is within the radius distance from the curve represented as a polyline in _samples 246 //check whether the point is within the radius distance from the curve represented as a polyline in _samples
221 //return the parametric distance along the curve if there is an intersection, else return null 247 //return the parametric distance along the curve if there is an intersection, else return null
222 //will assume that the BBox test is performed outside this function 248 //will assume that the BBox test is performed outside this function
223 249 if (endIndex<startIndex){
250 //go from startIndex to the end of the samples
251 endIndex = this._samples.length/3;
252 }
224 for (var i=startIndex; i<endIndex; i++){ 253 for (var i=startIndex; i<endIndex; i++){
225 var seg0 = Vector.create([this._samples[3*i], this._samples[3*i + 1], this._samples[3*i + 2]]); 254 var seg0 = Vector.create([this._samples[3*i], this._samples[3*i + 1], this._samples[3*i + 2]]);
226 var j=i+1; 255 var j=i+1;
@@ -386,6 +415,7 @@ function GLSubpath() {
386 if (this._isWithinBoundingBox(point, controlPoints, radius)) { 415 if (this._isWithinBoundingBox(point, controlPoints, radius)) {
387 //var intersectParam = this._checkIntersection(controlPoints, 0.0, 1.0, point, radius); 416 //var intersectParam = this._checkIntersection(controlPoints, 0.0, 1.0, point, radius);
388 var intersectParam = this._checkIntersectionWithSamples(this._anchorSampleIndex[i], this._anchorSampleIndex[nextIndex], point, radius); 417 var intersectParam = this._checkIntersectionWithSamples(this._anchorSampleIndex[i], this._anchorSampleIndex[nextIndex], point, radius);
418 console.log("intersectParam:"+intersectParam);
389 if (intersectParam){ 419 if (intersectParam){
390 retCode = retCode | this.SEL_PATH; 420 retCode = retCode | this.SEL_PATH;
391 retParam = intersectParam-i; //make the retParam go from 0 to 1 421 retParam = intersectParam-i; //make the retParam go from 0 to 1
@@ -1137,6 +1167,7 @@ function GLSubpath() {
1137 this.buildBuffers = function () { 1167 this.buildBuffers = function () {
1138 if (this._useCanvasDrawing) 1168 if (this._useCanvasDrawing)
1139 return; 1169 return;
1170
1140 // get the world 1171 // get the world
1141 var world = this.getWorld(); 1172 var world = this.getWorld();
1142 if (!world) throw ("null world in GLSubpath buildBuffers"); 1173 if (!world) throw ("null world in GLSubpath buildBuffers");
@@ -1368,7 +1399,7 @@ function GLSubpath() {
1368 ctx.strokeStyle = "black"; 1399 ctx.strokeStyle = "black";
1369 if (this._strokeColor) 1400 if (this._strokeColor)
1370 ctx.strokeStyle = MathUtils.colorToHex( this._strokeColor ); 1401 ctx.strokeStyle = MathUtils.colorToHex( this._strokeColor );
1371 ctx.fillStyle = "blue"; 1402 ctx.fillStyle = "white";
1372 if (this._fillColor) 1403 if (this._fillColor)
1373 ctx.fillStyle = MathUtils.colorToHex( this._fillColor ); 1404 ctx.fillStyle = MathUtils.colorToHex( this._fillColor );
1374 var lineCap = ['butt','round','square']; 1405 var lineCap = ['butt','round','square'];
@@ -1387,7 +1418,9 @@ function GLSubpath() {
1387 prevAnchor = currAnchor; 1418 prevAnchor = currAnchor;
1388 } 1419 }
1389 ctx.stroke(); 1420 ctx.stroke();
1390 //ctx.fill(); 1421 if (this._isClosed){
1422 ctx.fill();
1423 }
1391 1424
1392 1425
1393 1426