Skip to content

Commit

Permalink
allow attributes in images
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianHicks committed Jan 10, 2020
1 parent 903f321 commit 2701117
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
22 changes: 12 additions & 10 deletions src/Image.elm
Expand Up @@ -4,7 +4,7 @@ import Array exposing (Array)
import Color.Transparent as Color exposing (Color)
import Css
import Grid exposing (Grid)
import Html.Styled as Html exposing (Html)
import Html.Styled as Html exposing (Attribute, Html)
import Html.Styled.Attributes as Attrs exposing (css, style)
import Set

Expand All @@ -13,19 +13,21 @@ type alias Image =
Grid Color


viewColor : Color -> Html msg
viewColor color =
viewColor : List (Attribute msg) -> Color -> Html msg
viewColor attrs color =
Html.td
[ style "background-color" (Color.toRGBAString color)
, Attrs.width 10
, Attrs.height 10
]
([ style "background-color" (Color.toRGBAString color)
, Attrs.width 10
, Attrs.height 10
]
++ attrs
)
[]


view : Image -> Html msg
view =
Grid.view viewColor
view : List (Attribute msg) -> Image -> Html msg
view attrs image =
Grid.view (viewColor attrs) image


recurse : Image
Expand Down
8 changes: 5 additions & 3 deletions src/Main.elm
Expand Up @@ -181,7 +181,7 @@ view model =
, Reset.borderBoxV201408
, h1 [ Html.text "Wave Function Collapse" ]
, h2 [ Html.text "Source Image" ]
, Image.view model.image
, Image.view [] model.image
, Html.details []
[ Html.summary [] [ Html.text "Windows" ]
, model.windows
Expand All @@ -194,7 +194,7 @@ view model =
, Css.margin (Css.px 5)
]
]
[ Image.view window ]
[ Image.view [] window ]
)
]
, h2 [ Html.text "Wave" ]
Expand All @@ -204,6 +204,8 @@ view model =
else
Html.button [ Events.onClick Start ] [ Html.text "Start" ]
, Html.button [ Events.onClick Step ] [ Html.text "Step" ]
, Html.button [ Events.onClick (Reset { width = 2, height = 2 }) ] [ Html.text "Reset (2x2)" ]
, Html.button [ Events.onClick (Reset { width = 5, height = 5 }) ] [ Html.text "Reset (5x5)" ]
, Html.button [ Events.onClick (Reset { width = 10, height = 10 }) ] [ Html.text "Reset (10x10)" ]
, Html.button [ Events.onClick (Reset { width = 20, height = 20 }) ] [ Html.text "Reset (20x20)" ]
, Wave.view
Expand Down Expand Up @@ -231,7 +233,7 @@ view model =
average items =
List.sum items / toFloat (List.length items)
in
Image.viewColor
Image.viewColor []
(Color.fromRGBA
{ red = average reds
, green = average greens
Expand Down

0 comments on commit 2701117

Please sign in to comment.