Fix all the fucking connection coloring

This commit is contained in:
2025-06-14 03:41:11 +02:00
parent 5143ba79a2
commit b401b4784a
3 changed files with 19 additions and 24 deletions

View File

@@ -3,11 +3,10 @@ import React from 'react';
interface ConnectionProps { interface ConnectionProps {
from: { x: number; y: number }; from: { x: number; y: number };
to: { x: number; y: number }; to: { x: number; y: number };
fromColor?: string; color?: string;
toColor?: string;
} }
export const Connection: React.FC<ConnectionProps> = ({ from, to, fromColor, toColor }) => { export const Connection: React.FC<ConnectionProps> = ({ from, to, color }) => {
return ( return (
<g> <g>
{/* Glow effect */} {/* Glow effect */}
@@ -16,8 +15,8 @@ export const Connection: React.FC<ConnectionProps> = ({ from, to, fromColor, toC
y1={from.y} y1={from.y}
x2={to.x} x2={to.x}
y2={to.y} y2={to.y}
stroke={fromColor || "#a855f7"} stroke={color || "#a855f7"}
strokeWidth="3" strokeWidth="5"
opacity="0.3" opacity="0.3"
/> />
@@ -27,7 +26,7 @@ export const Connection: React.FC<ConnectionProps> = ({ from, to, fromColor, toC
y1={from.y} y1={from.y}
x2={to.x} x2={to.x}
y2={to.y} y2={to.y}
stroke={fromColor || "#a855f7"} stroke={color || "#a855f7"}
strokeWidth="1" strokeWidth="1"
opacity="0.7" opacity="0.7"
className="transition-all duration-300" className="transition-all duration-300"

View File

@@ -141,11 +141,11 @@ export const GalaxyMap = () => {
return ( return (
<div className="w-full h-screen bg-gradient-to-br from-slate-900 via-purple-900 to-slate-900 overflow-hidden relative"> <div className="w-full h-screen bg-gradient-to-br from-slate-900 via-purple-900 to-slate-900 overflow-hidden relative">
<div className="absolute inset-0 bg-[radial-gradient(ellipse_at_center,_var(--tw-gradient-stops))] from-purple-900/20 via-slate-900/40 to-black"></div> <div className="absolute inset-0 bg-[radial-gradient(ellipse_at_center,_var(--tw-gradient-stops))] from-purple-900/20 via-slate-900/40 to-black"></div>
<div className="relative z-10 p-8"> <div className="relative z-10 p-8">
<h1 className="text-4xl font-bold text-white mb-2 text-center">Galaxy Map</h1> <h1 className="text-4xl font-bold text-white mb-2 text-center">Galaxy Map</h1>
<p className="text-purple-200 text-center mb-8">Navigate the known regions of space</p> <p className="text-purple-200 text-center mb-8">Navigate the known regions of space</p>
<div className="w-full h-[calc(100vh-200px)] border border-purple-500/30 rounded-lg overflow-hidden bg-black/20 backdrop-blur-sm"> <div className="w-full h-[calc(100vh-200px)] border border-purple-500/30 rounded-lg overflow-hidden bg-black/20 backdrop-blur-sm">
<svg <svg
ref={svgRef} ref={svgRef}
@@ -162,38 +162,37 @@ export const GalaxyMap = () => {
<defs> <defs>
<filter id="glow"> <filter id="glow">
<feGaussianBlur stdDeviation="3" result="coloredBlur"/> <feGaussianBlur stdDeviation="3" result="coloredBlur"/>
<feMerge> <feMerge>
<feMergeNode in="coloredBlur"/> <feMergeNode in="coloredBlur"/>
<feMergeNode in="SourceGraphic"/> <feMergeNode in="SourceGraphic"/>
</feMerge> </feMerge>
</filter> </filter>
</defs> </defs>
{/* Render connections first (behind nodes) */} {/* Render connections first (behind nodes) */}
{regions?.map((region) => {regions?.map((region) =>
region.connectsTo?.map((connectedRegion) => { region.connectsTo?.map((connectedRegion) => {
const fromPos = nodePositions[region.regionName]; const fromPos = nodePositions[region.regionName];
const toPos = nodePositions[connectedRegion]; const toPos = nodePositions[connectedRegion];
if (!fromPos || !toPos) return null; if (!fromPos || !toPos) return null;
// Get colors for both regions // Get colors for both regions
const fromColor = getSecurityColor(region.security);
const toRegion = regions.find(r => r.regionName === connectedRegion); const toRegion = regions.find(r => r.regionName === connectedRegion);
const toColor = toRegion ? getSecurityColor(toRegion.security) : fromColor; const avgSecurity = (region.security + toRegion.security) / 2;
const color = getSecurityColor(avgSecurity);
return ( return (
<Connection <Connection
key={`${region.regionName}-${connectedRegion}`} key={`${region.regionName}-${connectedRegion}`}
from={fromPos} from={fromPos}
to={toPos} to={toPos}
fromColor={fromColor} color={color}
toColor={toColor}
/> />
); );
}) })
)} )}
{/* Render nodes */} {/* Render fromCodes */}
{regions?.map((region) => ( {regions?.map((region) => (
<MapNode <MapNode
key={region.regionName} key={region.regionName}

View File

@@ -24,8 +24,7 @@ interface ProcessedConnection {
key: string; key: string;
from: Position; from: Position;
to: Position; to: Position;
fromColor: string; color: string;
toColor: string;
} }
const fetchRegionData = async (regionName: string): Promise<SolarSystem[]> => { const fetchRegionData = async (regionName: string): Promise<SolarSystem[]> => {
@@ -80,8 +79,7 @@ export const RegionMap: React.FC<{ regionName: string }> = ({ regionName }) => {
key: connectionKey, key: connectionKey,
from: fromPos, from: fromPos,
to: toPos, to: toPos,
fromColor: connectionColor, color: connectionColor
toColor: connectionColor
}); });
}); });
}); });
@@ -244,8 +242,7 @@ export const RegionMap: React.FC<{ regionName: string }> = ({ regionName }) => {
key={connection.key} key={connection.key}
from={connection.from} from={connection.from}
to={connection.to} to={connection.to}
fromColor={connection.fromColor} color={connection.color}
toColor={connection.toColor}
/> />
))} ))}