Multiple questions >
-
How to make glowy ellipses using javaFX bloom?
-
How to make ellipse motion effect that it fades in to the ellipse?
Thank you
EDIT :
- And how to import javafx bloom library?
Multiple questions >
How to make glowy ellipses using javaFX bloom?
How to make ellipse motion effect that it fades in to the ellipse?
Thank you
EDIT :
surface = (PSurfaceFX) getSurface();
canvas = (Canvas) surface.getNative();
canvas.setEffect(new Bloom());
fill(255, 100);
rect(0, 0, width, height);
import javafx.scene.effect.Bloom;
Example: This Processing project with bloom effect added.
Getting many errors like âPSurface doesnât existâ
You might have to import that too:
import processing.core.PSurface;
import javafx.scene.Scene;
import javafx.scene.canvas.Canvas;
Still getting > âThe class âPSurfaceFXâ doesnât existâ, âThe variable âcanvasâ doesnât existâ and âThe name âcanvasâ cannot be recognizedâ.
Fix?
Also this is my full code >
import processing.core.PSurface;
import javafx.scene.Scene;
import javafx.scene.canvas.Canvas;
import javafx.scene.effect.Bloom;
fill(255, 100);
rect(0, 0, width, height);
surface = (PSurfaceFX) getSurface();
canvas = (Canvas) surface.getNative();
canvas.setEffect(new Bloom());
You have a setup()
and draw()
loop right? Or are you completely new to Processing?
Try using
import processing.javafx.PSurfaceFX;
Also, you have to declare
Canvas canvas = (Canvas) surface.getNative();
if itâs a new Variable.
Same for surface.
Still getting error > java.lang.reflect.InvocationTargetException
FULL CODE >
import processing.javafx.PSurfaceFX;
import processing.core.PSurface;
import javafx.scene.Scene;
import javafx.scene.canvas.Canvas;
import javafx.scene.effect.Bloom;
Canvas canvas = (Canvas) surface.getNative();
void setup() {
size(800, 600);
}
void draw() {
fill(255, 100);
rect(0, 0, width, height);
surface = (PSurfaceFX) getSurface();
canvas = (Canvas) surface.getNative();
canvas.setEffect(new Bloom());
}
You can get the cause by adding
try {
} catch (InvocationTargetException e) {
e.getCause().printStackTrace();
}
This way you can see where the problem lies specifically. Please do this and tell us what you got.
Also, you did declare the canvas variable, but never the surface variable in the Code you posted, which is likely the cause of the problem.
Getting error > The class InvokationTargetException doesnât exist.
Also how do I declare the surface?
You need to include
import java.lang.reflect.InvocationTargetException;
The import java.lang.reflect.InvokationTargetException cannot be resolved
You declare a variable like this
ClassName variableName; //or
ClassName variableName = new ClassName(); // or for primitives
ClassName variableName = ClassValue; // for Int itâs a number, for String a String like âHelloâ etc.
Edit : Itâs Invocation, not Invokation. (Autocorrect messed me up)
Error > Unreachable catch block for InvocationTargetException. This exception is never thrown from the try statement body
And I still donât understand, how should I decalre the canvas
Yeah, that just shows that itâs from outside the function. In this case itâs very likely from the not declared surface variable.
How do I declare it, like what should I use?
className varName;
className varName = new className();
or
className varName = classValue;
Also I have this in my code > Canvas canvas = (Canvas) surface.getNative();
import processing.javafx.PSurfaceFX;
import processing.core.PSurface;
import javafx.scene.Scene;
import javafx.scene.canvas.Canvas;
import javafx.scene.effect.Bloom;
PSurfaceFX surface;
Canvas canvas;
void setup() {
size(800, 600);
}
void draw() {
fill(255, 100);
rect(0, 0, width, height);
surface = (PSurfaceFX) getSurface();
canvas = (Canvas) surface.getNative();
canvas.setEffect(new Bloom());
}
Since you are going to set surface inside the Setup function, you can just declare it without a specific value. Same for canvas. And pay attention to the order in which variables are set. In this case, if canvas where to already be declared with a value outside the function, youâd end up refering to the surface variable before it has a value.
Error > ClassCastException: processing.awt.PSurfaceAWT cannot be cast to processing.javafx.PSurfaceFX