feat: 앱도 웹과 같이 — 히어로·달 포스트를 오늘 밤 실제 달 모양으로(저녁엔 노을빛, 어두운 달이면 흰 점수), 캐릭터 댓글에 '날씨각' 표시·신고 메뉴 없음
This commit is contained in:
1 parent
197fafdc02
commit
a87f245547
4 files changed
+132
-11
No files matched your search
@@ -0,0 +1,79 @@
|
||||
import { moonPath } from '@nalssigak/shared/lib/today';
|
||||
import { useId } from 'react';
|
||||
import Svg, { Circle, ClipPath, Defs, Ellipse, FeGaussianBlur, Filter, G, Path, RadialGradient, Stop } from 'react-native-svg';
|
||||
|
||||
// 앞면 바다(어두운 무늬) 자리: [x, y, 가로 반지름, 세로 반지름]. 실제 달 앞면 배치를 대강 따른다 (웹 frontend/src/b/moon.tsx 와 같다)
|
||||
const MARIA: [number, number, number, number][] = [
|
||||
[-0.32, -0.36, 0.3, 0.26],
|
||||
[0.12, -0.36, 0.17, 0.15],
|
||||
[0.3, -0.06, 0.2, 0.17],
|
||||
[-0.56, 0.06, 0.26, 0.42],
|
||||
[0.66, -0.26, 0.1, 0.12],
|
||||
[0.52, 0.22, 0.13, 0.15],
|
||||
[-0.14, 0.44, 0.18, 0.13],
|
||||
[-0.46, 0.5, 0.1, 0.09],
|
||||
];
|
||||
// 작은 크레이터: [x, y, 반지름]
|
||||
const CRATERS: [number, number, number][] = [
|
||||
[0.1, 0.72, 0.07],
|
||||
[0.42, 0.52, 0.05],
|
||||
[-0.66, -0.5, 0.05],
|
||||
[0.62, 0.52, 0.04],
|
||||
[-0.2, 0.08, 0.04],
|
||||
];
|
||||
// 저녁(노을)엔 노을빛이 도는 달, 밤엔 하얀 달
|
||||
const TONES = {
|
||||
night: { body: ['#fffcf2', '#f6ebcb', '#e0cc98'], shade: '#1a2050' },
|
||||
dusk: { body: ['#fff8ee', '#ffe2cc', '#f2b9a2'], shade: '#4a2a63' },
|
||||
};
|
||||
|
||||
/** 오늘 밤 실제 모양대로 그린 달. pct 는 빛나는 면의 비율 0~100, 기우는 달은 왼쪽이 밝다. 빛 번짐까지 그려서 달 지름은 size 의 2/3 */
|
||||
export function MoonArt({ pct, waxing, tone = 'night', size }: { pct: number; waxing: boolean; tone?: keyof typeof TONES; size: number }) {
|
||||
const id = useId().replace(/[^a-zA-Z0-9]/g, '');
|
||||
const t = TONES[tone];
|
||||
const k = pct / 100;
|
||||
const full = pct >= 99;
|
||||
const hidden = pct <= 1;
|
||||
return (
|
||||
<Svg viewBox="-1.5 -1.5 3 3" width={size} height={size} pointerEvents="none">
|
||||
<Defs>
|
||||
<RadialGradient id={`${id}glow`} cx="0" cy="0" r="1.5" gradientUnits="userSpaceOnUse">
|
||||
<Stop offset="0.6" stopColor="#fff4cf" stopOpacity={0.55} />
|
||||
<Stop offset="0.8" stopColor="#ffe9a8" stopOpacity={0.16} />
|
||||
<Stop offset="1" stopColor="#ffe9a8" stopOpacity={0} />
|
||||
</RadialGradient>
|
||||
<RadialGradient id={`${id}body`} cx="-0.2" cy="-0.28" r="1.44" gradientUnits="userSpaceOnUse">
|
||||
<Stop offset="0" stopColor={t.body[0]} />
|
||||
<Stop offset="0.6" stopColor={t.body[1]} />
|
||||
<Stop offset="1" stopColor={t.body[2]} />
|
||||
</RadialGradient>
|
||||
<RadialGradient id={`${id}limb`} cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse">
|
||||
<Stop offset="0.72" stopColor="#8a6f3c" stopOpacity={0} />
|
||||
<Stop offset="1" stopColor="#8a6f3c" stopOpacity={0.28} />
|
||||
</RadialGradient>
|
||||
<ClipPath id={`${id}disc`}>
|
||||
<Circle r="1" />
|
||||
</ClipPath>
|
||||
<Filter id={`${id}soft`} x="-0.2" y="-0.2" width="1.4" height="1.4">
|
||||
<FeGaussianBlur stdDeviation="0.035" />
|
||||
</Filter>
|
||||
</Defs>
|
||||
{!hidden && <Circle r="1.5" fill={`url(#${id}glow)`} opacity={full ? 1 : 0.12 + 0.8 * k} />}
|
||||
<G clipPath={`url(#${id}disc)`}>
|
||||
<Circle r="1" fill={`url(#${id}body)`} />
|
||||
<G filter={`url(#${id}soft)`} fill="#c4b287" opacity={0.55}>
|
||||
{MARIA.map(([x, y, rx, ry]) => (
|
||||
<Ellipse key={`${x},${y}`} cx={x} cy={y} rx={rx} ry={ry} />
|
||||
))}
|
||||
</G>
|
||||
{CRATERS.map(([x, y, r]) => (
|
||||
<Circle key={`${x},${y}`} cx={x} cy={y} r={r} fill="#efe2bd" stroke="#cdbb8c" strokeWidth={0.018} opacity={0.8} />
|
||||
))}
|
||||
<Circle r="1" fill={`url(#${id}limb)`} />
|
||||
{/* 안 보이는 쪽: 흐릿한 경계로 덮고, 땅빛(지구조) 정도만 비치게 */}
|
||||
{!full && <Path d={moonPath(pct, 1.04, false)} fill={t.shade} opacity={0.94} filter={`url(#${id}soft)`} transform={waxing ? undefined : 'scale(-1,1)'} />}
|
||||
</G>
|
||||
{hidden && <Circle r="1" fill="none" stroke="#fff" strokeOpacity={0.18} strokeWidth={0.025} />}
|
||||
</Svg>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user