Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- drafter.lua -- factory approach
- local drafter = {}
- function drafter.line(maxLength)
- return function(startX, startY, endX, endY)
- local deltaX, deltaY = endX - startX, endY - startY
- local requestedLength = math.sqrt(deltaX * deltaX + deltaY * deltaY)
- if requestedLength > maxLength then
- local ratio = maxLength / requestedLength
- endX, endY = startX + deltaX * ratio, startY + deltaY * ratio
- end
- display.newLine(startX, startY, endX, endY)
- end
- end
- return drafter
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement