This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.
Base64 image creation on fly
version 1.0.0
license BSD3
native-modules False
elm-version 0.18.0 <= v < 0.19.0
Tag 1.0.0
Committed At 2018-04-24 14:06:56 UTC
newlandsvalley/elm-binary-base64 1.0.2 <= v < 2.0.0 1.0.3
elm-lang/core 5.1.1 <= v < 6.0.0 5.1.1

Modules

README

Build Status

A library for building base64 encoded images in elm

Motivation

WebGL for Elm do not support arrays, so I need to build lookup tables for that, to prevent doing it in preprocess was created this library that can convert matrix into image, and then used in shader.

Examples


import Html exposing (img)
    import Html.Attributes exposing (src)
    import Image.BMP exposing (encode24With)

    main : Html.Html msg
    main =
        img [ src (encode24With width height pixels options) ] []

    width : Int
    width =
        2

    height : Int
    height =
        2

    red : Int
    red =
        0x00FF0000

    green : Int
    green =
        0xFF00

    blue : Int
    blue =
        0xFF

    pixels : List Int
    pixels =
        [ red, green, blue, red ]

    options : Options {}
    options =
        { defaultColor = 0x00FFFF00, order = RightDown }

Example 2

Create texture useing base64 encoded image and load it to shader

import Image.BMP exposing (encode24)

textureTask = WebGL.Texture.load (encode24 2 2 [1,2,3,4] )
-- then use resulting texture as lookup table

You can use simple function to get data from lookup table, where color is pixel color from just created texture

float color2float(vec4 color) {
    return color.z * 255.0
    + color.y * 256.0 * 255.0
    + color.x * 256.0 * 256.0 * 255.0
    ;
}