Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lära Interactivity in Creative Coding | Creative Coding and Generative Art
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Python for Creators and Makers

bookInteractivity in Creative Coding

Interactivity is a core concept in creative coding, allowing you to make your generative art respond to user actions or changes in parameters. This can be as simple as adjusting a slider to control the number of shapes, clicking a button to switch colors, or updating a variable to see a new version of your design. Interactivity brings your creations to life and invites experimentation, making the creative process more engaging and dynamic.

12345678910111213141516171819
import matplotlib.pyplot as plt import numpy as np # Simulate user input by changing the 'num_circles' variable num_circles = 10 # Try changing this value to 5, 15, or 20 theta = np.linspace(0, 2 * np.pi, 100) x = np.cos(theta) y = np.sin(theta) plt.figure(figsize=(6, 6)) for i in range(num_circles): angle = 2 * np.pi * i / num_circles plt.plot(x + np.cos(angle), y + np.sin(angle)) plt.axis('equal') plt.axis('off') plt.title(f"Pattern with {num_circles} Circles") plt.show()
copy

By changing the value of a variable, such as the number of circles in the pattern above, you can simulate interactivity even without direct user input. This approach lets you explore how different parameters influence the final artwork. Each adjustment can lead to unexpected and interesting results, encouraging you to experiment with new ideas and discover creative possibilities you might not have considered before.

123456789101112131415161718192021
import matplotlib.pyplot as plt import numpy as np circle_counts = [5, 10, 15, 20] fig, axes = plt.subplots(1, len(circle_counts), figsize=(4 * len(circle_counts), 4)) theta = np.linspace(0, 2 * np.pi, 100) x = np.cos(theta) y = np.sin(theta) for ax, num_circles in zip(axes, circle_counts): for i in range(num_circles): angle = 2 * np.pi * i / num_circles ax.plot(x + np.cos(angle), y + np.sin(angle)) ax.set_title(f"{num_circles} Circles") ax.axis('equal') ax.axis('off') plt.tight_layout() plt.show()
copy

1. What is interactivity in the context of creative coding?

2. How can changing a parameter affect generative art?

3. To create different versions of a pattern, you can loop over ________ values.

question mark

What is interactivity in the context of creative coding?

Select the correct answer

question mark

How can changing a parameter affect generative art?

Select the correct answer

question-icon

To create different versions of a pattern, you can loop over ________ values.

PrintFunctionFile

Click or drag`n`drop items and fill in the blanks

Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 3. Kapitel 4

Fråga AI

expand

Fråga AI

ChatGPT

Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal

bookInteractivity in Creative Coding

Svep för att visa menyn

Interactivity is a core concept in creative coding, allowing you to make your generative art respond to user actions or changes in parameters. This can be as simple as adjusting a slider to control the number of shapes, clicking a button to switch colors, or updating a variable to see a new version of your design. Interactivity brings your creations to life and invites experimentation, making the creative process more engaging and dynamic.

12345678910111213141516171819
import matplotlib.pyplot as plt import numpy as np # Simulate user input by changing the 'num_circles' variable num_circles = 10 # Try changing this value to 5, 15, or 20 theta = np.linspace(0, 2 * np.pi, 100) x = np.cos(theta) y = np.sin(theta) plt.figure(figsize=(6, 6)) for i in range(num_circles): angle = 2 * np.pi * i / num_circles plt.plot(x + np.cos(angle), y + np.sin(angle)) plt.axis('equal') plt.axis('off') plt.title(f"Pattern with {num_circles} Circles") plt.show()
copy

By changing the value of a variable, such as the number of circles in the pattern above, you can simulate interactivity even without direct user input. This approach lets you explore how different parameters influence the final artwork. Each adjustment can lead to unexpected and interesting results, encouraging you to experiment with new ideas and discover creative possibilities you might not have considered before.

123456789101112131415161718192021
import matplotlib.pyplot as plt import numpy as np circle_counts = [5, 10, 15, 20] fig, axes = plt.subplots(1, len(circle_counts), figsize=(4 * len(circle_counts), 4)) theta = np.linspace(0, 2 * np.pi, 100) x = np.cos(theta) y = np.sin(theta) for ax, num_circles in zip(axes, circle_counts): for i in range(num_circles): angle = 2 * np.pi * i / num_circles ax.plot(x + np.cos(angle), y + np.sin(angle)) ax.set_title(f"{num_circles} Circles") ax.axis('equal') ax.axis('off') plt.tight_layout() plt.show()
copy

1. What is interactivity in the context of creative coding?

2. How can changing a parameter affect generative art?

3. To create different versions of a pattern, you can loop over ________ values.

question mark

What is interactivity in the context of creative coding?

Select the correct answer

question mark

How can changing a parameter affect generative art?

Select the correct answer

question-icon

To create different versions of a pattern, you can loop over ________ values.

PrintFunctionFile

Click or drag`n`drop items and fill in the blanks

Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 3. Kapitel 4
some-alt