Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: mosaic support (halfblocks) #404

Merged
merged 6 commits into from
Mar 11, 2025
Merged

feat: mosaic support (halfblocks) #404

merged 6 commits into from
Mar 11, 2025

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