Add a tiles effect

The two-dimensional counterpart of scanlines: rectangular tiles cut at
random positions from the source images, in three arrangements. A grid
draws its column widths and row heights once so the cells stay aligned
even when jittered; brick repacks every row on its own so the vertical
seams do not meet; scatter fills the canvas from one of the images and
drops loose tiles over it.

The plan is drawn serially from the rng as scanlines does, but scattered
tiles overlap, so they are painted in plan order on one thread: letting
threads race for the same pixels would leave the output depending on
their scheduling. A source smaller than a tile is repeated to fill the
cell, sideways and then downwards, which keeps grid and brick gapless.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Si
2026-09-18 22:10:54 +02:00
co-authored by Claude Opus 5
parent 1d0343b90a
commit 749ea239bb
6 changed files with 293 additions and 2 deletions
+23
View File
@@ -0,0 +1,23 @@
#pragma once
#include "core/effect.hpp"
namespace effector {
// Covers the canvas with rectangular tiles cut at random positions from the
// source images: the two-dimensional counterpart of the scanlines effect.
class TilesEffect : public Effect {
public:
std::string name() const override { return "tiles"; }
std::string title() const override { return "Tiles"; }
std::string description() const override {
return "Cuts rectangular tiles at random positions from the source images and lays "
"them over the canvas, in a grid, in offset rows or scattered about.";
}
const std::vector<ParamSpec>& params() const override;
Image render(const std::vector<Image>& sources, int width, int height, Rng& rng,
const ParamValues& values) const override;
};
} // namespace effector