Created
April 10, 2019 04:42
-
-
Save rebolek/8f7520f01d3297507d724e6e2c99b6f2 to your computer and use it in GitHub Desktop.
This file contains 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
Red[] | |
dist-to-color: func [dist][ | |
to tuple! reduce [dist * 256 dist * 256 dist * 256] | |
] | |
distance: func [start end /local diff][ | |
diff: end - start | |
absolute square-root diff/x * diff/x + (diff/y * diff/y) | |
] | |
map: func ['word series code][ | |
; Leaks :word, but foreach leaks to | |
collect [ | |
foreach :word series [ | |
keep do code | |
] | |
] | |
] | |
get-distances: func [point points maximal][ | |
sort collect [ | |
foreach p points [keep (distance point p) / maximal] | |
] | |
] | |
make-image: func [][ | |
size: 200x200 | |
max-distance: 0.1 * distance 0x0 size | |
map: make image! size | |
peaks: collect [loop 100 [keep random size]] | |
repeat x size/x [ | |
repeat y size/y [ | |
diff: first get-distances as-pair x y peaks max-distance | |
map/(as-pair x y): dist-to-color max 0 1.0 - diff * 0.5 | |
] | |
] | |
map | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment