1
이 코드는 http://elm-lang.org/edit/examples/Intermediate/Stamps.elm에서입니다. 나는 사소한 변화를했습니다, 아래를보십시오.지도 함수를 임의의 숫자로 사용하는 방법
import Mouse
import Window
import Random
main : Signal Element
main = lift2 scene Window.dimensions clickLocations
-- for a good time, remove "sampleOn Mouse.clicks" ;)
clickLocations : Signal [(Int,Int)]
clickLocations = foldp (::) [] (sampleOn Mouse.clicks Mouse.position)
scene : (Int,Int) -> [(Int,Int)] -> Element
scene (w,h) locs =
let p = Random.float (fps 25)
drawPentagon p (x,y) =
ngon 5 20 |> filled (hsla p 0.9 0.6 0.7)
|> move (toFloat x - toFloat w/2, toFloat h/2 - toFloat y)
|> rotate (toFloat x)
in layers [ collage w h (map (drawPentagon <~ p) locs) // I want to change different color each time, error here!
, plainText "Click to stamp a pentagon." ]
어떻게지도 기능을 사용할 때 신호를 전달할 수 있습니까? 코드에서