Skip to content

Commit 258754b

Browse files
committed
add basic information to README.md
1 parent 0babc1f commit 258754b

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

README.md

+40
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,42 @@
11
httpcanvas
22
==========
3+
4+
write to an html5 canvas using go
5+
6+
The `app` function starts once a we browser connects to `http://host:port/`
7+
8+
That request downloads a bit of html and javascript to connect to the server and run commands
9+
10+
Further GET requests causes the output to move to the most recent request.
11+
12+
## Example
13+
``` go
14+
package main
15+
16+
import (
17+
"github.com/kbatten/httpcanvas"
18+
"math"
19+
"time"
20+
)
21+
22+
func app(context *httpcanvas.Context) {
23+
centerX := context.Width / 2
24+
centerY := context.Height / 2
25+
26+
context.BeginPath()
27+
context.Arc(centerX, centerY, 70, 0, 2*math.Pi, false)
28+
context.FillStyle("green")
29+
context.Fill()
30+
31+
time.Sleep(5 * time.Second)
32+
33+
context.LineWidth(5)
34+
context.StrokeStyle("#003300")
35+
context.Stroke()
36+
}
37+
38+
func main() {
39+
httpcanvas.ListenAndServe(":8080", app)
40+
}
41+
42+
```

0 commit comments

Comments
 (0)