Skip to content

jlgw/CanvasWebIO.jl

Repository files navigation

CanvasWebIO

Warning: This package is experimental and buggy.

The purpose of this package is to allow the construction of clickable and movable SVG objects inside a WebIO Scope, with the position of each object accesssible through observables in Julia.

Installation

Install WebIO and JSExpr. Then run

Pkg.clone("https://github.com/lancebeet/CanvasWebIO.jl")

in the REPL.

Usage

To create a canvas:

canvas = Canvas()

Adding movable objects using a template node:

box = dom"svg:rect[id=box, height=50, width=50, x=100, y=100]"()
addmovable!(canvas, box)

Serving with Mux, (canvas() returns the canvas' Scope)

using Mux
webio_serve(page("/", req -> canvas()))

Accessing position of movable object:

a = canvas["box"][] #access
canvas["box"] = [500,250] #assignment

More examples

Note: Despite the name, the Canvas struct has nothing to do with an HTML canvas, but generates an SVG object.

About

Clickable/Movable SVGs in WebIO

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published