line burst

/** * Draw lines over time in a neat pattern. * Derived from http://processingjs.org/learning/basic/random */ /** * This JS figures out the height/width we want to use for the sketch * <script> * var divWidth = $("#header").width(); * var divHeight = 200; * var doDraw = true; *</script> **/ int i = 0; float targetX, targetY; int shiftDelay = 2500; int lastReset = 0; void setup() { size(divWidth, divHeight); background(0); strokeWeight(10); targetX = random(divWidth * 0.2, divWidth - divWidth * 0.2); targetY = random(divHeight * 0.2, divHeight - divHeight * 0.2); frameRate(20); } void draw() { if ( ! doDraw ) { noLoop(); return; } noStroke(); fill(0, 0, 0, 2); rect(0, 0, width, height); float r = random(255); lastReset += frameRate; if ( lastReset + shiftDelay < frameCount ) { targetX += random(5) - 10; targetY += random(5) - 10; if ( targetX < 0 ) { targetX = 0; } if ( targetX > width ) { targetX = width; } if ( targetY > height ) { targetY = height; } lastReset = frameCount; } if ( random(0, 100) > 92 ) { stroke(r, 0, 0, 40 + random(60)); } else { stroke(r, 20 + random(80)); } float foo = random(0, 1); float startX = 0; float startY = 0; float wiggle = random(10) - 20; if ( foo < 0.25 ) { startX = random(0, width); } else if ( foo < 0.5 ) { startX = random(0, width); startY = height; } else if ( foo < 0.75 ) { startY = random(0, height); } else { startY = random(0, height); startX = width; } line(startX, startY, targetX + wiggle, targetY + wiggle); }

Tags: 

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote> <pre>
  • Lines and paragraphs break automatically.
  • Syntax highlight code surrounded by the {syntaxhighlighter SPEC}...{/syntaxhighlighter} tags, where SPEC is a Syntaxhighlighter options string or class="OPTIONS" [title="the title"].

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.