diff options
author | Jose Antonio Marquez | 2012-04-02 10:40:05 -0700 |
---|---|---|
committer | Jose Antonio Marquez | 2012-04-02 10:40:05 -0700 |
commit | b2f6ec0a6b08edac76cc77e1b57009bbb319abf5 (patch) | |
tree | cb24d3a9db06d3ffc538f3558436f7bce29aa7fd /js/lib/geom/sub-path.js | |
parent | e876941eaa6cf5adf0e028d0f3f9402284ea5de2 (diff) | |
parent | c6de22bf42be90b403491b5f87b1818d9020310c (diff) | |
download | ninja-b2f6ec0a6b08edac76cc77e1b57009bbb319abf5.tar.gz |
Merge branch 'refs/heads/Ninja-Internal' into Document
Diffstat (limited to 'js/lib/geom/sub-path.js')
-rwxr-xr-x | js/lib/geom/sub-path.js | 18 |
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 | ||
8 | var VecUtils = require("js/helper-classes/3D/vec-utils").VecUtils; | 8 | var VecUtils = require("js/helper-classes/3D/vec-utils").VecUtils; |
9 | 9 | var CanvasController = require("js/controllers/elements/canvas-controller").CanvasController; | |
10 | var GeomObj = require("js/lib/geom/geom-obj").GeomObj; | 10 | var GeomObj = require("js/lib/geom/geom-obj").GeomObj; |
11 | var AnchorPoint = require("js/lib/geom/anchor-point").AnchorPoint; | 11 | var AnchorPoint = require("js/lib/geom/anchor-point").AnchorPoint; |
12 | var MaterialsModel = require("js/models/materials-model").MaterialsModel; | 12 | var 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 | ///////////////////////////////////////////////////////// |
268 | GLSubpath.prototype.setCanvas = function (c) { | ||
269 | this._canvas = c; | ||
270 | }; | ||
271 | |||
259 | GLSubpath.prototype.setWorld = function (world) { | 272 | GLSubpath.prototype.setWorld = function (world) { |
260 | this._world = world; | 273 | this._world = world; |
261 | }; | 274 | }; |
@@ -773,6 +786,7 @@ GLSubpath.prototype.getStrokeWidth = function () { | |||
773 | 786 | ||
774 | GLSubpath.prototype.setStrokeWidth = function (w) { | 787 | GLSubpath.prototype.setStrokeWidth = function (w) { |
775 | this._strokeWidth = w; | 788 | this._strokeWidth = w; |
789 | this._dirty=true; | ||
776 | }; | 790 | }; |
777 | 791 | ||
778 | GLSubpath.prototype.getStrokeMaterial = function () { | 792 | GLSubpath.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(); |