Compare commits

..

No commits in common. "master" and "1.0" have entirely different histories.
master ... 1.0

9 changed files with 33 additions and 97 deletions

View File

@ -1,23 +1,21 @@
kind: pipeline
name: default
workspace:
base: /go
path: src/code.stevenpolley.net/steven/mandelmapper
path: src/deadbeef.codes/steven/mandelmapper
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
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}

View File

@ -1,5 +1,4 @@
FROM scratch
LABEL maintainer="himself@stevenpolley.net"
COPY mandelmapper /
FROM deadbeef.codes:5000/raspberrypi3-alpine:3.7
COPY mandelmapper /usr/bin
EXPOSE 6161:6161
ENTRYPOINT ["/mandelmapper"]
CMD mandelmapper

View File

@ -1,6 +1,3 @@
[![Build Status](https://drone.deadbeef.codes/api/badges/steven/mandelmapper/status.svg)](https://drone.deadbeef.codes/steven/mandelmapper)
This is currently deployed to a ARMv8 cluster, viewable at https://mandelmap.deadbeef.codes
testing drone ?
release
another drone test plz

View File

@ -1,8 +0,0 @@
version: '3.6'
services:
mandel-mapper:
image: registry.deadbeef.codes/mandelmapper:latest
ports:
- 6161:6161
restart: always

5
go.mod
View File

@ -1,5 +0,0 @@
module deadbeef.codes/steven/mandelmapper
go 1.22
require golang.org/x/image v0.22.0

4
go.sum
View File

@ -1,4 +0,0 @@
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=

View File

@ -361,13 +361,4 @@ 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}},
}},
}

View File

@ -1,7 +1,6 @@
package main
import (
"fmt"
"image"
"image/color"
"image/png"
@ -9,22 +8,17 @@ 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) / 256
Iterations = (1<<16 - 1) / 128
Size = 128
Iterations = 1<<16 - 1
)
var (
@ -52,8 +46,8 @@ func main() {
}
colorStep := float64(Iterations)
colors = interpolateColors("Hippi", colorStep)
// colors = interpolateColors("Plan9", colorStep)
colors = interpolateColors("Solarized", colorStep)
log.Fatal(http.ListenAndServe(":6161", nil))
}
@ -71,7 +65,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{}
@ -138,7 +132,6 @@ 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" {
@ -174,16 +167,6 @@ 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)
}
@ -198,16 +181,3 @@ 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
View File

@ -13,25 +13,23 @@ func init() {
return
}
r.ParseForm()
fmt.Fprintf(w, `<!DOCTYPE html>
<html>
<head>
<title>MandelMapper</title>
<meta property="og:url" content="https://mandelmap.deadbeef.codes/" />
<meta property="og:url" content="http://mc.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=AIzaSyDJJV_-Q2wIBlzYVzfIbZTapl-8tMoYxw8"></script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAZItO5CjoqDfPLwH_FZ4KcvQFt_L5dQBw"></script>
<script>
var mandelbrotTypeOptions = {
getTileUrl: function(coord, zoom) {
return '/mandelbrot/' + zoom + '/' + coord.x + '/' + coord.y + '.png?label=%s';
return '/mandelbrot/' + zoom + '/' + coord.x + '/' + coord.y + '.png';
},
tileSize: new google.maps.Size(128, 128),
maxZoom: (1<<16),
@ -69,6 +67,6 @@ function initialize() {
<body onload="initialize()">
<div id="map_canvas"></div>
</body>
</html>`, r.FormValue("label"))
</html>`)
})
}