mandelmapper/web.go

75 lines
1.8 KiB
Go
Raw Normal View History

2018-07-31 04:41:10 +00:00
package main
import (
"fmt"
"net/http"
)
func init() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path != "/" {
w.Header().Set("Location", "/")
w.WriteHeader(http.StatusMovedPermanently)
return
}
2019-03-03 21:38:06 +00:00
r.ParseForm()
2018-07-31 04:41:10 +00:00
fmt.Fprintf(w, `<!DOCTYPE html>
<html>
<head>
2018-07-31 22:21:41 +00:00
<title>MandelMapper</title>
2018-08-03 06:26:25 +00:00
2019-03-03 20:46:33 +00:00
<meta property="og:url" content="https://mandelmap.deadbeef.codes/" />
2018-08-03 06:26:25 +00:00
<meta property="og:type" content="website" />
<meta property="og:title" content="Mandelbrot Mapper">
<meta property="og:description" content="A Google maps front end to a distributed real-time fractal renderer">
<meta property="og:image" content="https://deadbeef.codes/img/mandelbrot.png" />
<meta property="og:site_name" content="deadbeef.codes">
2019-01-17 03:02:29 +00:00
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCopjjJpOzgR_FUBKMJAcWQ9xMTFI-D4KA"></script>
2018-07-31 04:41:10 +00:00
<script>
var mandelbrotTypeOptions = {
getTileUrl: function(coord, zoom) {
2019-03-03 21:38:06 +00:00
return '/mandelbrot/' + zoom + '/' + coord.x + '/' + coord.y + '.png?label=%s';
2018-07-31 04:41:10 +00:00
},
tileSize: new google.maps.Size(128, 128),
maxZoom: (1<<16),
minZoom: 1,
name: '0xdeadbeef Mandel Mapper'
2018-07-31 04:41:10 +00:00
};
var mandelbrotMapType = new google.maps.ImageMapType(mandelbrotTypeOptions);
function initialize() {
var mapOptions = {
center: new google.maps.LatLng(0, 0),
zoom: 1,
streetViewControl: false,
mapTypeControlOptions: {
mapTypeIds: ['mandelbrot']
}
};
var map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);
map.mapTypes.set('mandelbrot', mandelbrotMapType);
map.setMapTypeId('mandelbrot');
}
</script>
<style>
#map_canvas {
position: absolute !important;
left: 0 !important;
right: 0 !important;
top: 0 !important;
bottom: 0 !important;
}
</style>
</head>
<body onload="initialize()">
<div id="map_canvas"></div>
</body>
2019-03-03 21:38:06 +00:00
</html>`, r.FormValue("label"))
2018-07-31 04:41:10 +00:00
})
}