diff options
Diffstat (limited to 'js/lib/geom/sub-path.js')
-rwxr-xr-x | js/lib/geom/sub-path.js | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/js/lib/geom/sub-path.js b/js/lib/geom/sub-path.js index 017cca92..e95be0e7 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 () { |