Created
October 15, 2014 20:27
-
-
Save bwinton/a616da940a9736fedbea 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
| #!/usr/bin/env node | |
| var suncalc = require('suncalc'); | |
| var phase = suncalc.getMoonIllumination(new Date()).phase; | |
| var phases = [ | |
| "π", | |
| "π", | |
| "π", | |
| "π", | |
| "π", | |
| "π", | |
| "π", | |
| "π", | |
| "π", | |
| "π" | |
| ]; | |
| stepPhase = function (phase, randomVal) { | |
| if (randomVal === undefined) { | |
| randomVal = 0.1; | |
| } | |
| var rv = Math.round(phase * 8) % 8; | |
| if (Math.random() <= randomVal && rv === 0) { | |
| rv = 8; | |
| } else if (Math.random() <= randomVal && rv === 4) { | |
| rv = 9; | |
| } | |
| return rv; | |
| } | |
| console.log(phases[stepPhase(phase)]); | |
| function test() { | |
| for (var i = 1; i <= 31; i++) { | |
| var phase = suncalc.getMoonIllumination(new Date(2014, 9, i)).phase; | |
| console.log("2014-09-" + i, phases[stepPhase(phase, 1)]); | |
| }; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment