gorobohash

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

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

Go to latest
Published: Apr 7, 2022 License: MIT Imports: 18 Imported by: 0

README

GoRobohash

Robohash Project Go Version, origin from e1ven/Robohash

Readme

[English] [简体中文]

Main File Tree

|-- material/... Materials needed to assemble pictures: License
|-- robohash.go Origin Code: robohash.py

How to use

go get -u github.com/Eminlin/GoRobohash

Example

import (
	gorobohash "github.com/Eminlin/GoRobohash"
)

func main() {
	r, err := gorobohash.NewResource("hello", &gorobohash.AssembleOptions{}).GeneratePNG()
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(r)
    // print: ./hello.png <nil>
}

Then you can get a picture with the same style as robohash.org

Config

type AssembleOptions struct {
    RoboSet, Colors, BgSet string //optional
    OutputPath             string //optional default current path
    X                      int    //optional default 300
    Y                      int    //optional default 300
}

More usage can be found in demo.go.

Tips

Original project has many static resources, if you need go build on other machines, you need to ensure the resources exist on the machine. I recommend you to directly execute go get -u github.com/Eminlin/GoRobohash on the machine.

Not support bmp format picture yet.

Recommend generate png format picture.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewResource

func NewResource(text string, options *AssembleOptions) *resource

newResource new resource

Types

type AssembleOptions

type AssembleOptions struct {
	RoboSet, Colors, BgSet string //optional
	OutputPath             string //optional default current dir
	X                      int    //optional default 300
	Y                      int    //optional default 300
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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