feat(editor): add --gen-texture-chevron V-stripe pattern

68th procedural texture: stack of V-shape stripes with
sharp seams. Within each vertical period the upper half
slopes one way and the lower half slopes the other; the
distance from the apex is added as an x-shift to the
stripe-column test, so stripes follow the V profile and
form clean chevrons.

Distinct from --gen-texture-herringbone (which alternates
slab orientation between cells) and --gen-texture-zebra
(sinusoidal stripes with no seam) — chevron has the
characteristic sharp V transition.

Useful for military insignia, sportswear, heraldic banners,
roadwork signage, paladin tabards, ranger cloaks. Default
24-period / 24-stride / 6-wide gives a chunky chevron at
256x256; tighter values read as fine ribbon trim.
This commit is contained in:
Kelsi 2026-05-09 12:57:47 -07:00
parent 9bd9b50bdb
commit 2225448dbf
3 changed files with 70 additions and 1 deletions

View file

@ -102,7 +102,7 @@ const char* const kArgRequired[] = {
"--gen-texture-mesh-screen", "--gen-texture-bamboo",
"--gen-texture-blueprint", "--gen-texture-rust-streaks",
"--gen-texture-plaid", "--gen-texture-diamond-grid",
"--gen-texture-houndstooth",
"--gen-texture-houndstooth", "--gen-texture-chevron",
"--validate-glb", "--info-glb", "--info-glb-tree", "--info-glb-bytes",
"--validate-jsondbc", "--check-glb-bounds", "--validate-stl",
"--validate-png", "--validate-blp",

View file

@ -3500,6 +3500,72 @@ int handleKnit(int& i, int argc, char** argv) {
return 0;
}
int handleChevron(int& i, int argc, char** argv) {
// Chevron: stack of V-shape bands. Within each vertical
// period, the upper half slopes one way and the lower half
// slopes the other so a pixel lands on a chevron stripe if
// its X (after a Y-dependent shift) falls inside a stripe
// column. Distinct from --gen-texture-herringbone (which
// alternates slab orientation) and --gen-texture-zebra
// (sinusoidal stripes) — chevron has the characteristic
// sharp-V seam.
std::string outPath = argv[++i];
std::string bgHex = argv[++i];
std::string lineHex = argv[++i];
int period = 24; // vertical V wavelength (pixels)
int stride = 24; // horizontal stripe pitch
int lineW = 6; // stripe thickness
int W = 256, H = 256;
parseOptInt(i, argc, argv, period);
parseOptInt(i, argc, argv, stride);
parseOptInt(i, argc, argv, lineW);
parseOptInt(i, argc, argv, W);
parseOptInt(i, argc, argv, H);
if (W < 1 || H < 1 || W > 8192 || H > 8192 ||
period < 4 || period > 1024 ||
stride < 4 || stride > 1024 ||
lineW < 1 || lineW * 2 >= stride) {
std::fprintf(stderr,
"gen-texture-chevron: invalid dims (W/H 1..8192, "
"period 4..1024, stride 4..1024, lineW 1..stride/2)\n");
return 1;
}
uint8_t br_, bg_, bb_, lr, lg, lb_;
if (!parseHexOrError(bgHex, br_, bg_, bb_, "gen-texture-chevron")) return 1;
if (!parseHexOrError(lineHex, lr, lg, lb_,
"gen-texture-chevron")) return 1;
std::vector<uint8_t> pixels(static_cast<size_t>(W) * H * 3, 0);
const int half = period / 2;
for (int y = 0; y < H; ++y) {
// V phase: distance from the nearest V point in [0, half].
// Apex points at y % period == 0 (top) and y % period ==
// period (bottom of next V).
int yPhase = y % period;
int distFromApex = std::abs(yPhase - half); // 0..half
// The chevron stripe at column N is active where
// (x + distFromApex) % stride < lineW. The +distFromApex
// shifts the stripe column to follow the V.
int xShift = distFromApex;
for (int x = 0; x < W; ++x) {
int shifted = ((x + xShift) % stride + stride) % stride;
uint8_t r, g, b;
if (shifted < lineW) {
r = lr; g = lg; b = lb_;
} else {
r = br_; g = bg_; b = bb_;
}
setPixelRGB(pixels, W, x, y, r, g, b);
}
}
if (!savePngOrError(outPath, W, H, pixels,
"gen-texture-chevron")) return 1;
printPngWrote(outPath, W, H);
std::printf(" bg/line : %s / %s\n", bgHex.c_str(), lineHex.c_str());
std::printf(" pattern : period=%d, stride=%d, lineW=%d\n",
period, stride, lineW);
return 0;
}
int handleHoundstooth(int& i, int argc, char** argv) {
// Houndstooth: classic textile broken-check pattern. The 8x8
// motif stored below tiles seamlessly to produce the
@ -4945,6 +5011,7 @@ constexpr TextureEntry kTextureTable[] = {
{"--gen-texture-plaid", 3, handlePlaid},
{"--gen-texture-diamond-grid", 3, handleDiamondGrid},
{"--gen-texture-houndstooth", 3, handleHoundstooth},
{"--gen-texture-chevron", 3, handleChevron},
};
} // namespace

View file

@ -169,6 +169,8 @@ void printUsage(const char* argv0) {
std::printf(" Diamond grid: axis-aligned solid diamonds in cells with bg gaps (clean tile / mosaic / floor inlay)\n");
std::printf(" --gen-texture-houndstooth <out.png> <toothHex> <bgHex> [cellSize] [W H]\n");
std::printf(" Houndstooth: classic textile broken-check pattern via seamless 8x8 motif (Scottish weave)\n");
std::printf(" --gen-texture-chevron <out.png> <bgHex> <lineHex> [period] [stride] [lineW] [W H]\n");
std::printf(" Chevron: stack of V-shape stripes with sharp seams (military / sportswear / heraldic banners)\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");