linsyking/elm-canvas/2.0.0

NOTE: the latest version is 4.4.0

Rerouted (regenerated, verified). Same repository and tag, but GitHub now builds the zip with different bytes, so it no longer matches the SHA-1 package.elm-lang.org recorded. The Lamdera package server serves a copy recovered from https://github.com/linsyking/elm-canvas.

What we checked: Rebuilt with git archive from commit 8a2e082db001 of https://github.com/linsyking/elm-canvas (zip prefix linsyking-elm-canvas-8a2e082/, America/Los_Angeles times): the zip is byte-identical to the one package.elm-lang.org recorded, SHA-1 161e76f3d17c5bd6e93cefb51e57639cdb8559da.

The Lamdera compiler uses this copy and prints a one-line notice saying so. elm itself fails to download this version.

Details · package.elm-lang.org's zip: https://github.com/linsyking/elm-canvas/zipball/2.0.0/

joakin/elm-canvas

** WARNING: THIS IS THE CLONE OF joakin/elm-canvas @ v5.0.0 MADE FOR CUSTOM USE WITH SOME EXTRA FUNCTIONALITY LIKE GRADIENTS ETC. USE ON YOUR OWN RISK AND PREFER THE ORIGINAL ONE IN ANY CASE. **

This module exposes a nice drawing API that works on top of the the DOM canvas.

Live examples (example sources)

Usage

To use it, read the docs on the Canvas module, and remember to include the elm-canvas custom element script in your page before you initialize your Elm application.

Then, you can add your HTML element like this:

module Main exposing (main)

import Canvas exposing (..)
import Canvas.Settings exposing (..)
import Color -- elm install avh4/elm-color
import Html exposing (Html)
import Html.Attributes exposing (style)

view : Html msg
view =
    let
        width = 500
        height = 300
    in
        Canvas.toHtml (width, height)
            [ style "border" "1px solid black" ]
            [ shapes [ fill Color.white ] [ rect (0, 0) width height ]
            , renderSquare
            ]

renderSquare =
  shapes [ fill (Color.rgba 0 0 0 1) ]
      [ rect (0, 0) 100 50 ]

main = view

Examples

You can see many examples in the examples/ folder, and experience them live.

Additionally, some of the p5js.org examples were adapted to Elm using this package. They can be found in the Elm discourse thread.