Prompt to do Processing to P5js with Gemini
Seen with Gemini!
(this version isn’t tested yet but it should work. I did the same thing with a very long prompt and it worked fine ! October 23, 2025 )
Precede the Processing code with the following text to obtain the correct translation in P5js (I prepare my complete prompt in a simple text file before I copy/paste into Gemini)
N.B. The free basic AI offered by Google is widely sufficient
Respond only and immediately to the question asked. DO NOT use introductory, justifying, validating, concluding, or contextual phrases or remarks. DO NOT suggest any unrequested adjustment or elaboration. Translate the following Processing code into P5.js: P5.js syntax, classes, functions, and variables strictly unchanged. Ignore interfaces (implements XXXXX). Add // implements XXXXX after the class declaration. Java variables in the JS constructor must use let and be initialized to null if uninitialized in Java. New variable declarations must be preceded by let. Preserve comments. Use strict mode. For file uploads, precede them with their path, namely: data/
I specify that :
-
I still only use one constructor in the Java part in every class
In case of need for several constructors, I write a (only) minimal constructor and use the Design Pattern Decorator.
See in my PstarEngine code, just after the constructor in every class the methods returning the current class with return this; at the end (if needed) -
The PstarEnginejava tab corresponds to the PstarEngineJS tab: it is the Procesing-P5js compatibility code that I write myself (it is not submitted to Gemini).
-
The declaration of interfaces are all in the PstarEngineJava part. There are systematically comments to signal their presence in the Java code, which are therefore found in the Javascript section.
-
If there are several tabs to translate, I put them all in a single text file with additional comments to find my way around.
After, I restore the tabs in the Javascript part (attention to the order in which they are declared in the html part… to be modified if necessary) without forgetting to add also the tab containing the compatibility code Processing-P5js that I maintain manually.