Compare commits
70 Commits
Author | SHA1 | Date | |
---|---|---|---|
c9c29f980d | |||
4b811dc8d7 | |||
62eed5a9ee | |||
1dd6fa470e | |||
c1b138aad1 | |||
073f79aa79 | |||
![]() |
b2515749ae | ||
60050187f8 | |||
20dc1fcbd9 | |||
67a301284e | |||
884f2f0f80 | |||
7f3ce1a8e1 | |||
f344c9ca06 | |||
b6bd4382c1 | |||
07cfe80c08 | |||
0014ae7eee | |||
48ac50f64c | |||
d5f9fb4b86 | |||
0f86e21376 | |||
42c657cc3a | |||
c91076b7ac | |||
89e4390465 | |||
002332594c | |||
85150c2792 | |||
b2c2ba5c42 | |||
8c1e447286 | |||
d475ea5083 | |||
77f367ef23 | |||
0d4980f64d | |||
d2dff15b6f | |||
107a95e7f4 | |||
63e25ba2d5 | |||
ff0ca4030c | |||
b0e33f0d9a | |||
d426e601e5 | |||
3921e641c9 | |||
d8f2c606ee | |||
197ecf54a7 | |||
ec5fdfa0b3 | |||
1486b05cd9 | |||
9fae307f90 | |||
677e069a4e | |||
cfcfc79727 | |||
dd9b05bc00 | |||
d8f00ba2a6 | |||
a6d7c05b59 | |||
b2b12265d9 | |||
6b43a65110 | |||
c4a56295b6 | |||
8301d08873 | |||
41b033d4f2 | |||
cc54877d5e | |||
c846cfe262 | |||
0f970fd21e | |||
e926140b99 | |||
a07290c8c2 | |||
44033bd5dc | |||
3b3fe20ae7 | |||
50185baa41 | |||
9105f34d6a | |||
2cb2d4764d | |||
150a098c46 | |||
9bd13db3ec | |||
93d0a51230 | |||
![]() |
8a1b7315f8 | ||
![]() |
2a100b79a7 | ||
![]() |
6d9f9ca112 | ||
2f2e272347 | |||
e359d09858 | |||
4f949f35e0 |
38
.drone.yml
38
.drone.yml
@ -1,21 +1,23 @@
|
||||
kind: pipeline
|
||||
name: default
|
||||
|
||||
workspace:
|
||||
base: /go
|
||||
path: src/deadbeef.codes/steven/mandelmapper
|
||||
path: src/code.stevenpolley.net/steven/mandelmapper
|
||||
|
||||
pipeline:
|
||||
build:
|
||||
image: golang:latest
|
||||
environment:
|
||||
- GOOS=linux
|
||||
- GOARCH=arm
|
||||
- GOARM=7
|
||||
commands:
|
||||
- go version
|
||||
- go get
|
||||
- go build
|
||||
publish:
|
||||
image: plugins/docker
|
||||
repo: deadbeef.codes:5000/mandelmapper
|
||||
registry: deadbeef.codes:5000
|
||||
auto_tag: true
|
||||
auto_tag_suffix: ${DRONE_COMMIT}
|
||||
steps:
|
||||
- name: build
|
||||
image: golang
|
||||
pull: always
|
||||
environment:
|
||||
GOOS: linux
|
||||
GOARCH: amd64
|
||||
CGO_ENABLED: 0
|
||||
commands:
|
||||
- go version
|
||||
- go get
|
||||
- go build -a -ldflags '-w'
|
||||
- name: publish
|
||||
image: plugins/docker
|
||||
settings:
|
||||
repo: registry.stevenpolley.net/mandelmapper
|
||||
|
@ -1,4 +1,5 @@
|
||||
FROM deadbeef.codes:5000/raspberrypi3-alpine:3.7
|
||||
COPY mandelmapper /usr/bin
|
||||
FROM scratch
|
||||
LABEL maintainer="himself@stevenpolley.net"
|
||||
COPY mandelmapper /
|
||||
EXPOSE 6161:6161
|
||||
CMD mandelmapper
|
||||
ENTRYPOINT ["/mandelmapper"]
|
@ -1,3 +1,6 @@
|
||||
testing drone ?
|
||||
release
|
||||
another drone test plz
|
||||
[](https://drone.deadbeef.codes/steven/mandelmapper)
|
||||
|
||||
|
||||
This is currently deployed to a ARMv8 cluster, viewable at https://mandelmap.deadbeef.codes
|
||||
|
||||
|
8
docker-compose.yml
Normal file
8
docker-compose.yml
Normal file
@ -0,0 +1,8 @@
|
||||
version: '3.6'
|
||||
|
||||
services:
|
||||
mandel-mapper:
|
||||
image: registry.deadbeef.codes/mandelmapper:latest
|
||||
ports:
|
||||
- 6161:6161
|
||||
restart: always
|
5
go.mod
Normal file
5
go.mod
Normal file
@ -0,0 +1,5 @@
|
||||
module deadbeef.codes/steven/mandelmapper
|
||||
|
||||
go 1.22
|
||||
|
||||
require golang.org/x/image v0.22.0
|
4
go.sum
Normal file
4
go.sum
Normal file
@ -0,0 +1,4 @@
|
||||
golang.org/x/image v0.18.0 h1:jGzIakQa/ZXI1I0Fxvaa9W7yP25TqT6cHIHn+6CqvSQ=
|
||||
golang.org/x/image v0.18.0/go.mod h1:4yyo5vMFQjVjUcVk4jEQcU9MGy/rulF5WvUILseCM2E=
|
||||
golang.org/x/image v0.22.0 h1:UtK5yLUzilVrkjMAZAZ34DXGpASN8i8pj8g+O+yd10g=
|
||||
golang.org/x/image v0.22.0/go.mod h1:9hPFhljd4zZ1GNSIZJ49sqbp45GKK9t6w+iXvGqZUz4=
|
@ -361,4 +361,13 @@ var ColorPalettes = []ColorMap{
|
||||
Color{Color: color.RGBA{0x2a, 0xa1, 0x98, 0xff}},
|
||||
Color{Color: color.RGBA{0x85, 0x99, 0x00, 0xff}},
|
||||
}},
|
||||
{"Pride", []Color{
|
||||
Color{Step: 0.0, Color: color.RGBA{0xff, 0x00, 0x00, 0xff}},
|
||||
Color{Step: 0.0, Color: color.RGBA{0xff, 0x7f, 0x00, 0xff}},
|
||||
Color{Step: 0.0, Color: color.RGBA{0xff, 0xff, 0x00, 0xff}},
|
||||
Color{Step: 0.0, Color: color.RGBA{0x00, 0xff, 0x00, 0xff}},
|
||||
Color{Step: 0.0, Color: color.RGBA{0x00, 0x00, 0xff, 0xff}},
|
||||
Color{Step: 0.0, Color: color.RGBA{0x2e, 0x2b, 0x5f, 0xff}},
|
||||
Color{Step: 0.0, Color: color.RGBA{0x8b, 0x00, 0xff, 0xff}},
|
||||
}},
|
||||
}
|
||||
|
40
render.go
40
render.go
@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"image"
|
||||
"image/color"
|
||||
"image/png"
|
||||
@ -8,17 +9,22 @@ import (
|
||||
"math"
|
||||
"math/cmplx"
|
||||
"net/http"
|
||||
"os"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"deadbeef.codes/steven/mandelmapper/palette"
|
||||
"golang.org/x/image/font"
|
||||
"golang.org/x/image/font/basicfont"
|
||||
"golang.org/x/image/math/fixed"
|
||||
)
|
||||
|
||||
const (
|
||||
Size = 128
|
||||
Iterations = 1<<16 - 1
|
||||
Size = 128
|
||||
//Iterations = (1<<16 - 1) / 256
|
||||
Iterations = (1<<16 - 1) / 128
|
||||
)
|
||||
|
||||
var (
|
||||
@ -46,8 +52,8 @@ func main() {
|
||||
}
|
||||
|
||||
colorStep := float64(Iterations)
|
||||
// colors = interpolateColors("Plan9", colorStep)
|
||||
colors = interpolateColors("Solarized", colorStep)
|
||||
|
||||
colors = interpolateColors("Hippi", colorStep)
|
||||
|
||||
log.Fatal(http.ListenAndServe(":6161", nil))
|
||||
}
|
||||
@ -65,7 +71,7 @@ func computeThread() {
|
||||
}
|
||||
}
|
||||
|
||||
//interpolateColors accepts a color palette and number of desired colors and builds a slice of colors by interpolating the gaps
|
||||
// interpolateColors accepts a color palette and number of desired colors and builds a slice of colors by interpolating the gaps
|
||||
func interpolateColors(paletteCode string, numberOfColors float64) []color.RGBA {
|
||||
var factor float64
|
||||
steps := []float64{}
|
||||
@ -132,6 +138,7 @@ func linearInterpolation(c1, c2, mu uint32) uint32 {
|
||||
}
|
||||
|
||||
func renderTile(w http.ResponseWriter, r *http.Request) {
|
||||
r.ParseForm()
|
||||
components := strings.Split(r.URL.Path, "/")[1:]
|
||||
|
||||
if len(components) != 4 || components[0] != "mandelbrot" || components[3][len(components[3])-4:] != ".png" {
|
||||
@ -167,6 +174,16 @@ func renderTile(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
if r.FormValue("label") == "1" {
|
||||
addLabel(img, 1, 10, fmt.Sprintf("%d/%d/%d", tileZoom, tileX, tileY))
|
||||
|
||||
hostname, err := os.Hostname()
|
||||
if err != nil {
|
||||
hostname = fmt.Sprintf("failed to get hostname: %v", err)
|
||||
}
|
||||
addLabel(img, 1, 22, hostname)
|
||||
}
|
||||
w.Header().Set("Content-Type", "image/png")
|
||||
png.Encode(w, img)
|
||||
}
|
||||
@ -181,3 +198,16 @@ func mandelbrot(c complex128) uint16 {
|
||||
}
|
||||
return Iterations
|
||||
}
|
||||
|
||||
func addLabel(img *image.RGBA, x, y int, label string) {
|
||||
col := color.RGBA{200, 100, 0, 255}
|
||||
point := fixed.Point26_6{fixed.Int26_6(x * 64), fixed.Int26_6(y * 64)}
|
||||
|
||||
d := &font.Drawer{
|
||||
Dst: img,
|
||||
Src: image.NewUniform(col),
|
||||
Face: basicfont.Face7x13,
|
||||
Dot: point,
|
||||
}
|
||||
d.DrawString(label)
|
||||
}
|
||||
|
10
web.go
10
web.go
@ -13,23 +13,25 @@ func init() {
|
||||
return
|
||||
}
|
||||
|
||||
r.ParseForm()
|
||||
|
||||
fmt.Fprintf(w, `<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>MandelMapper</title>
|
||||
|
||||
<meta property="og:url" content="http://mc.deadbeef.codes/" />
|
||||
<meta property="og:url" content="https://mandelmap.deadbeef.codes/" />
|
||||
<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">
|
||||
|
||||
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAZItO5CjoqDfPLwH_FZ4KcvQFt_L5dQBw"></script>
|
||||
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDJJV_-Q2wIBlzYVzfIbZTapl-8tMoYxw8"></script>
|
||||
<script>
|
||||
var mandelbrotTypeOptions = {
|
||||
getTileUrl: function(coord, zoom) {
|
||||
return '/mandelbrot/' + zoom + '/' + coord.x + '/' + coord.y + '.png';
|
||||
return '/mandelbrot/' + zoom + '/' + coord.x + '/' + coord.y + '.png?label=%s';
|
||||
},
|
||||
tileSize: new google.maps.Size(128, 128),
|
||||
maxZoom: (1<<16),
|
||||
@ -67,6 +69,6 @@ function initialize() {
|
||||
<body onload="initialize()">
|
||||
<div id="map_canvas"></div>
|
||||
</body>
|
||||
</html>`)
|
||||
</html>`, r.FormValue("label"))
|
||||
})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user