From 449774c94d08da18cb564a8a32a32bc344e6d87b Mon Sep 17 00:00:00 2001 From: liabru Date: Sat, 5 Dec 2015 18:58:56 +0000 Subject: [PATCH] fix issue when Bodies.trapezoid slope === 1, closes #138 --- src/factory/Bodies.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/factory/Bodies.js b/src/factory/Bodies.js index bc77d75..3b717eb 100644 --- a/src/factory/Bodies.js +++ b/src/factory/Bodies.js @@ -74,12 +74,19 @@ var Vector = require('../geometry/Vector'); var x1 = width * slope, x2 = x1 + roof, - x3 = x2 + x1; + x3 = x2 + x1, + verticesPath; + + if (slope < 0.5) { + verticesPath = 'L 0 0 L ' + x1 + ' ' + (-height) + ' L ' + x2 + ' ' + (-height) + ' L ' + x3 + ' 0'; + } else { + verticesPath = 'L 0 0 L ' + x2 + ' ' + (-height) + ' L ' + x3 + ' 0'; + } var trapezoid = { label: 'Trapezoid Body', position: { x: x, y: y }, - vertices: Vertices.fromPath('L 0 0 L ' + x1 + ' ' + (-height) + ' L ' + x2 + ' ' + (-height) + ' L ' + x3 + ' 0') + vertices: Vertices.fromPath(verticesPath) }; if (options.chamfer) {