Synaptic Resonance

📅 April 17, 2026 🏷️ art
neuroscience generative connectome bioluminescence network-theory dynamic-systems
Generated by GridFlow AI | Tags: neuroscience, generative, connectome, bioluminescence, network-theory, dynamic-systems

📊 视觉感受量化评分

0
0
0
0

💡 AI 提示词

Create a generative p5.js sketch representing a neural synapse network with firing electrical pulses, interconnected nodes, and a deep, ethereal color palette.

🧠 核心算法要点

  • Initialize a density-aware population of Neuron objects based on current canvas area.
  • Implement a spatial adjacency check to visualize connections between neurons within a specific range.
  • Develop a 'Signal' class that uses linear interpolation (lerp) to move between node coordinates.
  • Apply additive color blending (p.ADD) to simulate the luminous glow of electrical activity.
  • Use a frame-based probability trigger to simulate stochastic neural firing patterns.
  • Incorporate a trailing particle system for signals to emphasize the direction of data flow.

💻 原始 p5.js 代码

var sketch = function(p) {
    let neurons = [];
    let signals = [];
    let maxNeurons = 60;
    let connectionDist;

    p.setup = function() {
        let container = document.getElementById('p5-wrapper'); p.createCanvas(container.offsetWidth, container.offsetHeight).parent('p5-wrapper');
        p.pixelDensity(1);
        initNetwork();
    };

    p.draw = function() {
        p.background(5, 10, 25);
        
        // Subtle glow effect
        p.blendMode(p.ADD);
        
        // Update and show connections
        p.strokeWeight(1);
        for (let i = 0; i < neurons.length; i++) {
            neurons[i].update();
            neurons[i].show();
            
            for (let j = i + 1; j < neurons.length; j++) {
                let d = p.dist(neurons[i].pos.x, neurons[i].pos.y, neurons[j].pos.x, neurons[j].pos.y);
                if (d < connectionDist) {
                    let alpha = p.map(d, 0, connectionDist, 100, 0);
                    p.stroke(60, 100, 255, alpha);
                    p.line(neurons[i].pos.x, neurons[i].pos.y, neurons[j].pos.x, neurons[j].pos.y);
                }
            }
        }

        // Update and show firing signals
        for (let i = signals.length - 1; i >= 0; i--) {
            signals[i].update();
            signals[i].show();
            if (signals[i].isDead) {
                signals.splice(i, 1);
            }
        }

        // Randomly trigger firing
        if (p.frameCount % 10 === 0) {
            let starter = p.random(neurons);
            starter.fire();
        }
        
        p.blendMode(p.BLEND);
    };

    function initNetwork() {
        neurons = [];
        signals = [];
        connectionDist = p.min(p.width, p.height) * 0.25;
        let count = p.floor((p.width * p.height) / 18000);
        count = p.constrain(count, 30, 120);
        
        for (let i = 0; i < count; i++) {
            neurons.push(new Neuron(p.random(p.width), p.random(p.height)));
        }
    }

    p.windowResized = function() {
        let container = document.getElementById('p5-wrapper'); p.resizeCanvas(container.offsetWidth, container.offsetHeight);
        initNetwork();
    };

    class Neuron {
        constructor(x, y) {
            this.pos = p.createVector(x, y);
            this.vel = p.createVector(p.random(-0.5, 0.5), p.random(-0.5, 0.5));
            this.size = p.random(3, 6);
            this.lastFired = 0;
        }

        update() {
            this.pos.add(this.vel);
            if (this.pos.x < 0 || this.pos.x > p.width) this.vel.x *= -1;
            if (this.pos.y < 0 || this.pos.y > p.height) this.vel.y *= -1;
        }

        show() {
            p.noStroke();
            p.fill(100, 200, 255, 150);
            p.ellipse(this.pos.x, this.pos.y, this.size);
        }

        fire() {
            if (p.millis() - this.lastFired < 1000) return;
            this.lastFired = p.millis();
            
            // Find neighbors to send signal
            for (let other of neurons) {
                if (other === this) continue;
                let d = p.dist(this.pos.x, this.pos.y, other.pos.x, other.pos.y);
                if (d < connectionDist) {
                    signals.push(new Signal(this.pos, other.pos));
                }
            }
        }
    }

    class Signal {
        constructor(start, end) {
            this.start = start.copy();
            this.end = end.copy();
            this.progress = 0;
            this.speed = p.random(0.01, 0.03);
            this.isDead = false;
            this.col = p.color(p.random(150, 255), p.random(100, 200), 255);
        }

        update() {
            this.progress += this.speed;
            if (this.progress >= 1) {
                this.isDead = true;
            }
        }

        show() {
            let x = p.lerp(this.start.x, this.end.x, this.progress);
            let y = p.lerp(this.start.y, this.end.y, this.progress);
            p.fill(this.col);
            p.noStroke();
            p.ellipse(x, y, 4, 4);
            
            // Trail effect
            for(let i = 0; i < 5; i++) {
                let tx = p.lerp(this.start.x, this.end.x, p.max(0, this.progress - i * 0.02));
                let ty = p.lerp(this.start.y, this.end.y, p.max(0, this.progress - i * 0.02));
                p.fill(this.col.levels[0], this.col.levels[1], this.col.levels[2], 150 - (i * 30));
                p.ellipse(tx, ty, 3 - (i * 0.5));
            }
        }
    }
};
new p5(sketch);

🎨 AI 艺术解读

Synaptic Resonance visualizes the constant flux of information within a thinking mind. By translating biological data transmission into glowing trajectories and interconnected nodes, the piece highlights the beauty of systemic complexity. Each pulse represents a fleeting thought or memory, traversing the fragile architecture of the network before fading into the digital void.

📝 补充说明

  • Uses p.lerp() for smooth signal travel regardless of connection distance.
  • Responsive neuron density ensures the visual complexity remains consistent across mobile and desktop screens.
  • The blendMode(p.ADD) is critical for achieving the 'neon glow' aesthetic without heavy blur filters.
  • Performance is optimized by recycling Signal objects and limiting connection checks via distance thresholds.