• Stars
    star
    201
  • Rank 194,491 (Top 4 %)
  • Language
    Go
  • License
    MIT License
  • Created about 9 years ago
  • Updated about 9 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Go image composer

Picasso, a Go image composer

Build Status Coverage GoDoc

Example

Manual layout handling

The following code:

image := picasso.HorizontalSplit{
	Ratio: 2,
	Top:   picasso.Picture{bullfight},
	Bottom: picasso.VerticalSplit{
		Ratio: 0.5,
		Left:  picasso.Picture{girlBeforeAMirror},
		Right: picasso.VerticalSplit{
			Ratio: 1,
			Left:  picasso.Picture{oldGuitarist},
			Right: picasso.Picture{womenOfAlgiers},
		},
	},
}.Draw(400, 600)

Will compose the following image:

manual

Automatic layouts

Picasso also supports different automatic layouts and borders, so that the following code:

images := []image.Image{
	girlBeforeAMirror,
	oldGuitarist,
	womenOfAlgiers,
	bullfight,
	weepingWoman,
	laReve,
}
layout := picasso.GoldenSpiralLayout()
gray := color.RGBA{0xaf, 0xaf, 0xaf, 0xff}
image := layout.Compose(images).DrawWithBorder(600, 600, gray, 2)

Will compose an image using the golden ratio:

automatic

Or one could use the GridLayout:

images := []image.Image{...}
gray := color.RGBA{0xaf, 0xaf, 0xaf, 0xff}
image := picasso.DrawGridLayoutWithBorder(images, 800, gray, 2)

to compose larger sets of images:

composed

See tests for more examples