Fix
This commit is contained in:
@@ -1,48 +0,0 @@
|
|||||||
import { useEffect, useRef } from 'react'
|
|
||||||
import BerryNoColor from '../assets/berries/BerryNoColor.png'
|
|
||||||
|
|
||||||
export default function RandomBerry () {
|
|
||||||
const canvasRef = useRef<HTMLCanvasElement>(null)
|
|
||||||
const imgRef = useRef<HTMLImageElement>(document.createElement('img'))
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
imgRef.current.src = BerryNoColor.src
|
|
||||||
const canvas = canvasRef.current
|
|
||||||
const ctx = canvas?.getContext('2d')
|
|
||||||
if (!canvas || !ctx) return
|
|
||||||
|
|
||||||
canvas.width = 24
|
|
||||||
canvas.height = 24
|
|
||||||
|
|
||||||
let frame: number
|
|
||||||
const frequency = 5
|
|
||||||
|
|
||||||
const update = () => {
|
|
||||||
const t = (performance.now() / 1000) * frequency
|
|
||||||
|
|
||||||
ctx.clearRect(0, 0, canvas.width, canvas.height)
|
|
||||||
ctx.drawImage(imgRef.current, 0, 0, canvas.width, canvas.height)
|
|
||||||
|
|
||||||
const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height)
|
|
||||||
const data = imageData.data
|
|
||||||
|
|
||||||
for (let i = 0; i < data.length; i += 4) {
|
|
||||||
const gray = data[i]
|
|
||||||
const r = (Math.sin(t) * 0.5 + 0.5) * 255 * (gray / 255)
|
|
||||||
const g = (Math.sin(t + 2) * 0.5 + 0.5) * 255 * (gray / 255)
|
|
||||||
const b = (Math.sin(t + 4) * 0.5 + 0.5) * 255 * (gray / 255)
|
|
||||||
data[i] = r
|
|
||||||
data[i + 1] = g
|
|
||||||
data[i + 2] = b
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.putImageData(imageData, 0, 0)
|
|
||||||
frame = requestAnimationFrame(update)
|
|
||||||
}
|
|
||||||
|
|
||||||
imgRef.current.onload = () => update()
|
|
||||||
return () => cancelAnimationFrame(frame)
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
return <canvas ref={canvasRef} style={{ width: 24, height: 24 }} />
|
|
||||||
}
|
|
||||||
@@ -3,16 +3,11 @@
|
|||||||
import { useGlobal } from '../GlobalProvider'
|
import { useGlobal } from '../GlobalProvider'
|
||||||
|
|
||||||
export default function VersionChangelog () {
|
export default function VersionChangelog () {
|
||||||
const {
|
const { getVersionInfo, managingVersion, downloadedVersionsConfig } =
|
||||||
getGameInfo,
|
useGlobal()
|
||||||
getVersionInfo,
|
|
||||||
managingVersion,
|
|
||||||
downloadedVersionsConfig
|
|
||||||
} = useGlobal()
|
|
||||||
if (!managingVersion || !downloadedVersionsConfig) return <></>
|
if (!managingVersion || !downloadedVersionsConfig) return <></>
|
||||||
|
|
||||||
const versionInfo = getVersionInfo(managingVersion)
|
const versionInfo = getVersionInfo(managingVersion)
|
||||||
const gameInfo = getGameInfo(versionInfo?.game)
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -59,7 +59,8 @@ export default function Installs () {
|
|||||||
: 'h-[calc(100vh-84px)]'
|
: 'h-[calc(100vh-84px)]'
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
{downloadedVersionsConfig && downloadedVersionsConfig.list.length ? (
|
{downloadedVersionsConfig &&
|
||||||
|
Object.keys(downloadedVersionsConfig.list).length ? (
|
||||||
getListOfGames()
|
getListOfGames()
|
||||||
.sort((a, b) => {
|
.sort((a, b) => {
|
||||||
return a.id - b.id
|
return a.id - b.id
|
||||||
|
|||||||
Reference in New Issue
Block a user