Goofing around with html5 canvas again
to make sure I'm not missing anything big by mostly using svg (in d3).
This commit is contained in:
parent
b6ece46e5b
commit
250bfbdfa0
33
html5/canvas/mdn-tutorial.html
Normal file
33
html5/canvas/mdn-tutorial.html
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>MDN Canvas Tutorial</title>
|
||||||
|
<style type="text/css">
|
||||||
|
canvas {
|
||||||
|
border: 1px solid black;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<canvas id="tutorial" width="150" height="150">
|
||||||
|
hammer down
|
||||||
|
</canvas>
|
||||||
|
<script type="text/javascript">
|
||||||
|
function draw() {
|
||||||
|
var canvas = document.getElementById('tutorial');
|
||||||
|
if (!canvas.getContext) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var ctx = canvas.getContext('2d');
|
||||||
|
ctx.fillStyle = 'rgb(200, 0, 0)';
|
||||||
|
ctx.fillRect(10, 10, 55, 50);
|
||||||
|
|
||||||
|
ctx.fillStyle = 'rgba(0, 0, 200, 0.5)';
|
||||||
|
ctx.fillRect(30, 30, 55, 50);
|
||||||
|
}
|
||||||
|
|
||||||
|
window.addEventListener('load', draw, false);
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
22
html5/server.go
Normal file
22
html5/server.go
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// I wanted to practice, plus maaaaaybe I'll want something dynamic on the
|
||||||
|
// server side (???)
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"flag"
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
docroot = flag.String("d", ".", "docroot for server")
|
||||||
|
addr = flag.String("a", ":8990", "address on which to listen")
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
flag.Parse()
|
||||||
|
|
||||||
|
http.Handle("/", http.FileServer(http.Dir(*docroot)))
|
||||||
|
fmt.Printf("Serving %q on %v\n", *docroot, *addr)
|
||||||
|
http.ListenAndServe(*addr, nil)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user