Skip to content

Instantly share code, notes, and snippets.

@nodename
Last active October 13, 2015 03:47

Revisions

  1. nodename revised this gist Apr 4, 2013. 1 changed file with 13 additions and 13 deletions.
    26 changes: 13 additions & 13 deletions SlideShow.elm
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,9 @@
    import Mouse (clicks)
    import Time (every)
    import Window (dimensions)

    firstImageIndex = 0 - 500
    lastImageIndex = 1500
    imageInterval = 0.4
    firstImageIndex = 0
    lastImageIndex = 1000
    delta = lift inSeconds (fps 30)

    modCount signal period = lift (\a -> a `mod` period) (count signal)

    @@ -13,19 +12,20 @@ data PlayDirection = Fwd | Back
    yoyoIndex direction fwdIndex reverseIndex = if (direction == Fwd) then fwdIndex else reverseIndex

    yoyo signal period =
    let { fwdIndices = modCount signal period
    ; reverseIndices = lift (\a -> period - a) fwdIndices
    ; turnarounds = keepIf (\a -> a == 0) false fwdIndices
    ; directions = (lift (\t -> if (t `mod` 2 == 0) then Fwd else Back) (count turnarounds))
    } in
    let fwdIndices = modCount signal period
    reverseIndices = lift (\a -> period - a) fwdIndices
    turnarounds = keepIf (\a -> a == 0) false fwdIndices
    directions = (lift (\t -> if (t `mod` 2 == 0) then Fwd else Back) (count turnarounds))
    in
    lift3 yoyoIndex directions fwdIndices reverseIndices

    showSlide (w,h) imageIndex =
    let { filename = "morph/" ++ show imageIndex ++ ".svg"
    ; pic = image 800 800 filename
    ; textElement = text (Text.color white (toText $ show imageIndex)) } in
    let filename = "morph/" ++ show imageIndex ++ ".svg"
    pic = image 800 800 filename
    textElement = text (Text.color white (toText $ show imageIndex))
    in
    color black . container w h middle $ flow down [ container w (heightOf pic) middle pic, container w 100 midTop textElement ]

    showSlides first last interval = lift2 showSlide dimensions (lift (\a -> a + first) (yoyo (every interval) (last - first)))

    main = showSlides firstImageIndex lastImageIndex imageInterval
    main = showSlides firstImageIndex lastImageIndex delta
  2. nodename revised this gist Nov 24, 2012. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions SlideShow.elm
    Original file line number Diff line number Diff line change
    @@ -2,8 +2,8 @@ import Mouse (clicks)
    import Time (every)
    import Window (dimensions)

    firstImageIndex = 0 - 200
    lastImageIndex = 1200
    firstImageIndex = 0 - 500
    lastImageIndex = 1500
    imageInterval = 0.4

    modCount signal period = lift (\a -> a `mod` period) (count signal)
  3. nodename created this gist Nov 23, 2012.
    31 changes: 31 additions & 0 deletions SlideShow.elm
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    import Mouse (clicks)
    import Time (every)
    import Window (dimensions)

    firstImageIndex = 0 - 200
    lastImageIndex = 1200
    imageInterval = 0.4

    modCount signal period = lift (\a -> a `mod` period) (count signal)

    data PlayDirection = Fwd | Back

    yoyoIndex direction fwdIndex reverseIndex = if (direction == Fwd) then fwdIndex else reverseIndex

    yoyo signal period =
    let { fwdIndices = modCount signal period
    ; reverseIndices = lift (\a -> period - a) fwdIndices
    ; turnarounds = keepIf (\a -> a == 0) false fwdIndices
    ; directions = (lift (\t -> if (t `mod` 2 == 0) then Fwd else Back) (count turnarounds))
    } in
    lift3 yoyoIndex directions fwdIndices reverseIndices

    showSlide (w,h) imageIndex =
    let { filename = "morph/" ++ show imageIndex ++ ".svg"
    ; pic = image 800 800 filename
    ; textElement = text (Text.color white (toText $ show imageIndex)) } in
    color black . container w h middle $ flow down [ container w (heightOf pic) middle pic, container w 100 midTop textElement ]

    showSlides first last interval = lift2 showSlide dimensions (lift (\a -> a + first) (yoyo (every interval) (last - first)))

    main = showSlides firstImageIndex lastImageIndex imageInterval