biome

package module
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 25, 2019 License: BSL-1.0 Imports: 10 Imported by: 0

README

Biome

Biome is tool of image processing and generatig written in Go (Golang).

Installation

Installation is done using go get.

go get -u github.com/tomowarkar/biome

Godoc

https://godoc.org/github.com/tomowarkar/biome

Quick start

# assume the following codes in example.go file
$ cat example.go

# run example.go
$ go run example.go
flactal
package main

import (
	"image/color"
	"time"

	"github.com/tomowarkar/biome/fractal"
)

var (
	sea    = color.RGBA{65, 105, 225, 255}
	beach  = color.RGBA{240, 230, 140, 255}
	island = color.RGBA{184, 134, 11, 255}
	forest = color.RGBA{46, 139, 87, 255}
	snow   = color.RGBA{255, 255, 255, 255}
)

func main() {
	seed := time.Now().UnixNano()
	world := fractal.Flactal(320, 480, seed)

	var palette []color.Color

	for i := 0; i < 256; i++ {
		if i < 150 {
			palette = append(palette, sea)
		} else if i < 160 {
			palette = append(palette, beach)
		} else if i < 190 {
			palette = append(palette, island)
		} else if i < 240 {
			palette = append(palette, forest)
		} else {
			palette = append(palette, snow)
		}
	}

	world.ToPng("image", 1, palette)
}
maze
package main

import (
	"image/color"
	"time"

	"github.com/tomowarkar/biome/maze"
)

func main() {
	mazeWidth, mazeHeight := 37, 27
	m := maze.NewMaze(mazeHeight, mazeWidth)
	seed := time.Now().UnixNano()

	palette := []color.Color{
		color.RGBA{184, 134, 11, 255},
		color.RGBA{240, 230, 140, 255},
		color.RGBA{255, 0, 255, 255},
	}

	m.StickDown(seed)
	m.Solve()
	m.ToPng("maze1", 10, palette)

	m.Digging(seed)
	m.Solve()
	m.ToPng("maze2", 10, palette)
}
gif
package main

import (
	"image/color"
	"time"

	"github.com/tomowarkar/biome/maze"
)

func main() {
	w, h := 61, 49
	m := maze.NewMaze(h, w)
	var datas [][]int

	for i := 0; i < 10; i++ {
		seed := time.Now().UnixNano()
		m.StickDown(seed)
		datas = append(datas, m.Data())
		m.Solve()
		datas = append(datas, m.Data())
		m.Digging(seed)
		datas = append(datas, m.Data())
		m.Solve()
		datas = append(datas, m.Data())
	}

	palette := []color.Color{
		color.RGBA{184, 134, 11, 255},
		color.RGBA{240, 230, 140, 255},
		color.RGBA{255, 0, 255, 255},
	}

	maze.ToGif("gif", w, h, 10, 50, datas, palette)
}
fractal islands
maze
paint

image processing

original gray
sepia mosaic

original image source (https://ja.wikipedia.org/wiki/%E9%A2%A8%E6%99%AF )

License

Biome is free and open-source software licensed under the Boost Software License, Version 1.0.(See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

Author

tomowarkar twitter blog

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func F2uint8

func F2uint8(m float64) uint8

F2uint8 :

func Gray

func Gray(imgSrc image.Image) image.Image

Gray :

func MaxFloat

func MaxFloat(a, b float64) float64

MaxFloat :

func MaxInt

func MaxInt(a, b int) int

MaxInt :

func MinInt

func MinInt(a, b int) int

MinInt :

func ReadImage

func ReadImage(path string) (imgSrc image.Image)

ReadImage :

func Sepia

func Sepia(imgSrc image.Image) image.Image

Sepia :

func Shade

func Shade(oddnum int, imgSrc image.Image) image.Image

Shade :

func Slice2Image

func Slice2Image(width, height, scale int, data []int, palette []color.Color) image.Image

Slice2Image : 1次元Intスライスを元にimage.Imageを生成

func Slice2Paletted

func Slice2Paletted(width, height, scale int, data []int, palette []color.Color) *image.Paletted

Slice2Paletted : 1次元Intスライスを元にimage.Palettedを生成

func ToGif

func ToGif(filename string, images []*image.Paletted, delay int)

ToGif : 2次元Intスライスを元にGIF画像を生成

func ToPng

func ToPng(filename string, imgSrc image.Image)

ToPng : 1次元Intスライスを元にpng画像を生成

func ToStr

func ToStr(n int) string

ToStr : convert int to string

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL