diff --git a/config/config.go b/config/config.go index 30021dc..8829071 100644 --- a/config/config.go +++ b/config/config.go @@ -14,35 +14,35 @@ import ( ) type ConfigS struct { - FPSCounter bool - ShowMPRIS bool - TargetFPS int32 - WindowWidth int32 - WindowHeight int32 - WindowOpacity float32 - CaptureDeviceIndex int - SampleRate uint32 - RingBufferSize uint32 - ReadBufferSize uint32 - Gain float32 - LineOpacity uint8 - LineThickness float32 + FPSCounter bool + ShowMPRIS bool + TargetFPS int32 + WindowWidth int32 + WindowHeight int32 + CaptureDeviceIndex int + SampleRate uint32 + RingBufferSize uint32 + ReadBufferSize uint32 + Gain float32 + LineOpacity uint8 + LineThickness float32 + LineInvSqrtOpacityControl bool } var DefaultConfig = ConfigS{ - FPSCounter: false, - ShowMPRIS: true, - TargetFPS: 60, - WindowWidth: 1080, - WindowHeight: 1080, - WindowOpacity: 0.8, - CaptureDeviceIndex: 0, - SampleRate: 48000, - RingBufferSize: 4800, - ReadBufferSize: 4800, - Gain: 1, - LineOpacity: 50, - LineThickness: 2, + FPSCounter: false, + ShowMPRIS: true, + TargetFPS: 240, + WindowWidth: 1300, + WindowHeight: 1300, + CaptureDeviceIndex: 0, + SampleRate: 96000, + RingBufferSize: 9600, + ReadBufferSize: 9600, + Gain: 1, + LineOpacity: 100, + LineThickness: 3, + LineInvSqrtOpacityControl: false, } var Config ConfigS diff --git a/icons/assets/icon-16-32.xcf b/icons/assets/icon-16-32.xcf new file mode 100644 index 0000000..acceb68 Binary files /dev/null and b/icons/assets/icon-16-32.xcf differ diff --git a/icons/assets/icon-16.png b/icons/assets/icon-16.png new file mode 100644 index 0000000..e6bd995 Binary files /dev/null and b/icons/assets/icon-16.png differ diff --git a/icons/assets/icon-32.png b/icons/assets/icon-32.png new file mode 100644 index 0000000..64ab976 Binary files /dev/null and b/icons/assets/icon-32.png differ diff --git a/icons/assets/icon-48.png b/icons/assets/icon-48.png new file mode 100644 index 0000000..83ac519 Binary files /dev/null and b/icons/assets/icon-48.png differ diff --git a/icons/assets/icon-48.xcf b/icons/assets/icon-48.xcf new file mode 100644 index 0000000..d2b79e3 Binary files /dev/null and b/icons/assets/icon-48.xcf differ diff --git a/icons/icons.go b/icons/icons.go new file mode 100644 index 0000000..893fe05 --- /dev/null +++ b/icons/icons.go @@ -0,0 +1,35 @@ +package icons + +import ( + "embed" + "image" + _ "image/png" + "xyosc/utils" +) + +//go:embed assets/icon-48.png +//go:embed assets/icon-16.png +//go:embed assets/icon-32.png +var fs embed.FS + +var WindowIcon48 image.Image +var WindowIcon32 image.Image +var WindowIcon16 image.Image + +func Init() { + f48, err := fs.Open("assets/icon-48.png") + utils.CheckError(err) + defer f48.Close() + WindowIcon48, _, err = image.Decode(f48) + utils.CheckError(err) + f32, err := fs.Open("assets/icon-32.png") + utils.CheckError(err) + defer f32.Close() + WindowIcon32, _, err = image.Decode(f32) + utils.CheckError(err) + f16, err := fs.Open("assets/icon-16.png") + utils.CheckError(err) + defer f16.Close() + WindowIcon16, _, err = image.Decode(f16) + utils.CheckError(err) +} diff --git a/main.go b/main.go index 5e5959a..8b10f11 100644 --- a/main.go +++ b/main.go @@ -2,10 +2,14 @@ package main import ( "encoding/binary" + "image" + "image/color" "log" "xyosc/audio" "xyosc/config" + "xyosc/fastsqrt" "xyosc/fonts" + "xyosc/icons" "xyosc/media" "fmt" @@ -38,9 +42,15 @@ func (g *Game) Draw(screen *ebiten.Image) { fAY := -float32(AY) * config.Config.Gain * float32(scale) fBX := float32(BX) * config.Config.Gain * float32(scale) fBY := -float32(BY) * config.Config.Gain * float32(scale) - //inv := fastsqrt.FastInvSqrt32((fBX-fAX)*(fBX-fAX) + (fBY-fBY)*(fBY-fBY)) - //colorAdjusted := color.RGBA{config.AccentColor.R, config.AccentColor.G, config.AccentColor.B, uint8(255 * inv * config.Config.LineOpacity)} - 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) + 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)} + 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) + + } AX = BX AY = BY } @@ -84,10 +94,13 @@ func main() { config.Init() audio.Init() fonts.Init() + icons.Init() go audio.Start() go media.Start() + ebiten.SetWindowIcon([]image.Image{icons.WindowIcon48, icons.WindowIcon32, icons.WindowIcon16}) ebiten.SetWindowSize(int(config.Config.WindowWidth), int(config.Config.WindowHeight)) ebiten.SetWindowTitle("xyosc") + ebiten.SetWindowMousePassthrough(true) ebiten.SetTPS(int(config.Config.TargetFPS)) ebiten.SetWindowDecorated(false) screenW, screenH := ebiten.Monitor().Size()