Coded Echoes of Nature: Exploring Nature and Code with p5js and ChatGPT

Danne Woo
4 min readJun 1, 2023

--

Greetings, fellow technophiles and nature lovers! I’m currently amidst an extraordinary journey at the Catwalk Art Residency, tucked away in the lush heart of Catskill, NY. This scenic sanctuary has fostered a unique artistic experiment, an intriguing blend of nature’s wonders and the potential of AI-powered code generation. As I immerse myself in the surrounding flora and fauna, the tool of choice, OpenAI’s ChatGPT, is right by my side, helping to breathe life into four distinct p5js scripts, each a tribute to the captivating charm of Catskill.

The Snow of May: Cottonwood Tree Seeds in Flight

My journey into code generation started with a captivating scene — cottonwood tree seeds floating in the air, creating an illusion of May snowfall. I wanted to encapsulate this ethereal experience within a p5js script, but how do you programmatically replicate nature’s randomness? That’s where ChatGPT stepped in.

Through multiple interactions with the AI, I developed a script that visually emulated the cottonwood seeds. The finished piece features dynamic seed movements with an added element: the background color transition from sky blue to dark blue, reflecting the change from day to night in real time based on the viewers location.

Original Prompt: Can you generate code for p5js to replicate cottonwood tree seeds floating in the air?

View code and run script: https://editor.p5js.org/dannewoo/sketches/cCnrJBRb5

The Dance of the River Dwellers: A School of Fish in p5js

The next script was inspired by my time fly fishing on the Catskill Creek. Watching the hundreds of small fish gracefully swimming in unison among thousands of tadpoles, I was compelled to translate this aquatic ballet into code.

With ChatGPT’s help, we sculpted a generative system that mirrors the fish’s behavior. It even includes an interactive element; a click on the screen makes the fish scatter, mimicking their natural reaction when disturbed. The AI’s ability to consider such interactive elements was impressive, providing a more dynamic and engaging piece.

Original Prompt: Can you write me code for p5js that replicates a school of fish swimming in a river?

View code and run script: https://editor.p5js.org/dannewoo/sketches/FNCe1cSL3

Water’s Silent Echo: Ripples and Water Bugs

Our third undertaking was inspired by the intricate ripples caused by water bugs dancing on the river’s surface and trout darting to the surface for a quick meal. This captivating interplay of motion served as the inspiration for another p5js script.

With each successive engagement, ChatGPT demonstrated an impressive ability to grasp the essence of the concept and help shape it into functional code. It required minimal adjustment on my part, mostly limited to stylistic alterations like color choice and stroke.

Original Prompt: Can you write some code for p5js that replicates water flowing in a river?

View code and run script: https://editor.p5js.org/dannewoo/sketches/rw2XHcqHG

The Silent Sentinels: A Generative Tree

The final piece of this riveting project drew its muse from the plethora of Oak, Maple, Pine, and other majestic trees populating the Catskill countryside. My initial vision was to make the generative tree sway gently in a light breeze, capturing the essence of tranquility. We harnessed ChatGPT to breathe life into this concept, but the resulting code wasn’t quite what I’d envisioned. After some contemplation, I decided to keep the tree static, focusing more on capturing its innate beauty and variance. Despite the change in plans, the collaboration with ChatGPT was still enlightening, serving as a reminder that art — digital or otherwise — often evolves in the process of creation.

Original Prompt: Can you write some code for p5js that replicates a tree swaying in the wind?

View code and run script: https://editor.p5js.org/dannewoo/sketches/Appq1Bukc

In retrospect, this project was a testament to the changing landscape of programming and creative coding. The task of writing code, once solely human, is rapidly evolving as AI tools like ChatGPT become more common in the workspace. While my role in this project was undoubtedly essential, the AI served as a collaborative partner, transforming abstract ideas into workable code structures.

ChatGPT has its limitations, as revisions were needed occasionally, and personal adjustments were made to the style and variable values. Nevertheless, its contribution was substantial, streamlining the creation process and offering creative solutions that would traditionally take hours or days. It served as a fascinating reminder of the potential symbiosis between AI and human creativity, a collaboration that I believe will only deepen with time.

--

--

Danne Woo
Danne Woo

Written by Danne Woo

Founder of @datavisualinfo, Professor at @QC_news, @meddemfund/@fordfoundation Fellow at @colorofchange and @itp_nyu alum. #datadork #designer #programmer

No responses yet