From 53022419cf0825023c9c181487f839cf6cc265ff Mon Sep 17 00:00:00 2001 From: Louis Dalibard Date: Sat, 2 Nov 2024 23:58:30 +0100 Subject: [PATCH] feat: various fixes --- config/config.go | 9 ++++++++- main.go | 12 +++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/config/config.go b/config/config.go index 8829071..af47878 100644 --- a/config/config.go +++ b/config/config.go @@ -16,6 +16,7 @@ import ( type ConfigS struct { FPSCounter bool ShowMPRIS bool + MPRISTextOpacity uint8 TargetFPS int32 WindowWidth int32 WindowHeight int32 @@ -25,6 +26,7 @@ type ConfigS struct { ReadBufferSize uint32 Gain float32 LineOpacity uint8 + LineBrightness float64 LineThickness float32 LineInvSqrtOpacityControl bool } @@ -32,6 +34,7 @@ type ConfigS struct { var DefaultConfig = ConfigS{ FPSCounter: false, ShowMPRIS: true, + MPRISTextOpacity: 255, TargetFPS: 240, WindowWidth: 1300, WindowHeight: 1300, @@ -40,7 +43,8 @@ var DefaultConfig = ConfigS{ RingBufferSize: 9600, ReadBufferSize: 9600, Gain: 1, - LineOpacity: 100, + LineOpacity: 200, + LineBrightness: 1, LineThickness: 3, LineInvSqrtOpacityControl: false, } @@ -50,6 +54,7 @@ var Config ConfigS var AccentColor color.RGBA var FirstColor color.RGBA var ThirdColor color.RGBA +var ThirdColorAdj color.RGBA var watcher *fsnotify.Watcher @@ -119,6 +124,7 @@ func updatePywalColors() { AccentColor = color.RGBA{255, 0, 0, Config.LineOpacity} FirstColor = color.RGBA{255, 120, 120, Config.LineOpacity} ThirdColor = color.RGBA{255, 0, 0, Config.LineOpacity} + ThirdColorAdj = color.RGBA{uint8(255 * Config.LineBrightness), 0, 0, Config.LineOpacity} } else { fh, err := os.Open(walFile) utils.CheckError(err) @@ -141,6 +147,7 @@ func updatePywalColors() { rgbaColor, err = ParseHexColor(scanner.Text()) utils.CheckError(err) ThirdColor = color.RGBA{rgbaColor.R, rgbaColor.G, rgbaColor.B, Config.LineOpacity} + ThirdColorAdj = color.RGBA{uint8(float64(rgbaColor.R) * Config.LineBrightness), uint8(float64(rgbaColor.G) * Config.LineBrightness), uint8(float64(rgbaColor.B) * Config.LineBrightness), Config.LineOpacity} break } line++ diff --git a/main.go b/main.go index 8b10f11..b48bbb7 100644 --- a/main.go +++ b/main.go @@ -45,10 +45,10 @@ func (g *Game) Draw(screen *ebiten.Image) { if config.Config.LineInvSqrtOpacityControl { inv := fastsqrt.FastInvSqrt32((fBX-fAX)*(fBX-fAX) + (fBY-fBY)*(fBY-fBY)) - colorAdjusted := color.RGBA{config.AccentColor.R, config.AccentColor.G, config.AccentColor.B, uint8(float32(config.Config.LineOpacity) * inv)} + colorAdjusted := color.RGBA{config.ThirdColor.R, config.ThirdColor.G, config.ThirdColor.B, uint8(float32(config.Config.LineOpacity) * inv)} vector.StrokeLine(screen, float32(config.Config.WindowWidth/2)+fAX, float32(config.Config.WindowWidth/2)+fAY, float32(config.Config.WindowWidth/2)+fBX, float32(config.Config.WindowWidth/2)+fBY, config.Config.LineThickness, colorAdjusted, true) } else { - vector.StrokeLine(screen, float32(config.Config.WindowWidth/2)+fAX, float32(config.Config.WindowWidth/2)+fAY, float32(config.Config.WindowWidth/2)+fBX, float32(config.Config.WindowWidth/2)+fBY, config.Config.LineThickness, config.AccentColor, true) + vector.StrokeLine(screen, float32(config.Config.WindowWidth/2)+fAX, float32(config.Config.WindowWidth/2)+fAY, float32(config.Config.WindowWidth/2)+fBX, float32(config.Config.WindowWidth/2)+fBY, config.Config.LineThickness, config.ThirdColorAdj, true) } AX = BX @@ -62,7 +62,7 @@ func (g *Game) Draw(screen *ebiten.Image) { if config.Config.ShowMPRIS { op := &text.DrawOptions{} op.GeoM.Translate(16, 16) - op.ColorScale.ScaleWithColor(config.AccentColor) + op.ColorScale.ScaleWithColor(color.RGBA{config.AccentColor.R, config.AccentColor.G, config.AccentColor.B, config.Config.MPRISTextOpacity}) text.Draw(screen, media.PlayingMediaInfo.Artist+" - "+media.PlayingMediaInfo.Title, &text.GoTextFace{ Source: fonts.Font, Size: 32, @@ -70,7 +70,8 @@ func (g *Game) Draw(screen *ebiten.Image) { op = &text.DrawOptions{} op.GeoM.Translate(16, 64) - op.ColorScale.ScaleWithColor(config.ThirdColor) + op.ColorScale.ScaleWithColor(color.RGBA{config.ThirdColor.R, config.ThirdColor.G, config.ThirdColor.B, config.Config.MPRISTextOpacity}) + text.Draw(screen, media.PlayingMediaInfo.Album, &text.GoTextFace{ Source: fonts.Font, Size: 16, @@ -78,7 +79,8 @@ func (g *Game) Draw(screen *ebiten.Image) { op = &text.DrawOptions{} op.GeoM.Translate(16, 80) - op.ColorScale.ScaleWithColor(config.AccentColor) + op.ColorScale.ScaleWithColor(color.RGBA{config.AccentColor.R, config.AccentColor.G, config.AccentColor.B, config.Config.MPRISTextOpacity}) + text.Draw(screen, media.FmtDuration(media.PlayingMediaInfo.Position)+" / "+media.FmtDuration(media.PlayingMediaInfo.Duration), &text.GoTextFace{ Source: fonts.Font, Size: 32,