mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-10 19:13:52 +00:00
feat(editor): add --gen-texture-moon disc with phase shadow
82nd procedural texture: solid filled circle of moonHex on bg, with an optional crescent shadow created by subtracting a second bg-colored disc offset by `phase` pixels along +X. Phase reads as the lunar-cycle moment: • phase = 0 — full moon • 0 < phase < moonR — gibbous (waning right) • phase = moonR — half moon • phase > moonR — crescent (thinner as phase grows) Useful for night-sky overlays, banner moons (heraldry of night-themed orders), shrine medallion centers, druid / priest emblem inserts, lunar-festival decoration, vampire- zone backdrops. The simplest centered-disc texture in the catalogue — pairs naturally with --gen-texture-stars for a complete night-sky composite.
This commit is contained in:
parent
d9761046f9
commit
706c820f8a
3 changed files with 65 additions and 1 deletions
|
|
@ -125,7 +125,7 @@ const char* const kArgRequired[] = {
|
|||
"--gen-texture-dewdrops", "--gen-texture-pinwheel",
|
||||
"--gen-texture-scratched-metal", "--gen-texture-crackle",
|
||||
"--gen-texture-star", "--gen-texture-halftone",
|
||||
"--gen-texture-bayer",
|
||||
"--gen-texture-bayer", "--gen-texture-moon",
|
||||
"--validate-glb", "--info-glb", "--info-glb-tree", "--info-glb-bytes",
|
||||
"--validate-jsondbc", "--check-glb-bounds", "--validate-stl",
|
||||
"--validate-png", "--validate-blp",
|
||||
|
|
|
|||
|
|
@ -3500,6 +3500,67 @@ int handleKnit(int& i, int argc, char** argv) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int handleMoon(int& i, int argc, char** argv) {
|
||||
// Moon disc: solid filled circle of color moonHex on a bg.
|
||||
// Optional crescent: subtract a second disc of color bgHex
|
||||
// offset by `phase` pixels along +X. With phase=0 the result
|
||||
// is a full moon; with phase = moonR the result is roughly a
|
||||
// half-moon; phase > moonR gives a thin crescent.
|
||||
std::string outPath = argv[++i];
|
||||
std::string bgHex = argv[++i];
|
||||
std::string moonHex = argv[++i];
|
||||
int moonR = 80;
|
||||
int phase = 0; // 0 = full moon
|
||||
int W = 256, H = 256;
|
||||
parseOptInt(i, argc, argv, moonR);
|
||||
parseOptInt(i, argc, argv, phase);
|
||||
parseOptInt(i, argc, argv, W);
|
||||
parseOptInt(i, argc, argv, H);
|
||||
if (W < 1 || H < 1 || W > 8192 || H > 8192 ||
|
||||
moonR < 4 || moonR > 4096 ||
|
||||
phase < 0 || phase > 2 * moonR) {
|
||||
std::fprintf(stderr,
|
||||
"gen-texture-moon: invalid dims (W/H 1..8192, "
|
||||
"moonR 4..4096, phase 0..2*moonR)\n");
|
||||
return 1;
|
||||
}
|
||||
uint8_t br_, bg_, bb_, mr, mg, mb_;
|
||||
if (!parseHexOrError(bgHex, br_, bg_, bb_, "gen-texture-moon")) return 1;
|
||||
if (!parseHexOrError(moonHex, mr, mg, mb_,
|
||||
"gen-texture-moon")) return 1;
|
||||
std::vector<uint8_t> pixels(static_cast<size_t>(W) * H * 3, 0);
|
||||
const float cx = W * 0.5f;
|
||||
const float cy = H * 0.5f;
|
||||
const float shadowCX = cx + phase; // shadow disc offset
|
||||
const float moonR2 = static_cast<float>(moonR) * moonR;
|
||||
for (int y = 0; y < H; ++y) {
|
||||
for (int x = 0; x < W; ++x) {
|
||||
float dx = x - cx;
|
||||
float dy = y - cy;
|
||||
bool inMoon = (dx * dx + dy * dy) <= moonR2;
|
||||
float sdx = x - shadowCX;
|
||||
bool inShadow = phase > 0 &&
|
||||
(sdx * sdx + dy * dy) <= moonR2;
|
||||
uint8_t r, g, b;
|
||||
if (inMoon && !inShadow) {
|
||||
r = mr; g = mg; b = mb_;
|
||||
} else {
|
||||
r = br_; g = bg_; b = bb_;
|
||||
}
|
||||
setPixelRGB(pixels, W, x, y, r, g, b);
|
||||
}
|
||||
}
|
||||
if (!savePngOrError(outPath, W, H, pixels, "gen-texture-moon")) return 1;
|
||||
printPngWrote(outPath, W, H);
|
||||
std::printf(" bg/moon : %s / %s\n", bgHex.c_str(), moonHex.c_str());
|
||||
std::printf(" disc : R=%d, phase=%d (%s)\n",
|
||||
moonR, phase,
|
||||
phase == 0 ? "full" :
|
||||
(phase < moonR ? "gibbous" :
|
||||
(phase == moonR ? "half" : "crescent")));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int handleBayer(int& i, int argc, char** argv) {
|
||||
// Classic 4x4 ordered-dither Bayer matrix tiled across the
|
||||
// image. Each pixel's color comes from interpolating bg → fg
|
||||
|
|
@ -5971,6 +6032,7 @@ constexpr TextureEntry kTextureTable[] = {
|
|||
{"--gen-texture-star", 3, handleStar},
|
||||
{"--gen-texture-halftone", 3, handleHalftone},
|
||||
{"--gen-texture-bayer", 3, handleBayer},
|
||||
{"--gen-texture-moon", 3, handleMoon},
|
||||
};
|
||||
} // namespace
|
||||
|
||||
|
|
|
|||
|
|
@ -197,6 +197,8 @@ void printUsage(const char* argv0) {
|
|||
std::printf(" Halftone: grid of dots whose radii grow with a v/h/r gradient (comic / newspaper print look)\n");
|
||||
std::printf(" --gen-texture-bayer <out.png> <aHex> <bHex> [cellSize] [W H]\n");
|
||||
std::printf(" Bayer: 4x4 ordered-dither matrix tiled (retro / 8-bit / monochrome-CRT effects)\n");
|
||||
std::printf(" --gen-texture-moon <out.png> <bgHex> <moonHex> [moonR] [phase] [W H]\n");
|
||||
std::printf(" Moon disc with optional crescent shadow (phase 0=full, =moonR=half, >moonR=crescent)\n");
|
||||
std::printf(" --add-texture-to-zone <zoneDir> <png-path> [renameTo]\n");
|
||||
std::printf(" Copy an existing PNG into <zoneDir> (optionally renaming it on the way in)\n");
|
||||
std::printf(" --gen-mesh <wom-base> <cube|plane|sphere|cylinder|torus|cone|ramp> [size]\n");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue