aboutsummaryrefslogtreecommitdiff
path: root/js/lib/geom/sub-path.js
diff options
context:
space:
mode:
authorEric Guzman2012-04-02 15:36:08 -0700
committerEric Guzman2012-04-02 15:36:08 -0700
commit0241bf331b7e06e206a54be441edf2f4c7261f63 (patch)
treeb7e2f9cad73eed4fc616cf1841cd0be02bd955d4 /js/lib/geom/sub-path.js
parentdde5b5054f93db493e5d4d502e677f5781334b08 (diff)
parentc6de22bf42be90b403491b5f87b1818d9020310c (diff)
downloadninja-0241bf331b7e06e206a54be441edf2f4c7261f63.tar.gz
Merge branch 'refs/heads/master' into CSSPanelUpdates
Diffstat (limited to 'js/lib/geom/sub-path.js')
-rwxr-xr-xjs/lib/geom/sub-path.js18
1 files changed, 16 insertions, 2 deletions
diff --git a/js/lib/geom/sub-path.js b/js/lib/geom/sub-path.js
index 017cca92..7046673e 100755
--- a/js/lib/geom/sub-path.js
+++ b/js/lib/geom/sub-path.js
@@ -6,7 +6,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
6 6
7 7
8var VecUtils = require("js/helper-classes/3D/vec-utils").VecUtils; 8var VecUtils = require("js/helper-classes/3D/vec-utils").VecUtils;
9 9var CanvasController = require("js/controllers/elements/canvas-controller").CanvasController;
10var GeomObj = require("js/lib/geom/geom-obj").GeomObj; 10var GeomObj = require("js/lib/geom/geom-obj").GeomObj;
11var AnchorPoint = require("js/lib/geom/anchor-point").AnchorPoint; 11var AnchorPoint = require("js/lib/geom/anchor-point").AnchorPoint;
12var MaterialsModel = require("js/models/materials-model").MaterialsModel; 12var MaterialsModel = require("js/models/materials-model").MaterialsModel;
@@ -61,6 +61,9 @@ var GLSubpath = function GLSubpath() {
61 //whether or not to use the canvas drawing to stroke/fill 61 //whether or not to use the canvas drawing to stroke/fill
62 this._useCanvasDrawing = true; 62 this._useCanvasDrawing = true;
63 63
64 //the canvas that will draw this subpath
65 this._canvas = null;
66
64 //the X and Y location of this subpath's canvas in stage world space of Ninja 67 //the X and Y location of this subpath's canvas in stage world space of Ninja
65 this._canvasX = 0; 68 this._canvasX = 0;
66 this._canvasY = 0; 69 this._canvasY = 0;
@@ -131,6 +134,11 @@ var GLSubpath = function GLSubpath() {
131 var bboxHeight = bboxMax[1] - bboxMin[1]; 134 var bboxHeight = bboxMax[1] - bboxMin[1];
132 var bboxMid = [0.5 * (bboxMax[0] + bboxMin[0]), 0.5 * (bboxMax[1] + bboxMin[1]), 0.5 * (bboxMax[2] + bboxMin[2])]; 135 var bboxMid = [0.5 * (bboxMax[0] + bboxMin[0]), 0.5 * (bboxMax[1] + bboxMin[1]), 0.5 * (bboxMax[2] + bboxMin[2])];
133 136
137 if (this._canvas) {
138 CanvasController.setProperty(this._canvas, "width", bboxWidth+"px");
139 CanvasController.setProperty(this._canvas, "height", bboxHeight+"px");
140 this._canvas.elementModel.shapeModel.GLWorld.setViewportFromCanvas(this._canvas);
141 }
134 ctx.clearRect(0, 0, bboxWidth, bboxHeight); 142 ctx.clearRect(0, 0, bboxWidth, bboxHeight);
135 143
136 ctx.lineWidth = this._strokeWidth; 144 ctx.lineWidth = this._strokeWidth;
@@ -144,6 +152,7 @@ var GLSubpath = function GLSubpath() {
144 //ctx.fillStyle = MathUtils.colorToHex( this._fillColor ); 152 //ctx.fillStyle = MathUtils.colorToHex( this._fillColor );
145 var fillColorStr = "rgba("+parseInt(255*this._fillColor[0])+","+parseInt(255*this._fillColor[1])+","+parseInt(255*this._fillColor[2])+","+this._fillColor[3]+")"; 153 var fillColorStr = "rgba("+parseInt(255*this._fillColor[0])+","+parseInt(255*this._fillColor[1])+","+parseInt(255*this._fillColor[2])+","+this._fillColor[3]+")";
146 ctx.fillStyle = fillColorStr; 154 ctx.fillStyle = fillColorStr;
155 console.log("Fill color:" + fillColorStr);
147 } 156 }
148 var lineCap = ['butt','round','square']; 157 var lineCap = ['butt','round','square'];
149 ctx.lineCap = lineCap[1]; 158 ctx.lineCap = lineCap[1];
@@ -256,6 +265,10 @@ GLSubpath.prototype = new GeomObj();
256///////////////////////////////////////////////////////// 265/////////////////////////////////////////////////////////
257// Property Accessors/Setters 266// Property Accessors/Setters
258///////////////////////////////////////////////////////// 267/////////////////////////////////////////////////////////
268GLSubpath.prototype.setCanvas = function (c) {
269 this._canvas = c;
270};
271
259GLSubpath.prototype.setWorld = function (world) { 272GLSubpath.prototype.setWorld = function (world) {
260 this._world = world; 273 this._world = world;
261}; 274};
@@ -773,6 +786,7 @@ GLSubpath.prototype.getStrokeWidth = function () {
773 786
774GLSubpath.prototype.setStrokeWidth = function (w) { 787GLSubpath.prototype.setStrokeWidth = function (w) {
775 this._strokeWidth = w; 788 this._strokeWidth = w;
789 this._dirty=true;
776}; 790};
777 791
778GLSubpath.prototype.getStrokeMaterial = function () { 792GLSubpath.prototype.getStrokeMaterial = function () {
@@ -1189,7 +1203,7 @@ GLSubpath.prototype.getNearVertex = function( eyePt, dir ){
1189 bboxDim[1] = 0.5 * (this._BBoxMax[1] - this._BBoxMin[1]); 1203 bboxDim[1] = 0.5 * (this._BBoxMax[1] - this._BBoxMin[1]);
1190 bboxMid[1] = 0.5 * (this._BBoxMax[1] + this._BBoxMin[1]); 1204 bboxMid[1] = 0.5 * (this._BBoxMax[1] + this._BBoxMin[1]);
1191 bboxDim[2] = 0.5 * (this._BBoxMax[2] - this._BBoxMin[2]); 1205 bboxDim[2] = 0.5 * (this._BBoxMax[2] - this._BBoxMin[2]);
1192 bboxMid[3] = 0.5 * (this._BBoxMax[2] + this._BBoxMin[2]); 1206 bboxMid[2] = 0.5 * (this._BBoxMax[2] + this._BBoxMin[2]);
1193 1207
1194 // convert the stroke vertices into normalized device coordinates 1208 // convert the stroke vertices into normalized device coordinates
1195 var world = this.getWorld(); 1209 var world = this.getWorld();