Compare commits
	
		
			70 Commits
		
	
	
		
			1.0
			...
			c9c29f980d
		
	
	| 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:
 | 
					workspace:
 | 
				
			||||||
  base: /go
 | 
					  base: /go
 | 
				
			||||||
  path: src/deadbeef.codes/steven/mandelmapper
 | 
					  path: src/code.stevenpolley.net/steven/mandelmapper
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pipeline:
 | 
					steps:
 | 
				
			||||||
  build:
 | 
					- name: build
 | 
				
			||||||
    image: golang:latest
 | 
					  image: golang
 | 
				
			||||||
    environment:
 | 
					  pull: always
 | 
				
			||||||
      - GOOS=linux
 | 
					  environment:
 | 
				
			||||||
      - GOARCH=arm
 | 
					    GOOS: linux
 | 
				
			||||||
      - GOARM=7
 | 
					    GOARCH: amd64
 | 
				
			||||||
    commands:
 | 
					    CGO_ENABLED: 0
 | 
				
			||||||
      - go version
 | 
					  commands:
 | 
				
			||||||
      - go get
 | 
					  - go version
 | 
				
			||||||
      - go build
 | 
					  - go get
 | 
				
			||||||
  publish:
 | 
					  - go build -a -ldflags '-w'
 | 
				
			||||||
    image: plugins/docker
 | 
					- name: publish
 | 
				
			||||||
    repo: deadbeef.codes:5000/mandelmapper
 | 
					  image: plugins/docker
 | 
				
			||||||
    registry: deadbeef.codes:5000
 | 
					  settings:
 | 
				
			||||||
    auto_tag: true
 | 
					    repo: registry.stevenpolley.net/mandelmapper
 | 
				
			||||||
    auto_tag_suffix: ${DRONE_COMMIT}
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,4 +1,5 @@
 | 
				
			|||||||
FROM deadbeef.codes:5000/raspberrypi3-alpine:3.7
 | 
					FROM scratch
 | 
				
			||||||
COPY mandelmapper /usr/bin
 | 
					LABEL maintainer="himself@stevenpolley.net"
 | 
				
			||||||
 | 
					COPY mandelmapper /
 | 
				
			||||||
EXPOSE 6161:6161
 | 
					EXPOSE 6161:6161
 | 
				
			||||||
CMD mandelmapper
 | 
					ENTRYPOINT ["/mandelmapper"]
 | 
				
			||||||
@@ -1,3 +1,6 @@
 | 
				
			|||||||
testing drone ?
 | 
					[](https://drone.deadbeef.codes/steven/mandelmapper)
 | 
				
			||||||
release
 | 
					
 | 
				
			||||||
another drone test plz
 | 
					
 | 
				
			||||||
 | 
					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{0x2a, 0xa1, 0x98, 0xff}},
 | 
				
			||||||
		Color{Color: color.RGBA{0x85, 0x99, 0x00, 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
 | 
					package main
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
 | 
						"fmt"
 | 
				
			||||||
	"image"
 | 
						"image"
 | 
				
			||||||
	"image/color"
 | 
						"image/color"
 | 
				
			||||||
	"image/png"
 | 
						"image/png"
 | 
				
			||||||
@@ -8,17 +9,22 @@ import (
 | 
				
			|||||||
	"math"
 | 
						"math"
 | 
				
			||||||
	"math/cmplx"
 | 
						"math/cmplx"
 | 
				
			||||||
	"net/http"
 | 
						"net/http"
 | 
				
			||||||
 | 
						"os"
 | 
				
			||||||
	"runtime"
 | 
						"runtime"
 | 
				
			||||||
	"strconv"
 | 
						"strconv"
 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
	"sync"
 | 
						"sync"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"deadbeef.codes/steven/mandelmapper/palette"
 | 
						"deadbeef.codes/steven/mandelmapper/palette"
 | 
				
			||||||
 | 
						"golang.org/x/image/font"
 | 
				
			||||||
 | 
						"golang.org/x/image/font/basicfont"
 | 
				
			||||||
 | 
						"golang.org/x/image/math/fixed"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const (
 | 
					const (
 | 
				
			||||||
	Size       = 128
 | 
						Size = 128
 | 
				
			||||||
	Iterations = 1<<16 - 1
 | 
						//Iterations = (1<<16 - 1) / 256
 | 
				
			||||||
 | 
						Iterations = (1<<16 - 1) / 128
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var (
 | 
					var (
 | 
				
			||||||
@@ -46,8 +52,8 @@ func main() {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	colorStep := float64(Iterations)
 | 
						colorStep := float64(Iterations)
 | 
				
			||||||
	//	colors = interpolateColors("Plan9", colorStep)
 | 
					
 | 
				
			||||||
	colors = interpolateColors("Solarized", colorStep)
 | 
						colors = interpolateColors("Hippi", colorStep)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	log.Fatal(http.ListenAndServe(":6161", nil))
 | 
						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 {
 | 
					func interpolateColors(paletteCode string, numberOfColors float64) []color.RGBA {
 | 
				
			||||||
	var factor float64
 | 
						var factor float64
 | 
				
			||||||
	steps := []float64{}
 | 
						steps := []float64{}
 | 
				
			||||||
@@ -132,6 +138,7 @@ func linearInterpolation(c1, c2, mu uint32) uint32 {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func renderTile(w http.ResponseWriter, r *http.Request) {
 | 
					func renderTile(w http.ResponseWriter, r *http.Request) {
 | 
				
			||||||
 | 
						r.ParseForm()
 | 
				
			||||||
	components := strings.Split(r.URL.Path, "/")[1:]
 | 
						components := strings.Split(r.URL.Path, "/")[1:]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if len(components) != 4 || components[0] != "mandelbrot" || components[3][len(components[3])-4:] != ".png" {
 | 
						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()
 | 
						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")
 | 
						w.Header().Set("Content-Type", "image/png")
 | 
				
			||||||
	png.Encode(w, img)
 | 
						png.Encode(w, img)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -181,3 +198,16 @@ func mandelbrot(c complex128) uint16 {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	return Iterations
 | 
						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
 | 
								return
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							r.ParseForm()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		fmt.Fprintf(w, `<!DOCTYPE html>
 | 
							fmt.Fprintf(w, `<!DOCTYPE html>
 | 
				
			||||||
<html>
 | 
					<html>
 | 
				
			||||||
<head>
 | 
					<head>
 | 
				
			||||||
<title>MandelMapper</title>
 | 
					<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:type" content="website" />
 | 
				
			||||||
<meta property="og:title" content="Mandelbrot Mapper">
 | 
					<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: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:image" content="https://deadbeef.codes/img/mandelbrot.png" />
 | 
				
			||||||
<meta property="og:site_name" content="deadbeef.codes">
 | 
					<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>
 | 
					<script>
 | 
				
			||||||
var mandelbrotTypeOptions = {
 | 
					var mandelbrotTypeOptions = {
 | 
				
			||||||
	getTileUrl: function(coord, zoom) {
 | 
						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),
 | 
						tileSize: new google.maps.Size(128, 128),
 | 
				
			||||||
	maxZoom: (1<<16),
 | 
						maxZoom: (1<<16),
 | 
				
			||||||
@@ -67,6 +69,6 @@ function initialize() {
 | 
				
			|||||||
<body onload="initialize()">
 | 
					<body onload="initialize()">
 | 
				
			||||||
<div id="map_canvas"></div>
 | 
					<div id="map_canvas"></div>
 | 
				
			||||||
</body>
 | 
					</body>
 | 
				
			||||||
</html>`)
 | 
					</html>`, r.FormValue("label"))
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user