Skip to content

feat: mosaic support (halfblocks)#404

Merged
raphamorim merged 6 commits intomainfrom
mosaic
Mar 11, 2025
Merged

feat: mosaic support (halfblocks)#404
raphamorim merged 6 commits intomainfrom
mosaic

Conversation

@raphamorim
Copy link
Member

Convert images to strings using half blocks symbols

TODO

  • Rework API to mosaic.New().Width(100).Height(40).Render(img)
  • Use draw.Scaler
  • Use draw.FloydSteinberg

Added examples

Simple Example

func main() {
	dogImg, err := loadImage("./pekinas.jpg")
	if err != nil {
		fmt.Print(err)
		os.Exit(1)
	}

	m := mosaic.New().Width(80).Height(80).Scale(2)

	fmt.Println(lipgloss.JoinVertical(lipgloss.Right, lipgloss.JoinHorizontal(lipgloss.Center, m.Render(dogImg))))
}
Screenshot 2025-03-06 at 13 08 53 Screenshot 2025-03-06 at 13 08 48

Scaling

Scales uses bilinear, which works at least as well as the others do in every situation. So prob use Bilinear for upscaling and downscaling as default.

scaling 1x and 2x:

Screenshot 2025-03-07 at 13 14 15

Other examples

Screenshot 2025-03-07 at 13 13 11 Screenshot 2025-02-27 at 15 05 53

Related

Copy link
Member

@aymanbagabas aymanbagabas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

few nit picks, other than that, lgtm

@raphamorim raphamorim requested a review from aymanbagabas March 11, 2025 19:59
@raphamorim raphamorim merged commit 12f357c into main Mar 11, 2025
8 checks passed
@raphamorim raphamorim deleted the mosaic branch March 11, 2025 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants