Mycelial Consciousness Lattice

📅 April 25, 2026 🏷️ art
L-system neural-network mycelial bismuth-crystal recursive-fractal consciousness generative-art geometric-pastel pending-review
Generated by GridFlow AI | Tags: L-system, neural-network, mycelial, bismuth-crystal, recursive-fractal, consciousness, generative-art, geometric-pastel

💡 AI 提示词

Create a visually stunning p5.js artwork representing Mycelial Consciousness Neural Network Lattice with bismuth crystal aesthetic - geometric pastel rainbow interference patterns on dark background using extreme recursive L-systems to simulate fungal/neuronal consciousness with multi-layer compositing, blend modes, and interactive elements.

🔧 核心算法要点

  1. L-system fractal generation with recursive branching simulating mycelial network growth patterns
  2. Multi-layer offscreen buffer compositing using createGraphics for depth and glow effects
  3. Multiple wave interference patterns creating bismuth crystal iridescence on dark void background
  4. Geometric hexagonal lattice structure with rotating geometric shapes forming neural connections
  5. Consciousness nodes placed at branch tips with pulsing glow effects and luminosity through ADD blend mode
  6. Mouse proximity affects wave interference and crystal growth angles, click spawns new crystal formations

🎨 原始代码

var sketch = function(p) {
  var bgBuffer, crystalBuffer, latticeBuffer, glowBuffer;
  var lSystems = [];
  var time = 0;
  var interactionMode = 0;
  var mouseAttract = {x: 0, y: 0, strength: 0};
  var crystalPalette = [];
  
  // Bismuth crystal pastel palette
  var initPalette = function() {
    crystalPalette = [
      p.color(255, 182, 193, 200),  // pale rose
      p.color(230, 230, 250, 200),  // lavender mist
      p.color(175, 238, 238, 200),  // pale cyan
      p.color(255, 218, 185, 200),  // peach
      p.color(255, 255, 224, 200),  // pale yellow
      p.color(216, 191, 216, 200),  // thistle
      p.color(152, 251, 152, 180),  // pale green
      p.color(255, 182, 193, 220),  // soft pink
      p.color(173, 216, 230, 200),  // light blue
    ];
  };

  // L-System class for fractal branching
  var LSystem = function(x, y, angle, depth) {
    this.pos = p.createVector(x, y);
    this.angle = angle;
    this.depth = depth;
    this.branches = [];
    this.segments = [];
    this.nodePoints = [];
    this.generate();
  };

  LSystem.prototype.generate = function() {
    var maxDepth = 8;
    var branchStack = [{pos: this.pos.copy(), angle: this.angle, depth: 0, length: p.height * 0.3}];
    
    while (branchStack.length > 0) {
      var current = branchStack.pop();
      if (current.depth > maxDepth) continue;
      
      var lenDecay = p.pow(0.65, current.depth);
      var segLength = current.length * lenDecay;
      
      var endX = current.pos.x + p.cos(current.angle) * segLength;
      var endY = current.pos.y + p.sin(current.angle) * segLength;
      var endPos = p.createVector(endX, endY);
      
      var colorIdx = current.depth % crystalPalette.length;
      this.segments.push({
        start: current.pos.copy(),
        end: endPos,
        depth: current.depth,
        colorIdx: colorIdx
      });
      
      // Add consciousness node at branch tips
      if (current.depth >= 3) {
        this.nodePoints.push({
          pos: endPos.copy(),
          depth: current.depth,
          size: p.map(current.depth, 3, maxDepth, 3, 12),
          pulse: p.random(p.TWO_PI),
          colorIdx: colorIdx
        });
      }
      
      // Branching with crystalline geometry
      var numBranches = current.depth < 2 ? p.floor(p.random(2, 4)) : p.floor(p.random(1, 3));
      
      for (var i = 0; i < numBranches; i++) {
        var angleOffset;
        if (current.depth < 3) {
          // Geometric bismuth angles
          angleOffset = (i - (numBranches - 1) / 2) * p.PI / (3 + current.depth * 0.5);
          angleOffset += p.random(-0.1, 0.1);
        } else {
          // Mycelial organic angles
          angleOffset = p.random(-p.PI / 3, p.PI / 3) * (1 - current.depth / maxDepth);
        }
        
        var newAngle = current.angle + angleOffset;
        var jitter = mouseAttract.strength * 0.3;
        newAngle += p.sin(time * 2 + current.depth) * jitter;
        
        var newLength = segLength * p.random(0.7, 0.9);
        
        branchStack.push({
          pos: endPos.copy(),
          angle: newAngle,
          depth: current.depth + 1,
          length: newLength
        });
      }
    }
  };

  LSystem.prototype.draw = function(g, mode) {
    g.push();
    g.translate(this.pos.x, this.pos.y);
    
    // Draw segments
    for (var i = 0; i < this.segments.length; i++) {
      var seg = this.segments[i];
      var localStart = p.createVector(seg.start.x - this.pos.x, seg.start.y - this.pos.y);
      var localEnd = p.createVector(seg.end.x - this.pos.x, seg.end.y - this.pos.y);
      
      var col = crystalPalette[seg.colorIdx];
      var alphaMult = p.map(seg.depth, 0, 8, 1, 0.3);
      
      g.stroke(p.red(col), p.green(col), p.blue(col), p.alpha(col) * alphaMult);
      g.strokeWeight(p.map(seg.depth, 0, 8, 4, 0.5));
      g.strokeCap(p.ROUND);
      g.line(localStart.x, localStart.y, localEnd.x, localEnd.y);
      
      // Add geometric interference lines
      if (mode === 1 && seg.depth > 2) {
        var midX = (localStart.x + localEnd.x) / 2;
        var midY = (localStart.y + localEnd.y) / 2;
        var perpAngle = seg.depth > 4 ? p.HALF_PI : p.QUARTER_PI;
        var interferenceLen = p.sin(time * 3 + seg.depth * 0.5) * 20 + 15;
        
        g.stroke(255, 255, 255, 40);
        g.strokeWeight(0.5);
        g.line(
          midX + p.cos(seg.angle + perpAngle) * interferenceLen,
          midY + p.sin(seg.angle + perpAngle) * interferenceLen,
          midX - p.cos(seg.angle + perpAngle) * interferenceLen,
          midY - p.sin(seg.angle + perpAngle) * interferenceLen
        );
      }
    }
    
    g.pop();
    
    // Draw consciousness nodes
    for (var i = 0; i < this.nodePoints.length; i++) {
      var node = this.nodePoints[i];
      var localX = node.pos.x - this.pos.x;
      var localY = node.pos.y - this.pos.y;
      var pulse = p.sin(time * 2 + node.pulse) * 0.3 + 0.7;
      var size = node.size * pulse;
      
      // Glow effect
      for (var j = 3; j >= 0; j--) {
        var glowSize = size + j * 4;
        var col = crystalPalette[node.colorIdx];
        g.noStroke();
        g.fill(p.red(col), p.green(col), p.blue(col), 20 - j * 5);
        g.ellipse(localX, localY, glowSize, glowSize);
      }
      
      // Core crystal
      g.fill(255, 255, 255, 200);
      g.ellipse(localX, localY, size, size);
    }
  };

  // Interference pattern generator
  var drawInterference = function(g, w, h) {
    var step = 4;
    var mouseInfluence = p.map(p.dist(p.mouseX, p.mouseY, w/2, h/2), 0, p.max(w, h), 0, 1);
    mouseInfluence = p.constrain(mouseInfluence, 0, 1);
    
    for (var x = 0; x < w; x += step) {
      for (var y = 0; y < h; y += step) {
        var nx = x / w;
        var ny = y / h;
        
        // Multiple wave interference
        var wave1 = p.sin(x * 0.02 + time * 1.5) * p.cos(y * 0.015 + time);
        var wave2 = p.sin(x * 0.025 - time * 0.8 + ny * 4) * p.cos(y * 0.02 + time * 1.2);
        var wave3 = p.sin(p.dist(x, y, w/2, h/2) * 0.015 - time * 2) * mouseInfluence;
        
        var interference = (wave1 + wave2 + wave3) / 3;
        interference = (interference + 1) * 0.5;
        interference = p.pow(interference, 1.5);
        
        // Map to bismuth palette
        var palIdx = p.floor(p.map(interference, 0, 1, 0, crystalPalette.length));
        palIdx = p.constrain(palIdx, 0, crystalPalette.length - 1);
        
        var col = crystalPalette[palIdx];
        var alpha = p.map(interference, 0, 1, 10, 60) * (0.3 + mouseInfluence * 0.4);
        
        g.noStroke();
        g.fill(p.red(col), p.green(col), p.blue(col), alpha);
        g.rect(x, y, step, step);
      }
    }
  };

  // Lattice geometry generator
  var drawLattice = function(g, w, h) {
    var gridSize = 60 + p.sin(time * 0.5) * 10;
    g.stroke(255, 255, 255, 15);
    g.strokeWeight(0.5);
    g.noFill();
    
    var offsetX = (time * 10) % gridSize;
    var offsetY = (time * 8) % gridSize;
    
    // Hexagonal lattice pattern
    for (var x = -gridSize + offsetX; x < w + gridSize; x += gridSize) {
      for (var y = -gridSize + offsetY; y < h + gridSize; y += gridSize * 0.866) {
        var hexRadius = 25 + p.sin(x * 0.01 + y * 0.01 + time) * 8;
        var colIdx = p.floor((x + y + time * 20) / gridSize) % crystalPalette.length;
        var col = crystalPalette[colIdx];
        
        // Draw hexagon
        g.push();
        g.translate(x, y);
        g.rotate(time * 0.2 + p.sin(x * 0.05) * 0.3);
        
        g.beginShape();
        for (var i = 0; i < 6; i++) {
          var angle = p.TWO_PI / 6 * i;
          g.vertex(p.cos(angle) * hexRadius, p.sin(angle) * hexRadius);
        }
        g.endShape(p.CLOSE);
        
        // Inner geometric detail
        g.stroke(p.red(col), p.green(col), p.blue(col), 30);
        g.strokeWeight(0.3);
        g.beginShape();
        for (var i = 0; i < 6; i++) {
          var angle = p.TWO_PI / 6 * i + p.QUARTER_PI;
          g.vertex(p.cos(angle) * hexRadius * 0.5, p.sin(angle) * hexRadius * 0.5);
        }
        g.endShape(p.CLOSE);
        
        g.pop();
      }
    }
    
    // Connecting neural lines
    g.stroke(255, 255, 255, 8);
    g.strokeWeight(0.3);
    for (var i = 0; i < 20; i++) {
      var x1 = p.noise(i * 0.3, time * 0.1) * w;
      var y1 = p.noise(i * 0.3 + 100, time * 0.1) * h;
      var x2 = p.noise(i * 0.3 + 200, time * 0.1 + 50) * w;
      var y2 = p.noise(i * 0.3 + 300, time * 0.1 + 50) * h;
      g.line(x1, y1, x2, y2);
    }
  };

  p.setup = function() {
    var container = document.getElementById('p5-wrapper');
    var w = container.offsetWidth;
    var h = container.offsetHeight;
    
    p.createCanvas(w, h).parent(container);
    p.colorMode(p.RGB, 255, 255, 255, 255);
    
    initPalette();
    
    // Create offscreen buffers
    bgBuffer = p.createGraphics(w, h);
    crystalBuffer = p.createGraphics(w, h);
    latticeBuffer = p.createGraphics(w, h);
    glowBuffer = p.createGraphics(w, h);
    
    // Initialize L-systems
    var numSystems = 5;
    for (var i = 0; i < numSystems; i++) {
      var x = p.random(w * 0.2, w * 0.8);
      var y = h * 0.85;
      var angle = -p.PI / 2 + p.random(-0.3, 0.3);
      var depth = p.floor(p.random(6, 9));
      lSystems.push(new LSystem(x, y, angle, depth));
    }
    
    // Additional vertical systems
    for (var i = 0; i < 3; i++) {
      var x = p.random(w * 0.1, w * 0.9);
      var y = h * 0.9;
      var angle = -p.PI / 2 + p.random(-0.2, 0.2);
      var depth = p.floor(p.random(5, 7));
      lSystems.push(new LSystem(x, y, angle, depth));
    }
    
    p.noiseDetail(4, 0.5);
  };

  p.draw = function() {
    time += 0.008;
    
    var w = p.width;
    var h = p.height;
    
    // Update mouse attract
    var distToCenter = p.dist(p.mouseX, p.mouseY, w/2, h/2);
    mouseAttract.strength = p.map(distToCenter, 0, p.max(w, h), 1, 0);
    mouseAttract.x = p.mouseX;
    mouseAttract.y = p.mouseY;
    
    // Background buffer - deep dark void
    bgBuffer.background(8, 6, 18, 255);
    
    // Add subtle depth gradient
    for (var y = 0; y < h; y += 2) {
      var alpha = p.map(y, 0, h, 5, 25);
      bgBuffer.stroke(30, 20, 50, alpha);
      bgBuffer.line(0, y, w, y);
    }
    
    // Lattice layer
    latticeBuffer.clear();
    drawLattice(latticeBuffer, w, h);
    
    // Crystal L-systems layer
    crystalBuffer.clear();
    crystalBuffer.blendMode(p.ADD);
    
    for (var i = 0; i < lSystems.length; i++) {
      lSystems[i].draw(crystalBuffer, interactionMode);
    }
    
    // Glow buffer for luminous effects
    glowBuffer.clear();
    glowBuffer.blendMode(p.ADD);
    
    // Add concentrated glow at intersections
    for (var i = 0; i < lSystems.length; i++) {
      var ls = lSystems[i];
      for (var j = 0; j < ls.nodePoints.length; j++) {
        var node = ls.nodePoints[j];
        var glowSize = node.size * 8 + p.sin(time * 3 + node.pulse) * 10;
        
        for (var k = 3; k >= 0; k--) {
          var palIdx = (node.colorIdx + k) % crystalPalette.length;
          var col = crystalPalette[palIdx];
          glowBuffer.noStroke();
          glowBuffer.fill(p.red(col), p.green(col), p.blue(col), 8 - k * 2);
          glowBuffer.ellipse(node.pos.x, node.pos.y, glowSize + k * 15, glowSize + k * 15);
        }
      }
    }
    
    // Composite all layers
    p.background(0);
    p.image(bgBuffer, 0, 0);
    
    // Lattice with SCREEN blend
    p.blendMode(p.SCREEN);
    p.image(latticeBuffer, 0, 0);
    
    // Crystal structures with ADD blend
    p.blendMode(p.ADD);
    p.image(crystalBuffer, 0, 0);
    
    // Glow layer for ethereal luminosity
    p.blendMode(p.SCREEN);
    p.tint(255, 180);
    p.image(glowBuffer, 0, 0);
    p.tint(255, 255);
    
    // Interference overlay
    p.blendMode(p.OVERLAY);
    var interferenceBuffer = p.createGraphics(w, h);
    drawInterference(interferenceBuffer, w, h);
    p.image(interferenceBuffer, 0, 0);
    interferenceBuffer.remove();
    
    p.blendMode(p.BLEND);
    
    // Central consciousness core
    var coreX = w / 2;
    var coreY = h * 0.35;
    var coreSize = 80 + p.sin(time * 1.5) * 20;
    
    for (var r = 3; r >= 0; r--) {
      var radius = coreSize + r * 30;
      var alpha = 30 - r * 8;
      var col = crystalPalette[r % crystalPalette.length];
      p.noFill();
      p.stroke(p.red(col), p.green(col), p.blue(col), alpha);
      p.strokeWeight(2 - r * 0.5);
      
      p.beginShape();
      for (var a = 0; a < p.TWO_PI; a += 0.1) {
        var nr = radius + p.noise(a * 2 + time, r) * 15;
        p.vertex(coreX + p.cos(a + time * 0.3) * nr, coreY + p.sin(a + time * 0.3) * nr);
      }
      p.endShape(p.CLOSE);
    }
    
    // Mouse interaction highlight
    if (mouseAttract.strength > 0.1) {
      p.noFill();
      p.stroke(255, 255, 255, 50 * mouseAttract.strength);
      p.strokeWeight(1);
      p.ellipse(p.mouseX, p.mouseY, 100 * mouseAttract.strength, 100 * mouseAttract.strength);
    }
  };

  p.mousePressed = function() {
    // Click creates a burst of new crystal growth
    var numNew = 3;
    for (var i = 0; i < numNew; i++) {
      var angle = p.random(p.TWO_PI);
      var dist = p.random(50, 150);
      var x = p.mouseX + p.cos(angle) * dist;
      var y = p.mouseY + p.sin(angle) * dist;
      var startAngle = p.atan2(p.mouseY - y, p.mouseX - x) + p.random(-0.5, 0.5);
      lSystems.push(new LSystem(x, y, startAngle, p.floor(p.random(4, 7))));
    }
    // Limit total systems
    while (lSystems.length > 12) {
      lSystems.shift();
    }
  };

  p.keyPressed = function() {
    // Space: Cycle interaction mode
    if (p.key === ' ') {
      interactionMode = (interactionMode + 1) % 3;
    }
    // R: Reset systems
    if (p.key === 'r' || p.key === 'R') {
      lSystems = [];
      var numSystems = 6;
      for (var i = 0; i < numSystems; i++) {
        var x = p.random(p.width * 0.2, p.width * 0.8);
        var y = p.height * 0.85;
        var angle = -p.PI / 2 + p.random(-0.3, 0.3);
        var depth = p.floor(p.random(6, 9));
        lSystems.push(new LSystem(x, y, angle, depth));
      }
    }
    // C: Cycle palette variant
    if (p.key === 'c' || p.key === 'C') {
      // Shift palette colors slightly
      for (var i = 0; i < crystalPalette.length; i++) {
        var c = crystalPalette[i];
        var shift = 10;
        crystalPalette[i] = p.color(
          p.constrain(p.red(c) + p.random(-shift, shift), 150, 255),
          p.constrain(p.green(c) + p.random(-shift, shift), 150, 255),
          p.constrain(p.blue(c) + p.random(-shift, shift), 150, 255),
          200
        );
      }
    }
  };

  p.windowResized = function() {
    var container = document.getElementById('p5-wrapper');
    var w = container.offsetWidth;
    var h = container.offsetHeight;
    p.resizeCanvas(w, h);
    
    // Recreate buffers at new size
    bgBuffer = p.createGraphics(w, h);
    crystalBuffer = p.createGraphics(w, h);
    latticeBuffer = p.createGraphics(w, h);
    glowBuffer = p.createGraphics(w, h);
    
    // Reposition L-systems
    for (var i = 0; i < lSystems.length; i++) {
      lSystems[i].pos.x = p.constrain(lSystems[i].pos.x, 0, w);
      lSystems[i].pos.y = p.constrain(lSystems[i].pos.y, h * 0.5, h);
    }
  };
};
// p5 init stripped

✨ AI 艺术解读

This artwork visualizes the emergence of consciousness from interconnected mycelial networks - crystalline fractal structures grow upward from darkness like frozen thoughts, their branching patterns mimicking both fungal networks and neural synapses. The bismuth crystal palette creates an otherworldly atmosphere where geometric pastel interference patterns suggest the fragile beauty of awareness itself. As the viewer interacts, new growths emerge from click points, implying that consciousness is both organic and responsive to presence. The layered composite with lattice geometry beneath the crystal formations represents the underlying mathematical order within biological complexity.

📝 补充说明

  • Using object pool pattern for L-systems - capped at 12 maximum to maintain performance while allowing dynamic spawning on click
  • Pixel-level interference computed at step 4 for performance, creating organic interference texture without full pixel processing overhead
  • SCREEN and ADD blend modes essential for creating luminous bismuth crystal glow that cannot be achieved with single-layer alpha blending
  • palette manipulation on 'C' key press shifts colors within constraints to maintain bismuth aesthetic while providing variability
  • Recreated offscreen buffers on resize to match new canvas dimensions and prevent scaling artifacts