Skip to content

Instantly share code, notes, and snippets.

@quxiaowei
Created December 21, 2016 15:45
Show Gist options
  • Save quxiaowei/0f8764b1c31dca934c8e91394fe0b0dd to your computer and use it in GitHub Desktop.
Save quxiaowei/0f8764b1c31dca934c8e91394fe0b0dd to your computer and use it in GitHub Desktop.
processing.js
width, height = 600, 600
w, h = 300, 600
lines, cols = 40, 20
xspace, yspace = 5, 10
moving = 0.0
bg_color = color(50, 55, 100)
fg_color = color(255)
def setup():
global cols
size(600, 600, P3D)
cols = w / xspace
def get_molder(base, scale, width):
global w
if width < TWO_PI:
width = TWO_PI
def a (i):
j = map(i, 0, w, 0, width)
if j < width-(width-TWO_PI)/2 and j > (width-TWO_PI)/2:
return scale*(base+1-cos(j-(width-TWO_PI)/2))
else:
return scale*base
return a
def draw():
global moving
background(bg_color)
translate(width/2, height/2)
translate(-w/2, -h/2)
start = (height - (lines - 1) * yspace) / 2
molder = get_molder(0.2, 1, 4*PI)
moving = moving + 0.01
yoff = moving
stroke(bg_color)
fill(bg_color)
for y in range(lines):
z = y / 1
xoff = 0.0
beginShape()
curveVertex(0, start+y*yspace, z)
curveVertex(0, start+y*yspace, z)
for x in range(1, cols-1):
yDelta = map(noise(xoff, yoff), 0, 1, 0, 20)
curveVertex(x*xspace, start+y*yspace-molder(x*xspace)*yDelta, z)
xoff += 0.5
stroke(fg_color)
stroke(bg_color)
curveVertex(w, start+y*yspace, z)
curveVertex(w, start+y*yspace, z)
endShape(CLOSE)
yoff += 0.8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment