From 486842239c71e7964f38a09aacda4970f2a82e1a Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 7 Feb 2012 10:58:14 -0800 Subject: Updated tools and PI to get/set materials by binding to appModel's materials property. This requires us to add FlatMaterial to the list of materials in the MaterialsLibrary. Signed-off-by: Nivesh Rajbhandari --- js/tools/LineTool.js | 7 +++---- js/tools/OvalTool.js | 14 ++++++-------- js/tools/RectTool.js | 14 ++++++-------- 3 files changed, 15 insertions(+), 20 deletions(-) (limited to 'js/tools') diff --git a/js/tools/LineTool.js b/js/tools/LineTool.js index 6a948fd8..99c374a7 100644 --- a/js/tools/LineTool.js +++ b/js/tools/LineTool.js @@ -203,10 +203,10 @@ exports.LineTool = Montage.create(ShapeTool, { // for default stroke and fill/no materials var strokeMaterial = null; - var strokeIndex = parseInt(this.options.strokeMaterial); - if(strokeIndex > 0) + var strokeM = this.options.strokeMaterial; + if(strokeM) { - strokeMaterial = Object.create(MaterialsLibrary.getMaterialAt(strokeIndex-1)); + strokeMaterial = Object.create(MaterialsLibrary.getMaterial(strokeM)); } var world = this.getGLWorld(canvas, this.options.use3D); @@ -232,7 +232,6 @@ exports.LineTool = Montage.create(ShapeTool, { } canvas.elementModel.shapeModel.strokeMaterial = strokeMaterial; - canvas.elementModel.shapeModel.strokeMaterialIndex = strokeIndex; canvas.elementModel.shapeModel.strokeStyleIndex = strokeStyleIndex; canvas.elementModel.shapeModel.strokeStyle = strokeStyle; diff --git a/js/tools/OvalTool.js b/js/tools/OvalTool.js index 446c6754..14655312 100644 --- a/js/tools/OvalTool.js +++ b/js/tools/OvalTool.js @@ -43,16 +43,16 @@ exports.OvalTool = Montage.create(ShapeTool, { var strokeMaterial = null; var fillMaterial = null; - var strokeIndex = parseInt(this.options.strokeMaterial); - if(strokeIndex > 0) + var strokeM = this.options.strokeMaterial; + if(strokeM) { - strokeMaterial = Object.create(MaterialsLibrary.getMaterialAt(strokeIndex-1)); + strokeMaterial = Object.create(MaterialsLibrary.getMaterial(strokeM)); } - var fillIndex = parseInt(this.options.fillMaterial); - if(fillIndex > 0) + var fillM = this.options.fillMaterial; + if(fillM) { - fillMaterial = Object.create(MaterialsLibrary.getMaterialAt(fillIndex-1)); + fillMaterial = Object.create(MaterialsLibrary.getMaterial(fillM)); } @@ -88,8 +88,6 @@ exports.OvalTool = Montage.create(ShapeTool, { canvas.elementModel.shapeModel.strokeMaterial = strokeMaterial; canvas.elementModel.shapeModel.fillMaterial = fillMaterial; - canvas.elementModel.shapeModel.strokeMaterialIndex = strokeIndex; - canvas.elementModel.shapeModel.fillMaterialIndex = fillIndex; canvas.elementModel.shapeModel.strokeStyleIndex = strokeStyleIndex; canvas.elementModel.shapeModel.strokeStyle = strokeStyle; diff --git a/js/tools/RectTool.js b/js/tools/RectTool.js index 6109ee4d..31ac7faa 100644 --- a/js/tools/RectTool.js +++ b/js/tools/RectTool.js @@ -62,16 +62,16 @@ exports.RectTool = Montage.create(ShapeTool, { var strokeMaterial = null; var fillMaterial = null; - var strokeIndex = parseInt(this.options.strokeMaterial); - if(strokeIndex > 0) + var strokeM = this.options.strokeMaterial; + if(strokeM) { - strokeMaterial = Object.create(MaterialsLibrary.getMaterialAt(strokeIndex-1)); + strokeMaterial = Object.create(MaterialsLibrary.getMaterial(strokeM)); } - var fillIndex = parseInt(this.options.fillMaterial); - if(fillIndex > 0) + var fillM = this.options.fillMaterial; + if(fillM) { - fillMaterial = Object.create(MaterialsLibrary.getMaterialAt(fillIndex-1)); + fillMaterial = Object.create(MaterialsLibrary.getMaterial(fillM)); } var world = this.getGLWorld(canvas, this.options.use3D); @@ -110,8 +110,6 @@ exports.RectTool = Montage.create(ShapeTool, { canvas.elementModel.shapeModel.strokeMaterial = strokeMaterial; canvas.elementModel.shapeModel.fillMaterial = fillMaterial; - canvas.elementModel.shapeModel.strokeMaterialIndex = strokeIndex; - canvas.elementModel.shapeModel.fillMaterialIndex = fillIndex; canvas.elementModel.shapeModel.strokeStyleIndex = strokeStyleIndex; canvas.elementModel.shapeModel.strokeStyle = strokeStyle; -- cgit v1.2.3