From d54ccb90a60f796ff37e42f01a855577cb3062d0 Mon Sep 17 00:00:00 2001 From: liabru Date: Wed, 19 Mar 2014 00:55:33 +0000 Subject: [PATCH] constraints now use a render property --- src/constraint/Constraint.js | 7 +++++-- src/constraint/MouseConstraint.js | 6 ++++-- src/render/Render.js | 4 ++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/constraint/Constraint.js b/src/constraint/Constraint.js index 001e3da..29930b8 100644 --- a/src/constraint/Constraint.js +++ b/src/constraint/Constraint.js @@ -41,9 +41,12 @@ var Constraint = {}; constraint.length = constraint.length || length || _minLength; + // render + constraint.render = constraint.render || {}; + constraint.render.lineWidth = constraint.render.lineWidth || 2; + constraint.render.strokeStyle = constraint.render.strokeStyle || '#666'; + // option defaults - constraint.lineWidth = constraint.lineWidth || 2; - constraint.strokeStyle = constraint.strokeStyle || '#666'; constraint.stiffness = constraint.stiffness || 1; constraint.angularStiffness = constraint.angularStiffness || 0; constraint.angleA = constraint.bodyA ? constraint.bodyA.angle : constraint.angleA; diff --git a/src/constraint/MouseConstraint.js b/src/constraint/MouseConstraint.js index 4fa5d0d..acd1d84 100644 --- a/src/constraint/MouseConstraint.js +++ b/src/constraint/MouseConstraint.js @@ -21,8 +21,10 @@ var MouseConstraint = {}; length: 0.01, stiffness: 0.1, angularStiffness: 1, - strokeStyle: 'lightgreen', - lineWidth: 3 + render: { + strokeStyle: '#90EE90', + lineWidth: 3 + } }); return { diff --git a/src/render/Render.js b/src/render/Render.js index 1909534..8e6522b 100644 --- a/src/render/Render.js +++ b/src/render/Render.js @@ -191,8 +191,8 @@ var Render = {}; c.lineTo(constraint.pointB.x, constraint.pointB.y); } - c.lineWidth = constraint.lineWidth; - c.strokeStyle = constraint.strokeStyle; + c.lineWidth = constraint.render.lineWidth; + c.strokeStyle = constraint.render.strokeStyle; c.stroke(); };