img
p5.Image
Holds the image loaded in preload(); used throughout draw() to read and distort pixel data
let img;
mic
p5.AudioIn
Stores the microphone input object; created in setup() and started in mousePressed()
let mic;
amplitude
p5.Amplitude
Analyzes the microphone's audio level; provides getLevel() which returns volume as a number 0-1
let amplitude;
level
number
Stores the current microphone volume (0 = silent, 1 = loudest); read each frame and used to control distortion strength
let level = amplitude.getLevel();
timeFactor
number
Oscillates between -1 and 1 over time using a sine wave; creates continuous wobbling independent of audio
let timeFactor = sin(frameCount * 0.05);
morphCenterX
number
The X coordinate of the distortion circle's center; follows mouseX
let morphCenterX = mouseX;
morphCenterY
number
The Y coordinate of the distortion circle's center; follows mouseY
let morphCenterY = mouseY;
baseRadius
number
The radius of the distortion circle in pixels; mapped from mouseX so left side = small, right side = large
let baseRadius = map(mouseX, 0, width, 50, 300);
morphRadius
number
The radius used for distortion calculations; equals baseRadius (could be extended to vary over time)
let morphRadius = baseRadius;
audioMorphFactor
number
Controls distortion strength based on microphone volume; ranges -0.7 to 0.7 (negative = pinch, positive = bulge)
let audioMorphFactor = map(level, 0, 1, -0.7, 0.7);
timeMorphFactor
number
Adds a subtle time-based oscillation to the distortion; ranges -0.1 to 0.1
let timeMorphFactor = map(timeFactor, -1, 1, -0.1, 0.1);
morphFactor
number
The final distortion strength, combining audio and time effects; used to displace pixels
let morphFactor = audioMorphFactor + timeMorphFactor;