fogón

← BásicoObjeto 3Dfogon/silla-windsor-v4

Silla Windsor

de fogonCC03598 bloques
Silla WindsorArrastrá para girarlo
// «Silla Windsor» · gpt-6-sol (medium)
// Windsor chair («Silla Windsor»). One of several variations of this object: follow the reference picture closely.

const dark = "#304840";
const shadow = "#3d5750";
const wood = "#506d63";
const light = "#68867b";
const seat = "#79988d";
const seatLight = "#8aa69a";

// Turned legs, gently splayed outward toward the floor.
function leg(xTop, yTop, xFoot, yFoot) {
  for (let z = 0; z <= 20; z++) {
    const t = z / 20;
    const x = Math.round(xFoot + (xTop - xFoot) * t);
    const y = Math.round(yFoot + (yTop - yFoot) * t);
    const r = z < 3 ? 1 : z < 15 ? 1.15 : 1.35;
    cylinder(x, y, z, r, 1, z < 5 ? shadow : wood);
    set(x - 1, y, z, z < 5 ? dark : shadow);
    if (z > 5 && z < 18) set(x, y - 1, z, light);
  }
}
leg(13, 15, 10, 11);
leg(35, 15, 38, 11);
leg(14, 31, 11, 37);
leg(34, 31, 37, 37);

// Low stretchers between the four legs.
line(11, 12, 8, 37, 12, 8, 1, shadow);
line(11, 37, 9, 37, 37, 9, 1, shadow);
line(11, 13, 8, 11, 36, 9, 1, wood);
line(37, 13, 8, 37, 36, 9, 1, wood);
line(14, 14, 9, 34, 14, 9, 0, light);

// Broad, softly rounded solid wooden seat.
function onSeat(x, y, inset = 0) {
  const dx = (x - 24) / (16 - inset);
  const dy = (y - 23) / (13 - inset);
  return dx * dx + dy * dy <= 1;
}
for (let z = 19; z <= 22; z++) {
  for (let y = 10; y <= 36; y++) {
    for (let x = 8; x <= 40; x++) {
      if (!onSeat(x, y, z === 19 ? 1 : 0)) continue;
      let c = z === 22 ? seat : z === 21 ? wood : shadow;
      if (z === 22) {
        const edge = !onSeat(x + 1, y, 0) || !onSeat(x - 1, y, 0) ||
                     !onSeat(x, y + 1, 0) || !onSeat(x, y - 1, 0);
        if (edge) c = wood;
        else if (rand() < 0.13) c = seatLight;
        else if (rand() < 0.11) c = light;
      }
      set(x, y, z, c);
    }
  }
}

// Fine, irregular grain in the seat surface.
for (let y = 14; y <= 32; y += 4) {
  for (let x = 12; x <= 36; x++) {
    if (onSeat(x, y) && onSeat(x, y - 1) && rand() > 0.24) {
      set(x, y, 22, rand() < 0.5 ? light : seatLight);
    }
  }
}

// Curving bow back: the ends grow out of the rear corners of the seat.
for (let i = 0; i < 65; i++) {
  const t = Math.PI * i / 64;
  const x = 24 + 14 * Math.cos(t);
  const z = 23 + 19 * Math.sin(t);
  const y = 33 + 2 * Math.sin(t);
  sphere(x, y, z, 1.15, shadow);
  set(x, y - 1, z + 1, light);
}

// Slim upright spindles meet the curved upper bow.
for (const x of [14, 18, 22, 26, 30, 34]) {
  const u = (x - 24) / 14;
  const top = Math.round(23 + 19 * Math.sqrt(1 - u * u));
  const y = Math.round(33 + 2 * Math.sqrt(1 - u * u));
  line(x, 31, 23, x, y, top - 1, 0, wood);
  for (let z = 27; z < top - 2; z++) {
    if (z % 3 !== 0) set(x, Math.round(31 + (y - 31) * (z - 23) / (top - 23)) - 1, z, light);
  }
  box(x, 31, 23, x, 31, 25, shadow);
}

// Slightly heavier side uprights and the lower back rail.
line(11, 33, 23, 11, 34, 33, 1, wood);
line(37, 33, 23, 37, 34, 33, 1, wood);
line(13, 32, 24, 35, 32, 24, 0, dark);