(line, left, right)
| 28 | * @return {Phaser.Geom.Line} The modified Line instance. |
| 29 | */ |
| 30 | var Extend = function (line, left, right) |
| 31 | { |
| 32 | if (right === undefined) { right = left; } |
| 33 | |
| 34 | var length = Length(line); |
| 35 | |
| 36 | var slopX = line.x2 - line.x1; |
| 37 | var slopY = line.y2 - line.y1; |
| 38 | |
| 39 | if (left) |
| 40 | { |
| 41 | line.x1 = line.x1 - slopX / length * left; |
| 42 | line.y1 = line.y1 - slopY / length * left; |
| 43 | } |
| 44 | |
| 45 | if (right) |
| 46 | { |
| 47 | line.x2 = line.x2 + slopX / length * right; |
| 48 | line.y2 = line.y2 + slopY / length * right; |
| 49 | } |
| 50 | |
| 51 | return line; |
| 52 | }; |
| 53 | |
| 54 | module.exports = Extend; |
no test coverage detected
searching dependent graphs…