Skip to content

Instantly share code, notes, and snippets.

@giisyu
Last active August 29, 2015 14:09
Show Gist options
  • Save giisyu/3f86d5ec60cadb1e6954 to your computer and use it in GitHub Desktop.
Save giisyu/3f86d5ec60cadb1e6954 to your computer and use it in GitHub Desktop.
create a elastic bar
--example : http://www.share-elm.com/sprout/546cc30be4b00800031fee56
elasticBar (x,y) baseSide extendSide maxValue angle barColor state =
let moveDis = min extendSide (extendSide * (state / maxValue ))
faring bcolor shape = shape|>filled bcolor|> move (x,y)|> rotate (degrees angle)
in [polygon [(0,0),(baseSide,0),(baseSide,extendSide),(0,extendSide)]|>faring gray,
polygon [(0,0),(baseSide,0),(baseSide,moveDis),(0,moveDis)]|>faring barColor ]
bar state = elasticBar (0,0) 10 200 10 270 blue (toFloat state)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment