Skip to content

Instantly share code, notes, and snippets.

@CSchank

CSchank/Hearts.elm

Last active May 19, 2020
Embed
What would you like to do?
Many different hearts in Elm, using functions!!
myShapes model = [
{-
This code is for a picture of a playing card.
The card is a 6 of hearts.
-}
text "Example 1" |> centered |> filled black |> move(0,55)
, heart red orange |> move (0, 40)
, heart yellow blue |> move (20,40)
, heart green pink |> move (40,40)
, heart purple red |> move (60,40)
-- draw many hearts in a row
, text "Example 2" |> centered |> filled black |> move(0,25)
, group (List.map heart2 (List.range -5 5)) |> move(0,10)
-- draw many hearts of different colours
, text "Example 3" |> centered |> filled black |> move(0,-5)
, group (List.map heart3 [(10, red), (30, orange), (50, purple)]) |> move (0, -20)
-- draw many hearts of different colours, with the model for animation
, text "Example 4" |> centered |> filled black |> move(0,-35)
, group (List.map (heart4 model) [(10, red), (30, orange), (50, purple)]) |> move (0, -50)
]
heart backgroundColour eyeColour = group
[
triangle 40
|> filled backgroundColour
|> rotate (degrees 30)
|> scaleY 0.7
,
circle 20
|> filled backgroundColour
|> move (17,23.5)
,
circle 20
|> filled backgroundColour
|> move (-17,23.5)
,
circle 5
|> filled eyeColour
|> move(10, 20)
,
circle 5
|> filled eyeColour
|> move(-10, 20)
]
|> scale 0.25
heart2 x = group
[
triangle 40
|> filled red
|> rotate (degrees 30)
|> scaleY 0.7
,
circle 20
|> filled red
|> move (17,23.5)
,
circle 20
|> filled red
|> move (-17,23.5)
]
|> scale 0.25
|> move (20 * toFloat x,0)
heart3 (x,col) = group
[
triangle 40
|> filled col
|> rotate (degrees 30)
|> scaleY 0.7
,
circle 20
|> filled col
|> move (17,23.5)
,
circle 20
|> filled col
|> move (-17,23.5)
]
|> scale 0.25
|> move (x,0)
heart4 model (x,col) = group
[
triangle 40
|> filled col
|> rotate (degrees 30)
|> scaleY 0.7
,
circle 20
|> filled col
|> move (17,23.5)
,
circle 20
|> filled col
|> move (-17,23.5)
]
|> scale 0.25
|> rotate (degrees 10*model.time)
|> move (x,0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment