Created
October 21, 2015 22:17
-
-
Save mohayonao/b359f61f2018280ea2ce to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function createRandomAutoPanSegment() { | |
| let result = []; | |
| let length = Math.floor(Math.random() * 5 + 5); | |
| let pos = 0; | |
| for (let i = 0; i < length; i++) { | |
| if (Math.random() * 0.8 < i / length) { | |
| pos = 1; | |
| } | |
| if (pos === 0) { | |
| if (Math.random() < 0.2) { | |
| pos += Math.random() * 0.6; | |
| } | |
| } else if (1 <= pos) { | |
| pos = 1; | |
| } else if (Math.random() < 0.1) { | |
| pos += Math.random() * 0.6; | |
| } | |
| result[i] = pos; | |
| } | |
| result[0] = 0; | |
| result = result.map(x => x * 2 - 1); | |
| return result; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment