elmでやってみるシリーズ1: ●を動かす
elmでやってみるシリーズ1: ●を動かす。
import Window pos : Signal Int pos =let f = \tmp -> (tmp `mod` 30) - 10 in f <~ foldp (\it acc-> acc + 1) 0 (fps 50) drawCircle : Float -> Float -> Form drawCircle x y = move (x,y) <| filled red (circle 20) drawMatrix : [Form] drawMatrix = map (\x -> drawLine <| x*10) [-10..10] drawLine : Float -> Form drawLine x = traced (solid blue) ( segment (x,-100) (x,100) ) main : Signal Element main=let f = \w h p-> collage w h ([drawCircle ((toFloat p)*10) 10]++drawMatrix) in f <~ Window.width ~ Window.height ~ pos
続く。