← Fiestas y NavidadObjeto 3Dfogon/guirnalda-de-luces
Guirnalda de luces
Arrastrá para girarlo// «Guirnalda de luces» · gpt-6-sol (medium)
// A string of festive lights hanging between two short wooden posts: a dark green wire sagging in a gentle curve, with about twelve big chunky bulbs in alternating red, green, yellow, blue and white hanging from it.
const wood = "#a86532";
const woodLight = "#cb8750";
const woodDark = "#774322";
const gold = "#f6c94e";
const wire = "#173f30";
function wireHeight(x) {
return Math.round(13 + 5 * Math.pow((x - 24.5) / 17.5, 2));
}
// Painted feet and short wooden posts.
for (const x of [7, 42]) {
box(x - 4, 20, 0, x + 3, 27, 1, "#b92736");
box(x - 3, 21, 2, x + 2, 26, 2, "#e34a50");
box(x - 2, 21, 3, x + 1, 25, 18, wood);
box(x - 2, 21, 3, x - 2, 25, 18, woodLight);
box(x + 1, 21, 3, x + 1, 25, 18, woodDark);
box(x - 2, 21, 19, x + 1, 25, 19, gold);
box(x - 1, 22, 20, x, 24, 20, "#ffe68a");
// Cheerful painted bands and small gold rivets.
for (const z of [5, 6, 15]) {
box(x - 2, 20, z, x + 1, 21, z, z === 15 ? "#f0cf74" : "#d73542");
}
for (const z of [9, 12]) set(x - 1, 20, z, "#e3a968");
for (let n = 0; n < 22; n++) {
const z = 4 + Math.floor(rand() * 14);
const yy = 22 + Math.floor(rand() * 3);
set(x - 2, yy, z, rand() < 0.5 ? wood : "#dea06a");
}
}
// A gently sagging dark-green cable, with a fine lighter edge.
for (let x = 7; x < 42; x++) {
const z0 = wireHeight(x);
const z1 = wireHeight(x + 1);
line(x, 22, z0, x + 1, 22, z1, 0.65, wire);
if (x % 4 === 0) set(x, 21, z0, "#368263");
}
const bulbColors = [
"#f43d47", // red
"#37d276", // green
"#ffe064", // yellow
"#48a9f5", // blue
"#fff4df" // warm white
];
for (let i = 0; i < 12; i++) {
const x = 8 + i * 3;
const y = 19;
const top = wireHeight(x);
const cz = top - 4;
const color = bulbColors[i % bulbColors.length];
// Short drop cord and metallic socket stay attached to the main string.
line(x, 22, top, x, y, top - 1, 0, wire);
box(x, y, top - 2, x, y, top - 1, "#27634b");
box(x - 1, y - 1, top - 3, x + 1, y + 1, top - 2, "#a98236");
box(x - 1, y - 1, top - 2, x + 1, y + 1, top - 2, gold);
set(x - 1, y - 1, top - 2, "#ffeaa0");
// Each chunky glass globe has its own color-cycling part.
const name = "bulb" + i;
part(name, [x, y, cz]);
ellipsoid(x, y, cz, 1.8, 1.8, 2.1, color);
set(x, y, cz - 2, color);
set(x - 1, y - 1, cz + 1, "#fff9df");
set(x - 1, y - 1, cz, "#fff4c7");
set(x, y - 2, cz, "#ffffff");
animate(name, {
type: "colors",
palette: bulbColors.slice(i % 5).concat(bulbColors.slice(0, i % 5)),
pattern: "wave",
glow: 0.9
});
part("body");
}import { draw } from "./assets/voxel";
import { guirnaldaDeLuces } from "./assets/guirnalda-de-luces";
// En cada cuadro: parado sobre (x, y), el centro de su base.
draw(ctx, guirnaldaDeLuces, x, y, { size: 64, angle: 0, t: performance.now() / 1000 });
// size: lo que mide en px su lado más largo
// angle: giro sobre el piso, en radianes
// t: segundos; si se mueve, se anima solo con eso# En una terminal, en la carpeta del juego
fogon assets add guirnalda-de-luces
# Con las herramientas de Fogón (conector)
add_assets({ slug: "<tu-juego>", ids: ["guirnalda-de-luces"] })
# Queda en client/assets/guirnalda-de-luces.ts
# https://fogon.page/object/guirnalda-de-luces