Added ExtraWidth and AdditionalPadding Variables

This commit is contained in:
aditya-K2
2023-04-13 09:14:38 +05:30
parent 32789a1370
commit 9d1b2020f3
2 changed files with 14 additions and 6 deletions

View File

@@ -149,7 +149,7 @@ func NewApplication() *Application {
if draw {
go func() {
for {
_ImgX, _ImgY, _ImgW, _ImgH := Ui.CoverArt.GetInnerRect()
_ImgX, _ImgY, _ImgW, _ImgH := Ui.CoverArt.GetRect()
if start {
RefreshProgress()
start = false

View File

@@ -6,12 +6,20 @@ import (
"os"
"github.com/aditya-K2/utils"
"github.com/gdamore/tcell/v2"
"github.com/nfnt/resize"
"github.com/rivo/tview"
"github.com/zmb3/spotify/v2"
"gitlab.com/diamondburned/ueberzug-go"
)
var (
ax = 5
ay = 10
ex = -0.47
ey = -1.5
)
type CoverArt struct {
*tview.Box
image *ueberzug.Image
@@ -19,7 +27,7 @@ type CoverArt struct {
func newCoverArt() *CoverArt {
return &CoverArt{
tview.NewBox(),
tview.NewBox().SetBorder(true).SetBackgroundColor(tcell.ColorDefault),
nil,
}
}
@@ -37,8 +45,8 @@ func getImg(uri string) (image.Image, error) {
}
fw, fh := utils.GetFontWidth()
img = resize.Resize(
uint(float32(ImgW)*(fw+float32(10))),
uint(float32(ImgH)*(fh+float32(10))),
uint(float32(ImgW)*(fw+float32(ex))),
uint(float32(ImgH)*(fh+float32(ey))),
img,
resize.Bilinear,
)
@@ -89,8 +97,8 @@ func (c *CoverArt) RefreshState() {
return
}
im, err := ueberzug.NewImage(uimg,
int(float32(ImgX)*fw),
int(float32(ImgY)*fh))
int(float32(ImgX)*fw)+ax,
int(float32(ImgY)*fh)+ay)
if err != nil {
SendNotification(fmt.Sprintf("Error Rendering Image: %s", err.Error()))
return