Created
September 7, 2015 04:53
-
-
Save dela3499/a7e1c569deb84f91032d to your computer and use it in GitHub Desktop.
Radial Display 2
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
import Graphics.Element exposing (..) | |
import Graphics.Collage exposing (..) | |
import Window | |
import Signal | |
import Color exposing (..) | |
main = | |
Signal.map (view x) Window.dimensions | |
view: List (List Float) -> (Int, Int) -> Element | |
view values (w, h) = | |
let myRadius = | |
(toFloat w) * 0.4 | |
n = | |
List.length values | |
theta = | |
(degrees (360 / (toFloat n))) | |
slices = | |
List.map (viewSlice myRadius theta) values | |
rotations = | |
List.map (\i -> (toFloat i) * theta) [0 .. n - 1] | |
translations = | |
List.map (\angle -> fromPolar (myRadius / 2, angle)) rotations | |
rotatedSlices = | |
List.map3 | |
(\slice rot trans -> slice |> rotate rot) | |
slices rotations translations | |
in | |
collage w h rotatedSlices | |
colorize: Float -> Color | |
colorize value = | |
greyscale 0.5 --((value + 80) / 80) | |
viewSlice: Float -> Float -> List Float -> Form | |
viewSlice r theta values = | |
let n = | |
List.length values | |
myHeight = | |
(r - 5) / (toFloat n) | |
radii = | |
List.map (\i -> 5 + (toFloat i) * myHeight) [0 .. n - 1] | |
widths = | |
List.map (\radius -> radius * theta * 1.2) radii | |
colors = | |
List.map (\value -> greyscale ((value + 80) / 80)) values | |
in | |
group (List.map3 (viewElem myHeight) widths radii colors) | |
viewElem: Float -> Float -> Float -> Color -> Form | |
viewElem myHeight myWidth y myColor = | |
rect myWidth myHeight | |
|> filled myColor | |
|> move (0, y + (myHeight / 2)) | |
x = [[]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment