SHOW:
|
|
- or go back to the newest paste.
1 | - | -- drafter.lua -- stateful approach |
1 | + | -- drafter.lua -- stateless approach |
2 | ||
3 | local drafter = {} | |
4 | ||
5 | - | drafter.maxLength = 0 |
5 | + | function drafter.line(startX, startY, endX, endY, maxLength) |
6 | local deltaX, deltaY = endX - startX, endY - startY | |
7 | - | function drafter.line(startX, startY, endX, endY) |
7 | + | |
8 | if requestedLength > maxLength then | |
9 | local ratio = maxLength / requestedLength | |
10 | - | if requestedLength > drafter.maxLength then |
10 | + | |
11 | - | local ratio = drafter.maxLength / requestedLength |
11 | + | |
12 | display.newLine(startX, startY, endX, endY) | |
13 | end | |
14 | ||
15 | return drafter |