Orasund / pixelengine

a graphic engine for elm
https://package.elm-lang.org/packages/Orasund/pixelengine/latest/
BSD 3-Clause "New" or "Revised" License
58 stars 3 forks source link

Converting tiles to images loses custom attributes #1

Closed z5h closed 1 year ago

z5h commented 1 year ago

I Wanted to be able to layer tiles, so I implemented my own tilesArea as shown below. But in this case, custom attributes (such as those added with .monochrome) are not rendered.

tiledArea :
    { rows : Int, tileset : Tileset, background : Background, rowsPerTile : Int }
    -> List ( ( Int, Int ), Tile msg )
    -> Area msg
tiledArea params list =
    PixelEngine.imageArea
        { height = toFloat <| params.rows * params.tileset.spriteHeight // params.rowsPerTile
        , background = params.background
        }
        (list
            |> List.map
                (\( ( col, row ), tile ) ->
                    ( ( toFloat (col * params.tileset.spriteWidth // params.rowsPerTile)
                      , toFloat (row * params.tileset.spriteHeight // params.rowsPerTile)
                      )
                    , PixelEngine.Image.fromTile tile params.tileset
                    )
                )
        )
Orasund commented 1 year ago

This will not work. For layering tiles, use multipleTiles