comicgen

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2024 License: MIT Imports: 29 Imported by: 6

README

comicgen

A stupid comic generator.

GoDoc Go Walker Go report Build Status

Documentation

Index

Constants

View Source
const (
	EmotionAngry    Emotion = "angry"
	EmotionBored            = "bored"
	EmotionHappy            = "happy"
	EmotionHi               = "hi"
	EmotionIdle             = "idle"
	EmotionLove             = "love"
	EmotionMe               = "me"
	EmotionQuestion         = "question"
	EmotionSad              = "sad"
	EmotionScared           = "scared"
	EmotionSmug             = "smug"
	EmotionWalk             = "walk"
	EmotionYell             = "yell"
	EmotionYou              = "you"
)

All the possible emotion states.

View Source
const ReplacementUnicode = 0xF0000

Variables

This section is empty.

Functions

func CharacterNames

func CharacterNames() string

Types

type Cast

type Cast struct {
	CharacterSets []*CharacterSet
}

func (*Cast) AddCharacterSet

func (c *Cast) AddCharacterSet(cs *CharacterSet) error

func (*Cast) GetCharacterSetByName

func (c *Cast) GetCharacterSetByName(name string) *CharacterSet

func (*Cast) GetCharacters

func (c *Cast) GetCharacters() []*Character

func (*Cast) LoadFromDirectory

func (c *Cast) LoadFromDirectory(path string) error

type Character

type Character struct {
	FileName string            `json:"filename"`
	Name     string            `json:"name"`
	Width    int               `json:"width"`
	Height   int               `json:"height"`
	Chance   int               `json:"chance"`
	Emotions map[Emotion][]int `json:"Emotions"`
	Image    image.Image
}

A Character contains the information necessary to draw one character in a comic.

func (*Character) GetFrame

func (c *Character) GetFrame(message string) int

GetFrame will return a frame for a message. It will parse any emotion from the message and randomly select a matching frame for those emotions.

func (*Character) MaxFrame

func (c *Character) MaxFrame() int

MaxFrame returns the highest frame number available to the character.

type CharacterSet

type CharacterSet struct {
	Name       string       `json:"name"`
	History    string       `json:"history"`
	Author     string       `json:"author"`
	AuthorID   string       `json:"authorID"`
	Locations  []*Location  `json:"location"`
	Characters []*Character `json:"characters"`
}

func (*CharacterSet) GetMap

func (cs *CharacterSet) GetMap() map[string]*Character

func (*CharacterSet) GetRandomCharacters

func (cs *CharacterSet) GetRandomCharacters() []*Character

func (*CharacterSet) LoadFromFile

func (cs *CharacterSet) LoadFromFile(path string) error

type ComicGen

type ComicGen struct {
	sync.Mutex
	// contains filtered or unexported fields
}

ComicGen is a comic generator!

func NewComicGen

func NewComicGen(font string, useGoogleEmoji bool) *ComicGen

NewComicGen creates a new comic generator.

func (*ComicGen) MakeComic

func (comic *ComicGen) MakeComic(script *Script) (img image.Image, err error)

MakeComic makes a comic.

type ComicType

type ComicType int

A ComicType specifies the type of comic to create.

const (
	// ComicTypeSimple generates a comic with large text bubbles and avatars.
	ComicTypeSimple ComicType = iota
	// ComicTypeChat emulates Microsoft Comic Chat and creates a comic with characters and backgrounds.
	ComicTypeChat
	// ComicTypeTragedy is the same as ComicTypeChat but with unique characters.
	ComicTypeTragedy
)

type Emotion

type Emotion string

An Emotion is a possible state for a character in a comic.

type Location

type Location struct {
	Name     string `json:"name"`
	FileName string `json:"filename"`
}

type Message

type Message struct {
	Text string

	Author       string
	Replacements map[string]string
	ImageUrl     string
	// contains filtered or unexported fields
}

Message contains a single message for a comment.

type MultiBounds

type MultiBounds struct {
	AllBounds  [][]float64
	LineHeight float64
}

MultiBounds is a struct containing bounds information for multiple lines of text.

func (*MultiBounds) AddBound

func (m *MultiBounds) AddBound(l, t, r, b float64)

AddBound will add a new bound.

func (*MultiBounds) AddStringBounds

func (m *MultiBounds) AddStringBounds(l, t, r, b float64)

AddStringBounds will add a new bound and automodify the bound to be positioned on the next line.

func (*MultiBounds) Bounds

func (m *MultiBounds) Bounds() (l, t, r, b float64)

Bounds returns the total bounds of all lines.

func (*MultiBounds) GetBound

func (m *MultiBounds) GetBound(i int) (float64, float64, float64, float64)

GetBound returns the bound at the desired line.

func (*MultiBounds) Length

func (m *MultiBounds) Length() int

Length returns the number of lines contained in the MultiBounds.

func (*MultiBounds) Offset

func (m *MultiBounds) Offset(offset *MultiBounds) *MultiBounds

Offset returns a new MultiBound offset by another.

type Script

type Script struct {
	Type     ComicType
	Messages []*Message
	Avatars  map[string]string
	Author   string
	Room     string
}

Script contains all the data necessary to generate a comic.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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