Is there any method to get the tablet pressure on windows & Linux using any library using the FX2D (javafx) renderer in processing?
Mabye using the commandline it would be possible to get the pressure of the pen?
Using an extra library?
The main processing app & another java app that could just cast the pressure to the processing app using a server?
If you have any idea, please!
You might ask “Why javafx, use P2D?!” Simple, because openGl has weird artifacts regarding image rendering & rectangle drawing.
I would be interested in knowing how you are using FX2D to create graphics. A minimal reproducible example demonstrating the problem would help the rest of us have some idea of what you are trying to accomplish.
I got pressure working in Kotlin by tapping into /dev/input/ on Linux. I can’t currently help porting this solution to Processing but maybe someone else could? Here’s my code:
That’s not what I’m talking about. The real problem as I see it is getting PenManager() to accept any parameter when FX2D is the renderer. It’s looking for an awt component and that’s just not available with JavaFX. Supposedly it does work with Swing components.
Addendum:
Hook your tablet up to this demo and see if it will measure pen pressure on the window (it does on my Mac). I’ll leave it to you to figure out how to draw on it. Note that PenManager() did accept a JPanel parameter.
ah. And one last questio, Is it possible to get the pressure in JavaFx using a processing window (papplet). For example:
//import necessary libarys and create objects
void setup() {
size(960,540,FX2D);
}
void draw() {
//code that would get the pen pressure, without creating a new Panel
//So i can draw objects like rectangles (rect) and also use the pressure
//without the need of another window!
}
With my current knowledge I think getting pen pressure hinges on the successful implementation of PenManager, ie
PenManager pm = new PenManager(awt component)
If you can come up with a parameter to put inside the parentheses that allows the creation of ‘pm’ without throwing an exception then you can do what you’re trying to do. I’ve worked on this for over 24 hr. and have yet to find anything that will work for the setup that you want to use (default Processing window for JavaFX, ignoring stage, scene and all of that). There are a finite number of elements to a PSurfaceFX window and so far I can’t find one that will yield a clean ‘pm’. I was able to get the canvas for the window but that is a java.lang.object and not an awt component so it failed. I never was able to get the frame for PSurfaceFX so I don’t know if that will work or not.
The other option is to give up on using the JPen-2 library (which is where PenManager is defined) and figure out some other way to get the pressure. I use a Wacom tablet and they do have driver code for Windows and Mac, but no Linux code that I can find. With a Mac you can draw on several objects without any extra code as long as you trap mouse events, but I’ve never worried about line thickness and never bothered with pen pressure.
do you know a way of transfering the pressure to a processing sketch
No, not for your favorite FX2D renderer. There is no way to do that with JPen that I’ve ever been able to find (and I spent a lot of time looking). Hamoid says you can get the pressure data from /dev/input/ on Linux, but I never tried it; couldn’t find anything similar on Mac. Have you seen the app Krita?