Skip to content

kbatten/httpcanvas

Folders and files

NameName
Last commit message
Last commit date

Latest commit

734e3ae · Sep 1, 2013

History

16 Commits
Aug 31, 2013
Aug 30, 2013
Aug 30, 2013
Aug 31, 2013
Sep 1, 2013
Sep 1, 2013
Sep 1, 2013

Repository files navigation

httpcanvas

write to an html5 canvas using go

The app function starts once a we browser connects to http://host:port/

That request downloads a bit of html and javascript to connect to the server and run commands

Further GET requests causes the output to move to the most recent request.

Example

package main

import (
    "github.com/kbatten/httpcanvas"
    "math"
    "time"
)

func app(context *httpcanvas.Context) {
    centerX := context.Width / 2
    centerY := context.Height / 2

    context.BeginPath()
    context.Arc(centerX, centerY, 70, 0, 2*math.Pi, false)
    context.FillStyle("green")
    context.Fill()

    time.Sleep(5 * time.Second)

    context.LineWidth(5)
    context.StrokeStyle("#003300")
    context.Stroke()
}

func main() {
    httpcanvas.ListenAndServe(":8080", app)
}

About

golang api to interact with an html5 canvas over http

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages