Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lernen Working with Images and Pixels | Advanced Generative Techniques
Generative Art with JavaScript and P5.js

bookWorking with Images and Pixels

index.html

index.html

copy

When you want to use photographic or drawn images as a base for generative art, P5.js provides a powerful set of tools. The loadImage() function lets you load image files into your sketch, supporting formats such as JPG, PNG, and GIF. Once loaded, you can display the image on the canvas using the image() function, which draws your image at a specified location and size.

For deeper creative manipulation, P5.js gives you direct access to every pixel in the canvas through the pixel array. By calling loadPixels(), you can read and modify the RGBA values of each pixel. After making changes, use updatePixels() to apply your edits to the canvas. This workflow allows you to create custom filters and effects, such as inverting colors, adding noise, or generating mosaic patterns. By combining these tools, you can transform static images into dynamic, generative artworks that respond to algorithms or user interaction.

question mark

Which function is used to load an image file in P5.js?

Select the correct answer

War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 4. Kapitel 2

Fragen Sie AI

expand

Fragen Sie AI

ChatGPT

Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen

Suggested prompts:

How do I use `loadImage()` and `image()` in a P5.js sketch?

Can you show an example of manipulating pixels with `loadPixels()` and `updatePixels()`?

What are some creative effects I can apply to images using P5.js?

bookWorking with Images and Pixels

Swipe um das Menü anzuzeigen

index.html

index.html

copy

When you want to use photographic or drawn images as a base for generative art, P5.js provides a powerful set of tools. The loadImage() function lets you load image files into your sketch, supporting formats such as JPG, PNG, and GIF. Once loaded, you can display the image on the canvas using the image() function, which draws your image at a specified location and size.

For deeper creative manipulation, P5.js gives you direct access to every pixel in the canvas through the pixel array. By calling loadPixels(), you can read and modify the RGBA values of each pixel. After making changes, use updatePixels() to apply your edits to the canvas. This workflow allows you to create custom filters and effects, such as inverting colors, adding noise, or generating mosaic patterns. By combining these tools, you can transform static images into dynamic, generative artworks that respond to algorithms or user interaction.

question mark

Which function is used to load an image file in P5.js?

Select the correct answer

War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 4. Kapitel 2
some-alt