@seatlayer/core 0.7.2 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -297,6 +297,8 @@ __export(index_exports, {
297
297
  gaAreasOf: () => gaAreasOf,
298
298
  gaUnitLabel: () => gaUnitLabel,
299
299
  gaUnitLabels: () => gaUnitLabels,
300
+ generateSeatPanorama: () => generateSeatPanorama,
301
+ generateSeatThumb: () => generateSeatThumb,
300
302
  getLocale: () => getLocale,
301
303
  hiddenObjectIds: () => hiddenObjectIds,
302
304
  isGaUnitLabel: () => isGaUnitLabel,
@@ -3718,6 +3720,202 @@ var PickerController = class {
3718
3720
  }
3719
3721
  };
3720
3722
 
3723
+ // src/view/generatePanorama.ts
3724
+ var W = 2048;
3725
+ var H = 1024;
3726
+ var UNIT = 0.55 / 24;
3727
+ var yawToX = (yawDeg) => (yawDeg + 180) / 360 * W;
3728
+ var pitchToY = (pitchDeg) => (90 - pitchDeg) / 180 * H;
3729
+ function generateSeatPanorama(seat, focalPoint, neighborSeats) {
3730
+ const canvas = document.createElement("canvas");
3731
+ canvas.width = W;
3732
+ canvas.height = H;
3733
+ const ctx = canvas.getContext("2d");
3734
+ const dx = focalPoint.x - seat.x;
3735
+ const dy = focalPoint.y - seat.y;
3736
+ const distU = Math.hypot(dx, dy);
3737
+ const distM = Math.max(2, distU * UNIT);
3738
+ const sky = ctx.createLinearGradient(0, 0, 0, H);
3739
+ sky.addColorStop(0, "#05070c");
3740
+ sky.addColorStop(0.42, "#11172a");
3741
+ sky.addColorStop(0.5, "#1a2238");
3742
+ sky.addColorStop(0.56, "#10141f");
3743
+ sky.addColorStop(1, "#07090f");
3744
+ ctx.fillStyle = sky;
3745
+ ctx.fillRect(0, 0, W, H);
3746
+ const stageHalfYaw = Math.min(80, Math.atan2(4, distM) * 180 / Math.PI);
3747
+ const stageTopPitch = Math.min(45, Math.atan2(5, distM) * 180 / Math.PI);
3748
+ const stageBasePitch = Math.max(-30, -Math.atan2(1.1, distM) * 180 / Math.PI);
3749
+ const sx0 = yawToX(-stageHalfYaw);
3750
+ const sx1 = yawToX(stageHalfYaw);
3751
+ const sy0 = pitchToY(stageTopPitch);
3752
+ const sy1 = pitchToY(stageBasePitch);
3753
+ const glow = ctx.createRadialGradient(W / 2, (sy0 + sy1) / 2, 10, W / 2, (sy0 + sy1) / 2, (sx1 - sx0) * 1.1);
3754
+ glow.addColorStop(0, "rgba(129, 140, 248, 0.5)");
3755
+ glow.addColorStop(0.5, "rgba(99, 102, 241, 0.16)");
3756
+ glow.addColorStop(1, "rgba(99, 102, 241, 0)");
3757
+ ctx.fillStyle = glow;
3758
+ ctx.fillRect(sx0 - (sx1 - sx0) * 0.6, sy0 - (sy1 - sy0) * 1.2, (sx1 - sx0) * 2.2, (sy1 - sy0) * 3.4);
3759
+ ctx.fillStyle = "#242c44";
3760
+ ctx.fillRect(sx0, sy0, sx1 - sx0, sy1 - sy0);
3761
+ const backdrop = ctx.createLinearGradient(0, sy0, 0, sy1);
3762
+ backdrop.addColorStop(0, "#7c5cff");
3763
+ backdrop.addColorStop(0.5, "#e1447a");
3764
+ backdrop.addColorStop(1, "#f59e0b");
3765
+ ctx.globalAlpha = 0.75;
3766
+ ctx.fillStyle = backdrop;
3767
+ const inset = (sx1 - sx0) * 0.06;
3768
+ ctx.fillRect(sx0 + inset, sy0 + (sy1 - sy0) * 0.12, sx1 - sx0 - inset * 2, (sy1 - sy0) * 0.62);
3769
+ ctx.globalAlpha = 1;
3770
+ ctx.fillStyle = "#0d1119";
3771
+ ctx.fillRect(sx0, sy1 - (sy1 - sy0) * 0.1, sx1 - sx0, (sy1 - sy0) * 0.1);
3772
+ const performerH = (sy1 - sy0) * 0.45;
3773
+ ctx.fillStyle = "rgba(8, 10, 16, 0.85)";
3774
+ for (const fx of [0.35, 0.5, 0.65]) {
3775
+ const px = sx0 + (sx1 - sx0) * fx;
3776
+ const py = sy1 - (sy1 - sy0) * 0.12;
3777
+ ctx.beginPath();
3778
+ ctx.arc(px, py - performerH * 0.82, performerH * 0.16, 0, Math.PI * 2);
3779
+ ctx.fill();
3780
+ ctx.fillRect(px - performerH * 0.14, py - performerH * 0.68, performerH * 0.28, performerH * 0.68);
3781
+ }
3782
+ ctx.globalAlpha = 0.14;
3783
+ ctx.fillStyle = "#c7d2fe";
3784
+ for (const fx of [0.3, 0.5, 0.7]) {
3785
+ const bx = sx0 + (sx1 - sx0) * fx;
3786
+ ctx.beginPath();
3787
+ ctx.moveTo(bx - 8, pitchToY(Math.min(60, stageTopPitch + 25)));
3788
+ ctx.lineTo(bx - (sx1 - sx0) * 0.09, sy1);
3789
+ ctx.lineTo(bx + (sx1 - sx0) * 0.09, sy1);
3790
+ ctx.lineTo(bx + 8, pitchToY(Math.min(60, stageTopPitch + 25)));
3791
+ ctx.closePath();
3792
+ ctx.fill();
3793
+ }
3794
+ ctx.globalAlpha = 1;
3795
+ ctx.fillStyle = "rgba(199, 210, 254, 0.8)";
3796
+ for (let i = 0; i < 26; i++) {
3797
+ const x = i / 26 * W;
3798
+ const y = pitchToY(55 + i % 3 * 6);
3799
+ ctx.beginPath();
3800
+ ctx.arc(x, y, 3.2, 0, Math.PI * 2);
3801
+ ctx.fill();
3802
+ }
3803
+ const stageBearing = Math.atan2(dx, -dy);
3804
+ ctx.fillStyle = "rgba(16, 20, 30, 0.95)";
3805
+ for (const other of neighborSeats) {
3806
+ if (other.id === seat.id) continue;
3807
+ const ox = other.x - seat.x;
3808
+ const oy = other.y - seat.y;
3809
+ const d = Math.hypot(ox, oy) * UNIT;
3810
+ if (d < 0.3 || d > 14) continue;
3811
+ const bearing = Math.atan2(ox, -oy) - stageBearing;
3812
+ const yaw = (bearing * 180 / Math.PI + 540) % 360 - 180;
3813
+ const headPitch = -Math.atan2(0.35, d) * 180 / Math.PI;
3814
+ const headR = Math.min(46, 260 / (d / UNIT / 24 + 1.2) / 4);
3815
+ const hx = yawToX(yaw);
3816
+ const hy = pitchToY(headPitch);
3817
+ ctx.beginPath();
3818
+ ctx.arc(hx, hy, headR, 0, Math.PI * 2);
3819
+ ctx.fill();
3820
+ ctx.beginPath();
3821
+ ctx.ellipse(hx, hy + headR * 1.4, headR * 1.7, headR * 0.9, 0, Math.PI, 0, true);
3822
+ ctx.fill();
3823
+ }
3824
+ const poleFade = ctx.createLinearGradient(0, 0, 0, H);
3825
+ poleFade.addColorStop(0, "rgba(0,0,0,0.85)");
3826
+ poleFade.addColorStop(0.12, "rgba(0,0,0,0)");
3827
+ poleFade.addColorStop(0.88, "rgba(0,0,0,0)");
3828
+ poleFade.addColorStop(1, "rgba(0,0,0,0.85)");
3829
+ ctx.fillStyle = poleFade;
3830
+ ctx.fillRect(0, 0, W, H);
3831
+ return { url: canvas.toDataURL("image/jpeg", 0.82), distanceM: Math.round(distM) };
3832
+ }
3833
+ var TW = 480;
3834
+ var TH = 270;
3835
+ var HALF_HFOV = 50;
3836
+ var HALF_VFOV = 30;
3837
+ var yawToTX = (yawDeg) => (yawDeg + HALF_HFOV) / (2 * HALF_HFOV) * TW;
3838
+ var pitchToTY = (pitchDeg) => (HALF_VFOV - pitchDeg) / (2 * HALF_VFOV) * TH;
3839
+ function generateSeatThumb(seat, focalPoint, _neighborSeats) {
3840
+ const canvas = document.createElement("canvas");
3841
+ canvas.width = TW;
3842
+ canvas.height = TH;
3843
+ const ctx = canvas.getContext("2d");
3844
+ const dx = focalPoint.x - seat.x;
3845
+ const dy = focalPoint.y - seat.y;
3846
+ const distM = Math.max(2, Math.hypot(dx, dy) * UNIT);
3847
+ const sky = ctx.createLinearGradient(0, 0, 0, TH);
3848
+ sky.addColorStop(0, "#05070c");
3849
+ sky.addColorStop(0.44, "#141b30");
3850
+ sky.addColorStop(0.5, "#1b2440");
3851
+ sky.addColorStop(0.58, "#10141f");
3852
+ sky.addColorStop(1, "#070910");
3853
+ ctx.fillStyle = sky;
3854
+ ctx.fillRect(0, 0, TW, TH);
3855
+ const stageHalfYaw = Math.min(HALF_HFOV - 2, Math.atan2(4, distM) * 180 / Math.PI);
3856
+ const stageTopPitch = Math.min(HALF_VFOV - 2, Math.atan2(5, distM) * 180 / Math.PI);
3857
+ const stageBasePitch = Math.max(-HALF_VFOV + 2, -Math.atan2(1.1, distM) * 180 / Math.PI);
3858
+ const sx0 = yawToTX(-stageHalfYaw);
3859
+ const sx1 = yawToTX(stageHalfYaw);
3860
+ const sy0 = pitchToTY(stageTopPitch);
3861
+ const sy1 = pitchToTY(stageBasePitch);
3862
+ const sw = sx1 - sx0;
3863
+ const sh = sy1 - sy0;
3864
+ const glow = ctx.createRadialGradient(TW / 2, (sy0 + sy1) / 2, 4, TW / 2, (sy0 + sy1) / 2, sw * 1.1);
3865
+ glow.addColorStop(0, "rgba(129,140,248,0.5)");
3866
+ glow.addColorStop(0.5, "rgba(99,102,241,0.15)");
3867
+ glow.addColorStop(1, "rgba(99,102,241,0)");
3868
+ ctx.fillStyle = glow;
3869
+ ctx.fillRect(sx0 - sw * 0.6, sy0 - sh * 1.2, sw * 2.2, sh * 3.4);
3870
+ ctx.fillStyle = "#242c44";
3871
+ ctx.fillRect(sx0, sy0, sw, sh);
3872
+ const backdrop = ctx.createLinearGradient(0, sy0, 0, sy1);
3873
+ backdrop.addColorStop(0, "#7c5cff");
3874
+ backdrop.addColorStop(0.5, "#e1447a");
3875
+ backdrop.addColorStop(1, "#f59e0b");
3876
+ ctx.globalAlpha = 0.78;
3877
+ ctx.fillStyle = backdrop;
3878
+ const inset = sw * 0.06;
3879
+ ctx.fillRect(sx0 + inset, sy0 + sh * 0.12, sw - inset * 2, sh * 0.62);
3880
+ ctx.globalAlpha = 1;
3881
+ ctx.fillStyle = "#0d1119";
3882
+ ctx.fillRect(sx0, sy1 - sh * 0.1, sw, sh * 0.1);
3883
+ const ph = sh * 0.45;
3884
+ ctx.fillStyle = "rgba(8,10,16,0.85)";
3885
+ for (const fx of [0.35, 0.5, 0.65]) {
3886
+ const px = sx0 + sw * fx;
3887
+ const py = sy1 - sh * 0.12;
3888
+ ctx.beginPath();
3889
+ ctx.arc(px, py - ph * 0.82, ph * 0.16, 0, Math.PI * 2);
3890
+ ctx.fill();
3891
+ ctx.fillRect(px - ph * 0.14, py - ph * 0.68, ph * 0.28, ph * 0.68);
3892
+ }
3893
+ ctx.globalAlpha = 0.15;
3894
+ ctx.fillStyle = "#c7d2fe";
3895
+ for (const fx of [0.3, 0.5, 0.7]) {
3896
+ const bx = sx0 + sw * fx;
3897
+ ctx.beginPath();
3898
+ ctx.moveTo(bx - 5, pitchToTY(Math.min(HALF_VFOV, stageTopPitch + 18)));
3899
+ ctx.lineTo(bx - sw * 0.09, sy1);
3900
+ ctx.lineTo(bx + sw * 0.09, sy1);
3901
+ ctx.lineTo(bx + 5, pitchToTY(Math.min(HALF_VFOV, stageTopPitch + 18)));
3902
+ ctx.closePath();
3903
+ ctx.fill();
3904
+ }
3905
+ ctx.globalAlpha = 1;
3906
+ ctx.fillStyle = "rgba(199,210,254,0.75)";
3907
+ for (let i = 0; i < 8; i++) {
3908
+ ctx.beginPath();
3909
+ ctx.arc((i + 0.5) / 8 * TW, pitchToTY(HALF_VFOV - 4 - i % 2 * 3), 2.2, 0, Math.PI * 2);
3910
+ ctx.fill();
3911
+ }
3912
+ ctx.fillStyle = "rgba(10,13,20,0.9)";
3913
+ ctx.fillRect(0, TH - 26, TW, 26);
3914
+ ctx.fillStyle = "rgba(30,37,54,0.9)";
3915
+ for (let i = 0; i < 9; i++) ctx.fillRect(i * (TW / 9) + 6, TH - 22, TW / 9 - 12, 14);
3916
+ return { url: canvas.toDataURL("image/jpeg", 0.8), distanceM: Math.round(distM) };
3917
+ }
3918
+
3721
3919
  // src/i18n/bundles.ts
3722
3920
  var LOADERS = {
3723
3921
  es: () => Promise.resolve().then(() => (init_es(), es_exports)).then((m) => ({ default: m.es })),
@@ -3771,6 +3969,8 @@ async function loadLocale(code) {
3771
3969
  gaAreasOf,
3772
3970
  gaUnitLabel,
3773
3971
  gaUnitLabels,
3972
+ generateSeatPanorama,
3973
+ generateSeatThumb,
3774
3974
  getLocale,
3775
3975
  hiddenObjectIds,
3776
3976
  isGaUnitLabel,