initVariables();
///////////////////////////////////////////////////////
function funcionGo(ctx, width, height) {
  if (lInit) {
    jsreinitProcedure();
    jsinitTimer(1);
    posSpheres = [];
    xp = random(wsIni + rp / 2, wsIni + wVideo - rp / 2);
    yp = random(hsIni + rp / 2, hsIni + hVideo - rp / 2);
    ellipse(xp, yp, rp * 2, rp * 2);
    txClocalUp = "EN CONSTRUCCION";
    txClocalDown = "";
    centerX = windowWidth / 2;
    centerY = windowHeight / 2; // Centro del lienzo
    radius = windowHeight;
    if (deviceAndroid) {
      _handleMotion();
      if (deviceOrientation == "portrait") {
        if (lChangeCam) radius = windowHeight - 120;
        nCoefi = 3.10;
      } else {
        if (deviceOrientation == "landscape") {
          nCoefi = 1.90;
        }
      }
    }
    // Generar las posiciones de las esferas
    for (let i = 0; i < numSpheres; i++) {
      let angle = map(i, 0, numSpheres, 0, TWO_PI); // Ángulo en radianes
      let x = centerX + (radius / nCoefi) * cos(angle); // Coordenada x
      let y = centerY + (radius / nCoefi) * sin(angle); // Coordenada y
      let value = false;
      addPoint(x, y, value);
    }
  }
  //displaymodulo(0);
  strokeWeight(1);
  noStroke()
  noFill();
  ellipse(centerX, centerY, radius);
  for (let i = 0; i < numSpheres; i++) {
    if (posSpheres[i].value) fill(0, 0, 255, 128);
    else fill(128, 128, 128, 128);
    ellipse(posSpheres[i].x, posSpheres[i].y, rp * 2, rp * 2);
    fill(0);
    textAlign(CENTER, CENTER);
    textSize(28);
    fill(255);
    text(toRoman(i), posSpheres[i].x, posSpheres[i].y);
    textSize(12);
  }

  fill(0, 0, 255, 128);
  ellipse(pCW1.x, pCW1.y, rp * 2, rp * 2);
  ellipse(pCW2.x, pCW2.y, rp * 2, rp * 2);
  for (let i = 0; i < numSpheres; i++) {
    if (dist(posSpheres[i].x, posSpheres[i].y, pCW1.x, pCW1.y) < rp * 2) { // || dist(posSpheres[i].x, posSpheres[i].y, pCW2.x, pCW2.y) < rp * 2) {
      posSpheres[i].value = true;
      if (dwr12 < 100) {
        posSpheres[i].x = pCW1.x;
        posSpheres[i].y = pCW1.y;
      }
    }
    if (dist(posSpheres[i].x, posSpheres[i].y, pCW2.x, pCW2.y) < rp * 2) {
      posSpheres[i].value = true;
      if (dwl12 < 100) {
        posSpheres[i].x = pCW2.x;
        posSpheres[i].y = pCW2.y;
      }
    }
  }
  pCW1.x = -width;
  pCW1.y = -width;
  pCW2.x = -width;
  pCW2.x = -width;
}
///////////////////////////
function addPoint(x, y, value) {
  let point = { x: x, y: y, value: value };
  posSpheres.push(point);
}
function toRoman(num) {
  //const romanNumerals = ["IV", "V", "VI", "VII", "VIII", "IX", "X", "XI", "XII", "I", "II", "III"];
  const romanNumerals = ["D", "E", "F", "G", "H", "I", "J", "K", "L", "A", "B", "C"];
  return romanNumerals[num % 12]; // Devolver el número romano correspondiente
}