Created
October 25, 2013 15:41
-
-
Save evancz/7156716 to your computer and use it in GitHub Desktop.
Examples of markdown interpolation in Elm's markdown branch: https://github.com/evancz/Elm/tree/markdown
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
import Graphics.Input as Input | |
import String | |
main = lift2 scene textBox name | |
(textBox, name) = Input.field "What is your name?" | |
scene textBox name = [markdown| | |
{{ textBox }} | |
Hello {{ toText name }}! Check out this circle that grows as you type more letters: | |
{{ blueCircle (String.length name) }} | |
|] | |
blueCircle radius = | |
collage 200 200 [ filled blue (circle (toFloat (10 + radius * 5))) ] |
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
main = lift2 presentation sunAndEarth bouncingBall | |
presentation orbit bounce = [markdown| | |
# Physics: How does it work? | |
Today we are going to learn how to gravity. | |
{{ orbit }} | |
Now that we can gravity, let's see if we can do it with elasticity! | |
{{ bounce }} | |
Now you know how to gravity with elasticity! Good work physics friend! | |
|] | |
time = fst <~ timestamp (fps 40) | |
sunAndEarthAt time = | |
let earth = group [ filled blue (circle 20), toForm (plainText "Earth") ] | |
sun = group [ filled yellow (circle 35), toForm (plainText "Sun") ] | |
position = (120 * cos (inSeconds time), 80 * sin (inSeconds time)) | |
in collage 500 300 | |
[ move position earth, move (25,0) sun ] | |
sunAndEarth = lift sunAndEarthAt time | |
bouncingBallAt t = | |
let y = abs (200 * sin (inSeconds t)) - 100 | |
in collage 300 300 | |
[ move (0,y) (filled red (circle 15)), | |
move (0,0-125) (filled green (rect 300 50)) ] | |
bouncingBall = lift bouncingBallAt time |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment