From 63d987ff10158d137d6925b945bae29e5d94ff42 Mon Sep 17 00:00:00 2001 From: Louis Dalibard Date: Sat, 2 Nov 2024 23:44:33 +0100 Subject: [PATCH] feat: various fixes --- config/config.go | 52 ++++++++++++++++++------------------ icons/assets/icon-16-32.xcf | Bin 0 -> 2816 bytes icons/assets/icon-16.png | Bin 0 -> 864 bytes icons/assets/icon-32.png | Bin 0 -> 953 bytes icons/assets/icon-48.png | Bin 0 -> 2070 bytes icons/assets/icon-48.xcf | Bin 0 -> 5738 bytes icons/icons.go | 35 ++++++++++++++++++++++++ main.go | 19 ++++++++++--- 8 files changed, 77 insertions(+), 29 deletions(-) create mode 100644 icons/assets/icon-16-32.xcf create mode 100644 icons/assets/icon-16.png create mode 100644 icons/assets/icon-32.png create mode 100644 icons/assets/icon-48.png create mode 100644 icons/assets/icon-48.xcf create mode 100644 icons/icons.go 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 0000000000000000000000000000000000000000..acceb686c8c4f05dab94d31b81555e3880236425 GIT binary patch literal 2816 zcmds3OK%%h6h5AeA8{HrEwqafi(99aQY5!=Tc@oQicBRSsw!1VmKD<29^04LGttaA zwF^=s%7z`Qvgfhuh!se5Bt&=c2arH4_zz`xM6rkO%p**rtg?!@)|vC2$9Ly(zdPfu z9BheEt0T6TYc;}HNR06l*eO^phr=td(ru*JFkXeJFm5=TVD38udjXs8V(Mzk8Vn56 zMNC{gecLv4*Jz6e((Q?N*6!Zp%0kpC2YT12c5T__9Ctrma@=v>5RTQC?Th85PPb+C zEn6%_u4;Fix>$~WwTmb>4=L9~^yBi#+0t9m?26hlqVY>n5>$t#bcHlqJ;Py!)#*5f zE291kj^WGAe9f7W`zQ|b4`W~aGWN6IWSUZV8i1cW-}B69%;^G*pKb^{$N0@19I*m0 z&U5Q*g5ju=!LMa-IfF$8&t>q544%*6lfb1A1D?-UOlmy;g#^RVdB#cKVg{!QnL!S! z$bAJLFSToo+-hGR8#YorckYv=fo^XOw?t(%2DetRCZ_0Eru)YI%9`aE+nc(0*U-1e z_bdBF+vwWX&}^e+u@jB`q9Y#~NME^DzmD8!yn2}@ymineXRBbj`COv1?&@Y+x7%WU zJZM^dN8DRai&dUetXxZaqcB#%mK+&GT*=Ep2S6CUyNDwydasOzMctEow5Ki)VE_F z9n%`;-%Im%CiYBEEv1+Q2qkkNrZRle>n}FQTncp zHuHvb@v2*lUc$#__ooX9f7IQd&&&Z>_#hLf4X8Sk2dW3EHz5x=gsF^4@jyjo4}D01>VfJ-RG)lM zeNcT+{R#QNAxvdViVrF(d+0+7R3B77qBcktX!@O0=&zl}M2!pd=q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h?+hq{ROvg%&X$9QWhhy~o`i<8dLUpB1DKYXWz0!Z0-odR9zMR_MR=C?xj#p*nzb0<6N#hDFe}6x#50=} zgY!Odh!td&_?&p$qze*1a$RxxjdR{%foF!yRC1m;L@egpSZQNcFg4;S;;^delrN-R zRyl8R)=E{@yeEHQFsrXDbDic0;#kBIB#2N@MG+-b5TR8k#X^$yV;=rt$1jmfAy*NM z91AEzgY5Xh|KNAGR&H{_O$x?<&KKMM7zF~mK%-{c-^aGyI05|6z?I(em+QdnC+W48 z7Cr*{wtq3d%U}=y|;hQH2eDjt;%w~#PY$c00006VoOIv00000008+zyMF)x010qNS#tmY zE+YT{E+YYWr9XB6000McNliru=nDcCAsHJ*s5Afo02y>eSad^gZEa<4bO1wgWnpw> zWFU8GbZ8()Nlj2!fese{00EInL_t(o!|m5WNL4`?1>okWK*^?D*cKJyNYynma{3Pfu;VWAL* zqbN$m|5$L1xDuWo4ctD{2D*m^5;OWXJPv-Xu7dir$H9l(qgdR@hJ#?P{|Wf~WgeW) z^^~awUf#GHm{o*5%P%c~<~!jOe0@9;DpH)bkk5mCm(GJ@`y0U6$LYkqzueRe`d*Bd zsRn*5hm3b@+YWZu)yKwPf0_lgHCw@!>dmq769*b&{kFqL!NBCJSmx#H10@YCN4tWGH&s@Gy*qb-J?$-EHun%*8@wM*)2Vad=gJCby4963C+xp)1zdd48^b4i zLVxhh1b8+*^;hRhj}w+MXgzcUd@uSzM-hMC8MIMV)Ie(A1JS?w7p(X8`+qBtJxVhI bsU`3mhHr7q)tzdm00000NkvXXu0mjfVcw&E literal 0 HcmV?d00001 diff --git a/icons/assets/icon-48.png b/icons/assets/icon-48.png new file mode 100644 index 0000000000000000000000000000000000000000..83ac51924135c75819ee33a65387c14239418e89 GIT binary patch literal 2070 zcmV+x2EX>4Tx04R}tkv&MmKpe$iQ>CI62djuUWT;Md@e9XVg(6f4wL+^7CYOFelZK?l z#ZhoAIQX$xb#QUk)xlK|1V2EW9h?+hq{ROvg%&X$9QWh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A6JGW6&43#zei^L`(+etT(zKdnFodtBi z3us!aCHqnOcS6mZq?}1rv`d(#Op9*L0KvsG2+}5}XyTOBGTEn9{A^h{dubWRS3Z-U zv2n_`(Q-{bc07$@$nwU|BnOVwe{SNT&L4OlsJ>7S>Aw3y15>a}`@TS6)<^~anun)- Ut^Q-su(AHjY~`nb-zOXNKexEH{r~^~ literal 0 HcmV?d00001 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()