CVision-assitant commited on
Commit
b3771f2
路
verified 路
1 Parent(s): 2c90a3f

Update modules/interface.py

Browse files
Files changed (1) hide show
  1. modules/interface.py +78 -25
modules/interface.py CHANGED
@@ -12,54 +12,98 @@ from modules.utils.chat_utils import (
12
 
13
  PLACEHOLDER = "Escribe lo que necesites..."
14
 
15
- # ---------------- JAVASCRIPT PARA LA N脡BULA ----------------
 
 
16
  NEBULA_JS = """
17
- function createNebula() {
18
  const canvas = document.getElementById('nebulaCanvas');
19
  if (!canvas) return;
20
  const ctx = canvas.getContext('2d');
21
  let particles = [];
 
22
 
 
 
 
 
 
 
23
  function resize() {
 
24
  canvas.width = canvas.offsetWidth;
25
  canvas.height = canvas.offsetHeight;
 
26
  }
27
- window.onresize = resize;
28
  resize();
29
 
30
  class Particle {
31
- constructor() {
32
- this.x = Math.random() * canvas.width;
33
- this.y = Math.random() * canvas.height;
34
- this.vx = (Math.random() - 0.5) * 0.4;
35
- this.vy = (Math.random() - 0.5) * 0.4;
 
 
 
 
 
36
  }
37
- update() {
38
- this.x += this.vx;
39
- this.y += this.vy;
40
- if (this.x < 0 || this.x > canvas.width) this.vx *= -1;
41
- if (this.y < 0 || this.y > canvas.height) this.vy *= -1;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  }
43
  }
44
 
45
- for (let i = 0; i < 70; i++) particles.push(new Particle());
 
 
 
 
 
 
 
 
 
 
 
 
 
46
 
47
  function animate() {
48
  ctx.clearRect(0, 0, canvas.width, canvas.height);
49
- ctx.strokeStyle = 'rgba(0, 255, 150, 0.15)';
50
- ctx.fillStyle = 'rgba(0, 255, 150, 0.7)';
51
-
52
  particles.forEach((p, i) => {
53
- p.update();
54
- ctx.beginPath();
55
- ctx.arc(p.x, p.y, 1.2, 0, Math.PI * 2);
56
- ctx.fill();
57
 
58
  for (let j = i + 1; j < particles.length; j++) {
59
  const p2 = particles[j];
60
  const dist = Math.hypot(p.x - p2.x, p.y - p2.y);
61
- if (dist < 110) {
62
- ctx.lineWidth = 1 - dist / 110;
63
  ctx.beginPath();
64
  ctx.moveTo(p.x, p.y);
65
  ctx.lineTo(p2.x, p2.y);
@@ -67,11 +111,20 @@ function createNebula() {
67
  }
68
  }
69
  });
70
- requestAnimationFrame(animate);
 
 
 
 
 
71
  }
 
 
72
  animate();
73
  }
74
- setTimeout(createNebula, 1000);
 
 
75
  """
76
 
77
  # ---------------- VOZ A TEXTO ----------------
 
12
 
13
  PLACEHOLDER = "Escribe lo que necesites..."
14
 
15
+ // ---------------- JAVASCRIPT PARA LA N脡BULA/RED NEURONAL CIRCULAR AZUL FOTURISTA ----------------
16
+ // Reemplaza la secci贸n NEBULA_JS anterior con este nuevo c贸digo.
17
+
18
  NEBULA_JS = """
19
+ function createCircularNebula() {
20
  const canvas = document.getElementById('nebulaCanvas');
21
  if (!canvas) return;
22
  const ctx = canvas.getContext('2d');
23
  let particles = [];
24
+ let animationFrameId;
25
 
26
+ // Par谩metros de la forma circular
27
+ const NUM_PARTICLES = 120; // M谩s part铆culas para un anillo m谩s denso
28
+ const INNER_RADIUS_PERCENT = 0.35; // Radio interior del anillo
29
+ const OUTER_RADIUS_PERCENT = 0.50; // Radio exterior del anillo
30
+ const CONNECTION_DISTANCE = 110;
31
+
32
  function resize() {
33
+ // Asegurar que el canvas tenga un tama帽o para la corona circular
34
  canvas.width = canvas.offsetWidth;
35
  canvas.height = canvas.offsetHeight;
36
+ if (particles.length > 0) initParticles(); // Reinicializar si cambia el tama帽o
37
  }
38
+ window.addEventListener('resize', resize);
39
  resize();
40
 
41
  class Particle {
42
+ constructor(angle, currentRadius) {
43
+ this.angle = angle;
44
+ this.baseRadius = currentRadius;
45
+ this.angleSpeed = (Math.random() - 0.5) * 0.003; // Velocidad angular lenta
46
+ this.radiusOscillation = Math.random() * 5 + 2; // Oscilaci贸n radial peque帽a
47
+ this.radiusFreq = Math.random() * 0.05 + 0.01;
48
+ this.time = Math.random() * 100;
49
+
50
+ // Posici贸n inicial
51
+ this.updatePosition();
52
  }
53
+
54
+ updatePosition() {
55
+ this.time += 1;
56
+ // Un poco de movimiento orbital y oscilaci贸n radial
57
+ const osc = Math.sin(this.time * this.radiusFreq) * this.radiusOscillation;
58
+ const r = this.baseRadius + osc;
59
+
60
+ this.x = canvas.width / 2 + r * Math.cos(this.angle);
61
+ this.y = canvas.height / 2 + r * Math.sin(this.angle);
62
+
63
+ this.angle += this.angleSpeed;
64
+ }
65
+
66
+ draw() {
67
+ ctx.fillStyle = 'rgba(0, 210, 255, 0.9)'; // Azul Ne贸n Intenso
68
+ ctx.beginPath();
69
+ // Dibujar un peque帽o tri谩ngulo
70
+ const size = 2.5;
71
+ ctx.moveTo(this.x, this.y - size);
72
+ ctx.lineTo(this.x + size, this.y + size);
73
+ ctx.lineTo(this.x - size, this.y + size);
74
+ ctx.closePath();
75
+ ctx.fill();
76
  }
77
  }
78
 
79
+ function initParticles() {
80
+ particles = [];
81
+ const canvasMinDim = Math.min(canvas.width, canvas.height);
82
+ const innerRadius = canvasMinDim * INNER_RADIUS_PERCENT;
83
+ const outerRadius = canvasMinDim * OUTER_RADIUS_PERCENT;
84
+
85
+ for (let i = 0; i < NUM_PARTICLES; i++) {
86
+ const angle = (i / NUM_PARTICLES) * Math.PI * 2;
87
+ const currentRadius = innerRadius + Math.random() * (outerRadius - innerRadius);
88
+ particles.push(new Particle(angle, currentRadius));
89
+ }
90
+ }
91
+
92
+ initParticles();
93
 
94
  function animate() {
95
  ctx.clearRect(0, 0, canvas.width, canvas.height);
96
+ ctx.strokeStyle = 'rgba(50, 150, 255, 0.2)'; // Enlaces azules m谩s sutiles
97
+ ctx.lineWidth = 0.8;
98
+
99
  particles.forEach((p, i) => {
100
+ p.updatePosition();
101
+ p.draw();
 
 
102
 
103
  for (let j = i + 1; j < particles.length; j++) {
104
  const p2 = particles[j];
105
  const dist = Math.hypot(p.x - p2.x, p.y - p2.y);
106
+ if (dist < CONNECTION_DISTANCE) {
 
107
  ctx.beginPath();
108
  ctx.moveTo(p.x, p.y);
109
  ctx.lineTo(p2.x, p2.y);
 
111
  }
112
  }
113
  });
114
+ animationFrameId = requestAnimationFrame(animate);
115
+ }
116
+
117
+ // Cancelar la animaci贸n anterior si existe antes de empezar una nueva
118
+ if (window.nebulaAnimationFrameId) {
119
+ cancelAnimationFrame(window.nebulaAnimationFrameId);
120
  }
121
+ window.nebulaAnimationFrameId = animationFrameId;
122
+
123
  animate();
124
  }
125
+
126
+ // Ejecutar con un peque帽o retraso para asegurar que Gradio haya montado el canvas
127
+ setTimeout(createCircularNebula, 1000);
128
  """
129
 
130
  # ---------------- VOZ A TEXTO ----------------