textmode.synth.js / src
Function: src()
ts
function src(source?): SynthSource;Sample a source for synth compositions.
This is the core of feedback loops and source sampling - it reads from various sources, enabling effects like trails, motion blur, image processing, and recursive patterns.
Three modes of operation:
Self-feedback (
src()with no arguments): Samples from the previous frame- Context-aware: automatically samples the appropriate texture based on compilation context
- Inside
char(...)→ samples previous frame's character data - Inside
charColor(...)→ samples previous frame's primary color - Inside
cellColor(...)→ samples previous frame's cell color
Cross-layer sampling (
src(layer)): Samples from another layer's output- Enables hydra-style multi-output compositions
- Context-aware based on current compilation target
TextmodeSource sampling (
src(image)orsrc(video)): Samples from loaded media- Works with TextmodeImage and TextmodeVideo loaded via
t.loadImage()ort.loadVideo() - Samples directly from the source texture
- Works with TextmodeImage and TextmodeVideo loaded via
Equivalent to hydra's src(o0).
Parameters
| Parameter | Type | Description |
|---|---|---|
source? | | TextmodeLayer | TextmodeSource | () => TextmodeLayer | TextmodeSource | undefined | Optional source to sample from: TextmodeLayer for cross-layer, or TextmodeImage/TextmodeVideo for media |
Returns
A new SynthSource that samples the specified source or self
Example
javascript
const t = textmode.create({
width: window.innerWidth,
height: window.innerHeight,
plugins: [SynthPlugin]
});
t.layers.base.synth(
src()
.scale(1.01)
.blend(osc(6, 0.1, 1.2), 0.1)
);
t.windowResized(() => {
t.resizeCanvas(window.innerWidth, window.innerHeight);
});