Add a text effect
Writes a line or several over its input in a chosen family, weight, size and colour, optionally on a box filled with a colour or with a picture from disk. Like the blur and the overlay it needs no sources of its own, so it can lead a chain; given sources it fills the canvas from a randomly chosen one first. Two param types rather than effect-specific branches in the front-ends: Text, free-form text the user types, and Color, a colour written "#rrggbb". Both travel as strings, so the interface gets an entry and a colour button, the command line gets a flag (a colour that does not parse is refused there rather than drawn as black), and a project keeps them across a round trip. The glyphs come from Pango, which draws through Cairo without a display, so the core stays headless — but they are the one thing here that is not byte-identical across machines: a machine without the chosen family renders the substitute its fontconfig picks. Everything the effect is handed, the rng included, is used exactly as every other effect uses it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -45,7 +45,10 @@ about an effect: `src/gui/window.cpp` builds SpinButtons/Switches/DropDowns/file
|
||||
choosers from them and `src/cli/options.cpp` generates flags from them
|
||||
(`strip_height` → `--strip-height`). Never add effect-specific branches to the
|
||||
GUI or the parser — add a `ParamSpec` instead. A `Path` param names a file on
|
||||
disk; like a source path it is written relative to the project folder. Values
|
||||
disk; like a source path it is written relative to the project folder. A `Text`
|
||||
param is free-form text the user types, and a `Color` param is a colour written
|
||||
`#rrggbb` (`parseColor`/`formatColor`/`paramColor` in `src/core/params.hpp`),
|
||||
shown as a colour button in the interface. Values
|
||||
travel as `ParamValues` (a
|
||||
`map<string, variant<long,double,bool,string>>`), read back with
|
||||
`paramInt`/`paramDouble`/`paramBool`/`paramChoice`.
|
||||
@@ -96,7 +99,8 @@ is discarded rather than mixed into the new project (`dropLoadedImages_`).
|
||||
### Two link targets, deliberately
|
||||
|
||||
`effector_core` (static) holds image IO, params, effects, rng and links only
|
||||
`gdk-pixbuf-2.0` + Threads — **no gtkmm, no display**. The `effector` executable
|
||||
`gdk-pixbuf-2.0`, `pangocairo` (the text effect's glyphs; Pango and Cairo need
|
||||
no display) + Threads — **no gtkmm, no display**. The `effector` executable
|
||||
adds `src/main.cpp`, `src/cli/`, `src/gui/` and links gtkmm. Keep GTK out of
|
||||
`src/core/` and `src/effects/`; the tests link the core alone and rely on this.
|
||||
|
||||
@@ -105,7 +109,10 @@ adds `src/main.cpp`, `src/cli/`, `src/gui/` and links gtkmm. Keep GTK out of
|
||||
`Rng` (`src/core/rng.hpp`) is a hand-written xoshiro256\*\* rather than
|
||||
`<random>`, because libstdc++ distributions are not portable across
|
||||
implementations. Same sources + settings + seed must produce byte-identical
|
||||
output on any machine — the tests assert this. Effects must draw *every* random
|
||||
output on any machine — the tests assert this. The one thing outside this is the
|
||||
text effect's glyphs, which are whatever shapes the machine's fonts and
|
||||
fontconfig give: everything it is handed, the rng included, is still used the
|
||||
same way. Effects must draw *every* random
|
||||
value from the `Rng&` they are handed, and must not depend on thread scheduling:
|
||||
the scanlines effect first draws the whole strip plan serially from the rng,
|
||||
then copies pixels in parallel.
|
||||
|
||||
Reference in New Issue
Block a user