/** * Ichimoku Cloud Fill Plugin * LWC v5 ISeriesPrimitive를 이용해 선행스팬A/B 사이 구름 영역을 캔버스에 직접 렌더링합니다. * * 한국 관례: * SpanA > SpanB → 양운 (빨간 구름, 상승 신호) * SpanA <= SpanB → 음운 (청록 구름, 하락 신호) */ import type { ISeriesPrimitive, IPrimitivePaneView, IPrimitivePaneRenderer, SeriesAttachedParameter, ISeriesApi, SeriesType, Time, IChartApiBase, } from 'lightweight-charts'; export interface IchimokuCloudPoint { time: number; // Unix timestamp (seconds) spanA: number; spanB: number; } function toCanvasFillColor(color: string): string { if (color.startsWith('rgba(') || color.startsWith('rgb(')) return color; const hex = color.startsWith('#') ? color.slice(1) : color; if (hex.length < 6) return color; const r = parseInt(hex.slice(0, 2), 16); const g = parseInt(hex.slice(2, 4), 16); const b = parseInt(hex.slice(4, 6), 16); const a = hex.length >= 8 ? parseInt(hex.slice(6, 8), 16) / 255 : 1; return `rgba(${r}, ${g}, ${b}, ${a})`; } // ─── Renderer ────────────────────────────────────────────────────────────── class CloudRenderer implements IPrimitivePaneRenderer { private _chart: IChartApiBase