Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | import React, { ReactNode } from "react"; import { useLayoutEffect } from "react"; import { AutoFocusInside } from "react-focus-lock"; import { Button } from "ui/buttons/Button"; import useResizeObserver from "ui/hooks/use-resize-observer"; import { CloseIcon } from "ui/icons/Icons"; import { StyledCredits, StyledCreditsCloseButton, StyledCreditsContent, StyledCreditsGrid, StyledCreditsPerson, StyledCreditsSubHeading, StyledCreditsTitle, } from "ui/splash/credits/style"; interface CreditsProps { onClose?: () => void; duration?: number; children?: ReactNode; } export const Credits = ({ onClose, duration = 60, children }: CreditsProps) => { return ( <StyledCredits> <CreditsBackground /> <StyledCreditsContent $duration={duration}> {children} </StyledCreditsContent> {onClose && ( <StyledCreditsCloseButton> <AutoFocusInside> <Button variant="transparent" onClick={onClose}> <CloseIcon /> </Button> </AutoFocusInside> </StyledCreditsCloseButton> )} </StyledCredits> ); }; interface CreditsTitleProps { children?: ReactNode; } export const CreditsTitle = ({ children }: CreditsTitleProps) => { return <StyledCreditsTitle children={children} />; }; interface CreditsSubHeadingProps { children?: ReactNode; } export const CreditsSubHeading = ({ children }: CreditsSubHeadingProps) => { return <StyledCreditsSubHeading children={children} />; }; export interface CreditsPersonProps { children?: ReactNode; gold?: boolean; onClick?: () => void; } export const CreditsPerson = ({ children, gold, onClick, }: CreditsPersonProps) => ( <StyledCreditsPerson $gold={gold} onClick={onClick}> <span>{children}</span> </StyledCreditsPerson> ); export interface CreditsGridProps { children?: ReactNode; } export const CreditsGrid = ({ children }: CreditsGridProps) => { return <StyledCreditsGrid children={children} />; }; const CreditsBackground = () => { const [ref, size] = useResizeObserver<HTMLCanvasElement>(); useLayoutEffect(() => { Iif (ref.current) { const c = ref.current; const ctx = c.getContext("2d"); let time = 0; const render = () => { const width = c.width; const height = c.height; const numVerticalLines = Math.ceil(width / 30); Iif (ref.current && ctx) { // Create gradient const bgGrad = ctx.createLinearGradient(0, 0, 0, height); bgGrad.addColorStop(0, "#221e6a"); bgGrad.addColorStop(0.25, "#bb205a"); bgGrad.addColorStop(0.5, "#ce1e32"); bgGrad.addColorStop(0.75, "#bb205a"); bgGrad.addColorStop(1, "#221e6a"); // Fill with gradient ctx.fillStyle = bgGrad; ctx.fillRect(0, 0, width, height); const lineGrad = ctx.createLinearGradient(0, 0, 0, height); lineGrad.addColorStop(0, "#e79c58"); lineGrad.addColorStop(0.25, "#e5731b"); lineGrad.addColorStop(0.4, "#ce1e32"); lineGrad.addColorStop(0.5, "#ce1e32"); lineGrad.addColorStop(0.6, "#ce1e32"); lineGrad.addColorStop(0.75, "#e5731b"); lineGrad.addColorStop(1, "#e79c58"); ctx.strokeStyle = lineGrad; ctx.lineWidth = 2; // Vertical lines to horizon for (let i = -(numVerticalLines * 0.5); i < numVerticalLines; i++) { ctx.beginPath(); ctx.moveTo(i * 80, 0); ctx.lineTo(width * 0.5, height * 0.5); ctx.stroke(); ctx.beginPath(); ctx.moveTo(i * 80, height); ctx.lineTo(width * 0.5, height * 0.5); ctx.stroke(); } // Horizontal lines for (let i = 0; i < 15; i++) { ctx.beginPath(); ctx.moveTo(0, height * 0.5 - (height * 0.5) / (-time + i * 0.5)); ctx.lineTo( width, height * 0.5 - (height * 0.5) / (-time + i * 0.5) ); ctx.stroke(); ctx.beginPath(); ctx.moveTo(0, height * 0.5 + (height * 0.5) / (-time + i * 0.5)); ctx.lineTo( width, height * 0.5 + (height * 0.5) / (-time + i * 0.5) ); ctx.stroke(); } Iif (time > 0.5) { time = 0; } time += 0.005; requestAnimationFrame(render); } }; render(); } }, [ref]); return ( <canvas ref={ref} width={size.width} height={size.height} style={{ width: "100%", height: "100%" }} ></canvas> ); }; |