galaxygen

package module
v0.0.0-...-f22e042 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2016 License: MIT Imports: 2 Imported by: 0

README

galaxygen

Package galaxygen generates realistic-looking star galaxies.

This algorithm was originally made in c++, by:

Bryon Mau (www.cyberbrinedreams.com)

And was then modified (in c++) by:

Patrick Down (www.codemoon.com)

This was done years ago and both sites now seems to be down.

This go port was made from the salvaged parts from my shitty python port (done ages ago too), that was based on the original c++ source. It has now been cleaned up and made easier to read.

Install

go get github.com/lmas/galaxygen

Usage

import (
    "time"
    "math/rand"
    "github.com/lmas/galaxygen"
)

// Set a new seed to get random galaxies each time.
rand.Seed(time.Now().UnixNano())

// Make a new galaxy with at most 5000 stars, in 5 arms spread out in a radius
// of 100 points.
starmap := galaxygen.New(5000, 5, 100.0)

See examples/ for more usage examples.

License

I have no idea if and what license the original code had, but I've decided to release my implementation under the MIT license anyway.

If you are the original author and don't like it, please contact me and we'll sort it out. :)

Documentation

Overview

Package galaxygen generates realistic-looking star galaxies.

This algorithm was originally made in c++, by:

Bryon Mau (www.cyberbrinedreams.com)

And was then modified (in c++) by:

Patrick Down (www.codemoon.com)

This was done years ago and both sites now seems to be down.

This go port was made from the salvaged parts from my shitty python port (done ages ago too), that was based on the original c++ source. It has now been cleaned up and made easier to read.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Star

type Star struct {
	X int
	Y int
}

Star is nothing more but a point in 2D space.

func New

func New(stars, arms int, radius float64) []*Star

New generates a new galaxy filled with "stars". It lazely try to make x stars (but it's usually lower due to removed duplicates).

Directories

Path Synopsis
examples
ascii command
plot command

Jump to

Keyboard shortcuts

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