Additional Padding for Cover art to fit correctly

As specified in #2 the image gets out of the preview box, the previous
commit solves the problem but the image placement in the box differs
from terminal to terminal it might need some extra padding so user can
define some extra padding in the render.go
This commit is contained in:
aditya-K2 2021-10-29 10:14:57 +05:30
parent 97b2e4c4bc
commit 93e6885ae9
2 changed files with 16 additions and 25 deletions

View File

@ -11,7 +11,6 @@ https://user-images.githubusercontent.com/51816057/138585868-92aff5bd-dd7e-46af-
- [ ] Add Functionality to Sort out most played songs
- [ ] Add a config parser ( preferably ***YAML*** )
- [x] Image Previews
- The Image Previews are working but the placement is very hacky and needs some work
- [ ] Fuzzy Searching
- [ ] Visual Mode (like vim) for updating playlists
- [ ] Music Visualizer
@ -20,18 +19,27 @@ https://user-images.githubusercontent.com/51816057/138585868-92aff5bd-dd7e-46af-
- Music Player Daemon must be setup
- Go Should Be Installed ( for building )
- Set the Path to your mpd DATABASE in progressbar.go
- Set the Path to your mpd DATABASE in [progressbar.go](https://github.com/aditya-K2/goMP/blob/master/progressBar.go)
```go
var DBDIR string = "PATH TO YOUR MPD DATABASE HERE"
```
- In imageUtils.go set the path for your default Image
- In [imageUtils.go](https://github.com/aditya-K2/goMP/blob/master/imageUtils.go) set the path for your default Image
```go
var path string = "YOUR DEFAULT IMAGE PATH HERE"
```
- Change the default additional Image padding according to your terminal in [render.go](https://github.com/aditya-K2/goMP/blob/master/render.go)
```go
// Change according to your needs
var ADDITIONAL_PADDING_X int = 16
var ADDITIONAL_PADDING_Y int = 24
```
# Installing / Building
```bash
@ -39,24 +47,3 @@ git clone https://github.com/aditya-K2/goMP &&
cd goMP &&
go build
```
## Image Placement
The image is rendered by calculating pixels by multiplying the rows and columns with the font-width which is calculated by dividing the terminal width and height ( Please let me know if there is a better way to do this ) this let's to uneven placement so it is better that you disable the borders for the imagePreview holder.
in [App.go](https://github.com/aditya-K2/goMP/blob/master/App.go)
```go
imagePreviewer.SetBorder(false)
```
#### With Borders ( Sometimes \[Mostly Maximized Terminals\] )
![Oct28(Thu)02:4134PM](https://user-images.githubusercontent.com/51816057/139225915-b3e30742-65a8-4482-ad38-753646b5082f.png)
#### Without Borders
![Oct28(Thu)02:4513PM](https://user-images.githubusercontent.com/51816057/139226138-b68ebc22-204c-40f7-a7f2-0dd92b88f72b.png)
Note: Your terminal window padding also affects the tui.

View File

@ -13,6 +13,9 @@ type Renderer struct {
c chan string
}
var ADDITIONAL_PADDING_X int = 16
var ADDITIONAL_PADDING_Y int = 24
/*
Returns a new Renderer with a string channel
*/
@ -39,10 +42,11 @@ func (self *Renderer) Send(path string) {
*/
func openImage(path string, c chan string) {
fw, fh := getFontWidth()
var im *ueberzug.Image
if path != "stop" {
img2, _ := getImg(getAlbumArt(path))
im, _ = ueberzug.NewImage(img2, (IMG_X*10)+15, (IMG_Y*22)+10)
im, _ = ueberzug.NewImage(img2, int(float32(IMG_X)*fw)+ADDITIONAL_PADDING_X, int(float32(IMG_Y)*fh)+ADDITIONAL_PADDING_Y)
}
d := <-c
if im != nil {