Created
January 22, 2025 20:28
-
-
Save BohemianHacks/1690ecef785e40dc20b356bfc2766fa2 to your computer and use it in GitHub Desktop.
flow
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
from matplotlib.collections import LineCollection | |
from matplotlib import colors | |
def create_flowing_art(size=1000, waves=15): | |
# Create figure with black background | |
plt.figure(figsize=(12, 12), facecolor='black') | |
ax = plt.gca() | |
ax.set_facecolor('black') | |
# Generate base coordinates | |
t = np.linspace(0, 2*np.pi, size) | |
x = np.linspace(-10, 10, size) | |
# Create multiple wave patterns | |
segments = [] | |
colors_list = [] | |
for i in range(waves): | |
phase = i * 2 * np.pi / waves | |
amplitude = 2 + np.sin(i * 0.3) | |
frequency = 1 + i * 0.1 | |
# Generate flowing wave pattern | |
y = amplitude * np.sin(frequency * x + phase) | |
y += 0.3 * np.sin(frequency * 3 * x + phase) | |
y += 0.2 * np.cos(frequency * 5 * x + phase) | |
# Create line segments | |
points = np.array([x, y]).T.reshape(-1, 1, 2) | |
segments.append(np.concatenate([points[:-1], points[1:]], axis=1)) | |
# Generate colors | |
hue = (i / waves + t[:len(segments[-1])] / (4 * np.pi)) % 1.0 | |
saturation = np.full_like(hue, 0.8) | |
value = np.full_like(hue, 0.9) | |
colors_list.extend(colors.hsv_to_rgb(np.dstack([hue, saturation, value]))[0]) | |
# Combine all segments | |
segments = np.concatenate(segments, axis=0) | |
# Create line collection with varying colors | |
lc = LineCollection(segments, colors=colors_list, linewidth=1.5, alpha=0.7) | |
ax.add_collection(lc) | |
# Add some stars in the background | |
stars = np.random.rand(200, 2) * 20 - 10 | |
plt.scatter(stars[:, 0], stars[:, 1], color='white', alpha=0.5, s=1) | |
# Set axis properties | |
ax.set_xlim(-10, 10) | |
ax.set_ylim(-8, 8) | |
ax.axis('off') | |
# Add a subtle glow effect | |
plt.style.use('dark_background') | |
return plt | |
# Create and show the art | |
art = create_flowing_art() | |
art.savefig('flowing_art.png', facecolor='black', bbox_inches='tight', dpi=300) | |
plt.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment