Hi all,
I’m trying to display noised “waves” on top of each other while avoiding any overlaps.
The waves are filled with point lines computed with the lerp()
function (interpolation between a noisy line and the next one below)
PROBLEM: Some of the waves are overlapping. More specifically, any noisy wave with a large amplitude will be overlapping the second wave coming after it.
So the common sense would be to state something like:
if p2.y < p0.y:
None # No point or strokeAlpha = 0
but then nothing changes, the overlaps are still visible:
Something must be off with the way I’m creating the if statement but not sure what it is.
def setup():
background(240)
size(800, 1000, P2D)
smooth(8)
n_points, edge = 20.0, 5
n_cols, n_rows = 200, 20
stepX, stepY = int(width/n_cols), int(height/n_rows)
t, factor, amplitude = 0, .01, 200
n = [[0 for y in range(n_rows)] for x in range(n_cols)]
for y in range(n_rows):
for x in range(n_cols):
t += factor
n[x][y] = amplitude * noise(t)
for y in range(n_rows-2):
rdmOffset = random(-1, 1)
stroke(random(50))
strokeWeight(random(1, 1.8))
for x in range(n_cols):
for e in range(int(n_points)):
p0 = PVector(x*stepX, y*stepY + n[x][y]) # Points on the first line
p1 = PVector(x*stepX + rdmOffset, (y+1)*stepY + n[x][y+1] - edge) # Points on the second line
p2 = PVector(x*stepX + rdmOffset, (y+2)*stepY + n[x][y+2] - edge) # Points on the third line
px = lerp(p0.x, p1.x, e/n_points)
py = lerp(p0.y, p1.y, e/n_points)
# If no overlapping -> Draw a point
if (p1.y) > (p0.y) and (p2.y) > (p0.y):
point(px, py)
###BUT I STILL GET OVERLAPS so stating again: ###
# If overlapping -> Make the points invisible
if (p2.y) < (p0.y):
stroke(100, 100, 255, 0)