Skip to content

Commit

Permalink
Add net gif over map (#501)
Browse files Browse the repository at this point in the history
  • Loading branch information
xpaczka authored Oct 25, 2023
2 parents e5493ee + e7ecb4c commit 8592ecf
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ declare module "*.webp" {
export = value
}

declare module "*.gif" {
const value: string
export = value
}

declare module "*.woff2" {
const value: string
export = value
Expand Down
Binary file added src/shared/assets/island-overlay-net.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 19 additions & 4 deletions src/ui/Island/Gif.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import React, { useEffect, useMemo, useRef } from "react"
import React, { memo, useEffect, useMemo, useRef } from "react"
import { Image } from "react-konva"
import type Konva from "konva"
import "gifler"
import { isBrowser } from "shared/utils"

type GifProps = {
src: string
width: number
height: number
x?: number
y?: number
scaleY?: number
}

export default function Gif(props: GifProps) {
const { src, x = 0, y = 0 } = props
function Gif(props: GifProps) {
const { src, x = 0, y = 0, width, height, scaleY } = props
const imageRef = useRef<Konva.Image | null>(null)
const canvas = useMemo(() => document.createElement("canvas"), [])

Expand All @@ -30,5 +33,17 @@ export default function Gif(props: GifProps) {
return () => anim?.stop()
}, [src, canvas])

return <Image x={x} y={y} image={canvas} ref={imageRef} />
return (
<Image
x={x}
y={y}
width={width}
height={height}
scaleY={scaleY}
image={canvas}
ref={imageRef}
/>
)
}

export default memo(Gif)
2 changes: 2 additions & 0 deletions src/ui/Island/InteractiveIsland.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import Background from "./Background"
import Realms from "./IslandRealms"
import RealmPin from "./RealmPin"
import Clouds from "./Clouds"
import NetOverlay from "./NetOverlay"

function InteractiveIsland() {
const settingsRef = useRef({ minScale: 0 })
Expand Down Expand Up @@ -165,6 +166,7 @@ function InteractiveIsland() {
<Layer>
<Background overlay={overlay} />
<Realms />
<NetOverlay />
<Clouds />
<RealmPin />
</Layer>
Expand Down
37 changes: 37 additions & 0 deletions src/ui/Island/NetOverlay.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import React, { memo } from "react"
import { Group } from "react-konva"
import netGif from "shared/assets/island-overlay-net.gif"
import { FIGMA_FACTOR } from "shared/constants"
import Gif from "./Gif"

function NetOverlay() {
return (
<Group listening={false} opacity={0.3}>
<Gif
src={netGif}
width={700 * FIGMA_FACTOR.X}
height={197 * FIGMA_FACTOR.Y}
x={600 * FIGMA_FACTOR.X}
y={-20 * FIGMA_FACTOR.Y}
/>
<Gif
src={netGif}
width={700 * FIGMA_FACTOR.X}
height={197 * FIGMA_FACTOR.Y}
x={-30 * FIGMA_FACTOR.X}
y={1150 * FIGMA_FACTOR.Y}
scaleY={-1}
/>
<Gif
src={netGif}
width={700 * FIGMA_FACTOR.X}
height={197 * FIGMA_FACTOR.Y}
x={1150 * FIGMA_FACTOR.X}
y={1200 * FIGMA_FACTOR.Y}
scaleY={-1}
/>
</Group>
)
}

export default memo(NetOverlay)

0 comments on commit 8592ecf

Please sign in to comment.