Documentation
¶
Overview ¶
Package wordcloud generates word clouds from frequencies using native Go. It has no tokenizer, filesystem, network, or application dependencies.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoWords = errors.New("wordcloud: no positive word frequencies") ErrNoSpace = errors.New("wordcloud: no words fit the canvas") )
Functions ¶
This section is empty.
Types ¶
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator is immutable and safe for concurrent Generate calls. Each call owns its random source, font faces, and occupancy map. Callers must not mutate frequency maps during Generate. The same inputs and seed reproduce a layout.
func (*Generator) GenerateSeeded ¶
func (g *Generator) GenerateSeeded(ctx context.Context, frequencies map[string]int, seed uint64) (*Result, error)
GenerateSeeded reuses the immutable parsed font with a per-call layout seed. The shallow copy owns its options value; the palette and font stay read-only.
type Options ¶
type Options struct {
Width, Height int
MaxWords int
MinFontSize, MaxFontSize, FontStep int
Margin int
PreferHorizontal, RelativeScaling float64
Seed uint64
Background color.NRGBA
Palette []color.NRGBA
}
Options controls layout. Start with DefaultOptions; zero is meaningful for Margin, PreferHorizontal, RelativeScaling, Seed, and MaxFontSize.
func DefaultOptions ¶
func DefaultOptions() Options
DefaultOptions returns settings for a 600x400 cloud on a white background. MaxFontSize=0 estimates the initial size by fitting the two largest words.