feat: various fixes

This commit is contained in:
Louis Dalibard 2024-11-02 23:44:33 +01:00
parent 30694431e6
commit 63d987ff10
8 changed files with 77 additions and 29 deletions

View File

@ -19,7 +19,6 @@ type ConfigS struct {
TargetFPS int32 TargetFPS int32
WindowWidth int32 WindowWidth int32
WindowHeight int32 WindowHeight int32
WindowOpacity float32
CaptureDeviceIndex int CaptureDeviceIndex int
SampleRate uint32 SampleRate uint32
RingBufferSize uint32 RingBufferSize uint32
@ -27,22 +26,23 @@ type ConfigS struct {
Gain float32 Gain float32
LineOpacity uint8 LineOpacity uint8
LineThickness float32 LineThickness float32
LineInvSqrtOpacityControl bool
} }
var DefaultConfig = ConfigS{ var DefaultConfig = ConfigS{
FPSCounter: false, FPSCounter: false,
ShowMPRIS: true, ShowMPRIS: true,
TargetFPS: 60, TargetFPS: 240,
WindowWidth: 1080, WindowWidth: 1300,
WindowHeight: 1080, WindowHeight: 1300,
WindowOpacity: 0.8,
CaptureDeviceIndex: 0, CaptureDeviceIndex: 0,
SampleRate: 48000, SampleRate: 96000,
RingBufferSize: 4800, RingBufferSize: 9600,
ReadBufferSize: 4800, ReadBufferSize: 9600,
Gain: 1, Gain: 1,
LineOpacity: 50, LineOpacity: 100,
LineThickness: 2, LineThickness: 3,
LineInvSqrtOpacityControl: false,
} }
var Config ConfigS var Config ConfigS

BIN
icons/assets/icon-16-32.xcf Normal file

Binary file not shown.

BIN
icons/assets/icon-16.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 864 B

BIN
icons/assets/icon-32.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 953 B

BIN
icons/assets/icon-48.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
icons/assets/icon-48.xcf Normal file

Binary file not shown.

35
icons/icons.go Normal file
View File

@ -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)
}

17
main.go
View File

@ -2,10 +2,14 @@ package main
import ( import (
"encoding/binary" "encoding/binary"
"image"
"image/color"
"log" "log"
"xyosc/audio" "xyosc/audio"
"xyosc/config" "xyosc/config"
"xyosc/fastsqrt"
"xyosc/fonts" "xyosc/fonts"
"xyosc/icons"
"xyosc/media" "xyosc/media"
"fmt" "fmt"
@ -38,9 +42,15 @@ func (g *Game) Draw(screen *ebiten.Image) {
fAY := -float32(AY) * config.Config.Gain * float32(scale) fAY := -float32(AY) * config.Config.Gain * float32(scale)
fBX := float32(BX) * config.Config.Gain * float32(scale) fBX := float32(BX) * config.Config.Gain * float32(scale)
fBY := -float32(BY) * config.Config.Gain * float32(scale) fBY := -float32(BY) * config.Config.Gain * float32(scale)
//inv := fastsqrt.FastInvSqrt32((fBX-fAX)*(fBX-fAX) + (fBY-fBY)*(fBY-fBY)) if config.Config.LineInvSqrtOpacityControl {
//colorAdjusted := color.RGBA{config.AccentColor.R, config.AccentColor.G, config.AccentColor.B, uint8(255 * inv * config.Config.LineOpacity)}
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) 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 AX = BX
AY = BY AY = BY
} }
@ -84,10 +94,13 @@ func main() {
config.Init() config.Init()
audio.Init() audio.Init()
fonts.Init() fonts.Init()
icons.Init()
go audio.Start() go audio.Start()
go media.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.SetWindowSize(int(config.Config.WindowWidth), int(config.Config.WindowHeight))
ebiten.SetWindowTitle("xyosc") ebiten.SetWindowTitle("xyosc")
ebiten.SetWindowMousePassthrough(true)
ebiten.SetTPS(int(config.Config.TargetFPS)) ebiten.SetTPS(int(config.Config.TargetFPS))
ebiten.SetWindowDecorated(false) ebiten.SetWindowDecorated(false)
screenW, screenH := ebiten.Monitor().Size() screenW, screenH := ebiten.Monitor().Size()