fogón

← NaturalezaObjeto 3Dfogon/cactus-redondo

Cactus redondo

de fogonCC014144 bloques
Cactus redondoArrastrá para girarlo
// «Cactus redondo» · gpt-6-sol (medium)
// A round barrel cactus with vertical ribs and spines, topped with a small pink flower, in a little sand mound.

// Low, sun-warmed sand mound.
const sand = ["#e9bf72", "#f3cf88", "#ffdc99", "#dca85d"];
for (let x = 5; x <= 43; x++) {
  for (let y = 6; y <= 42; y++) {
    const d = ((x - 24) / 19) ** 2 + ((y - 24) / 18) ** 2;
    if (d > 1) continue;
    const top = Math.floor(-3 + 8 * Math.sqrt(1 - d));
    for (let z = 0; z <= top; z++) {
      const c = z === top
        ? (rand() < 0.18 ? sand[2] : sand[1])
        : (rand() < 0.09 ? sand[3] : sand[0]);
      set(x, y, z, c);
    }
  }
}

// Solid, rounded barrel with twelve continuous, raised ribs.
const ribs = 12;
function cactusRadius(z, angle) {
  const t = (z - 19) / 16;
  return 12.5 * Math.sqrt(Math.max(0, 1 - t * t))
    + 0.8 * Math.cos(ribs * angle);
}

for (let z = 5; z <= 34; z++) {
  for (let x = 9; x <= 39; x++) {
    for (let y = 9; y <= 39; y++) {
      const dx = x - 24, dy = y - 24;
      const angle = Math.atan2(dy, dx);
      const radius = Math.hypot(dx, dy);
      const edge = cactusRadius(z, angle);
      if (radius > edge) continue;

      const ridge = Math.cos(ribs * angle);
      const exposed = radius > edge - 2.1;
      let color = "#299b4b";
      if (exposed) {
        if (ridge < -0.55) color = "#187a3c";
        else if (ridge > 0.55) color = "#43bd58";
        else color = "#2ba54b";

        if (z > 23 && ridge > -0.55) color = ridge > 0.55 ? "#65ce65" : "#43b957";
        if (y < 23 && ridge > 0.55 && rand() < 0.18) color = "#78d76b";
        if (rand() < 0.035) color = ridge < -0.55 ? "#206e38" : "#53c65c";
      }
      set(x, y, z, color);
    }
  }
}

// Pale, chunky needles grow from little golden areoles along each rib.
for (let i = 0; i < ribs; i++) {
  const angle = i * 2 * Math.PI / ribs;
  const ux = Math.cos(angle), uy = Math.sin(angle);
  for (let z = 9 + (i % 2); z <= 31; z += 4) {
    const r = cactusRadius(z, angle);
    const x = 24 + ux * r, y = 24 + uy * r;
    set(x, y, z, "#d5ab55");
    line(x, y, z, x + ux * 2.5, y + uy * 2.5, z + 1, 0, "#fff0ae");
    if ((i + z) % 3 === 0) {
      line(x, y, z, x + ux * 1.6, y + uy * 1.6, z - 2, 0, "#f8df92");
    }
  }
}

// A tiny flower sits slightly forward on the crown.
ellipsoid(24, 22, 34, 3, 3, 1, "#238c43");
cylinder(24, 22, 34, 1, 3, "#448f3d");

for (let i = 0; i < 6; i++) {
  const a = i * Math.PI / 3;
  const px = 24 + 3 * Math.cos(a);
  const py = 22 + 3 * Math.sin(a);
  ellipsoid(px, py, 38, 2.3, 2.3, 1.6, "#ed65a2");
  ellipsoid(px, py, 39, 1.6, 1.6, 1, "#ff9bc3");
}
sphere(24, 22, 39, 1.7, "#ffd858");
set(24, 22, 41, "#fff0a0");

// A few pebble and grass accents keep the mound playful.
ellipsoid(9, 22, 1, 2, 1, 1, "#aab6aa");
set(9, 22, 2, "#d6dcd0");
ellipsoid(38, 29, 1, 2, 1, 1, "#b5b9a5");
set(38, 29, 2, "#d7d8be");
for (const [x, y] of [[13, 32], [35, 13], [29, 39]]) {
  set(x, y, 1, "#53ae4c");
  set(x, y, 2, "#6cc45b");
  set(x + 1, y, 1, "#76c45b");
}