|
|
@ -16,6 +16,7 @@ def main():
|
|
|
|
ctx.scale(WIDTH, HEIGHT) # Normalizing the canvas
|
|
|
|
ctx.scale(WIDTH, HEIGHT) # Normalizing the canvas
|
|
|
|
|
|
|
|
|
|
|
|
wave_height = 1/WAVES
|
|
|
|
wave_height = 1/WAVES
|
|
|
|
|
|
|
|
lastpoints = [(x/1000, 0) for x in range(1000)]
|
|
|
|
|
|
|
|
|
|
|
|
for num in range(WAVES):
|
|
|
|
for num in range(WAVES):
|
|
|
|
r, g, b = random_color()
|
|
|
|
r, g, b = random_color()
|
|
|
@ -25,13 +26,20 @@ def main():
|
|
|
|
y = math.sin(x*50) * 0.1
|
|
|
|
y = math.sin(x*50) * 0.1
|
|
|
|
points.append((x, ( (y/4) + ((0.5+num)*wave_height))))
|
|
|
|
points.append((x, ( (y/4) + ((0.5+num)*wave_height))))
|
|
|
|
x += 0.001
|
|
|
|
x += 0.001
|
|
|
|
print(points)
|
|
|
|
# draw waves
|
|
|
|
ctx.move_to(*points[0])
|
|
|
|
ctx.move_to(*points[0])
|
|
|
|
for p in points[1:]:
|
|
|
|
for p in points[1:]:
|
|
|
|
ctx.line_to(*p)
|
|
|
|
ctx.line_to(*p)
|
|
|
|
ctx.set_line_width(0.002)
|
|
|
|
ctx.set_line_width(0.002)
|
|
|
|
ctx.set_source_rgb(r, g, b)
|
|
|
|
ctx.set_source_rgb(r, g, b)
|
|
|
|
ctx.stroke()
|
|
|
|
ctx.stroke()
|
|
|
|
|
|
|
|
# fill area above
|
|
|
|
|
|
|
|
for pos in range(len(points)):
|
|
|
|
|
|
|
|
ctx.move_to(*points[pos])
|
|
|
|
|
|
|
|
ctx.line_to(*lastpoints[pos])
|
|
|
|
|
|
|
|
ctx.stroke()
|
|
|
|
|
|
|
|
lastpoints = points
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
surface.write_to_png("out/waves.png") # Output to PNG
|
|
|
|
surface.write_to_png("out/waves.png") # Output to PNG
|
|
|
|
|
|
|
|
|
|
|
|