processing

Convert string to float occurs NaN error in Processing

别来无恙 提交于 2019-12-12 00:23:14
问题 I meet a problem in the Processing, and when i convert the value(string) into float, the first value is good, but the rests are all NaN . I could not find a way to solve this. And i print the string value for test. And it is correct, but after i convert it into float. It will be NaN . ps: the value is from the serial, i connected my Arduino with Proceesing. following is a part of codes while(myport.available() > 0) { myString = myport.readString(); //read the string from serial num = float

How would I use the imagemagick library with processing?

为君一笑 提交于 2019-12-11 21:57:09
问题 I want to use the imagemagick library (more specifically: the shepards distortion part of it) with processing.org. Does anyone know how to do that? Or if that is not possible, does anyone know of another library that can do this type of distortion? I've already found these related questions: one, two and three 回答1: Try to Look into the JMagick, it is a wrapper of ImageMagick. However if you wish an interface to the ImageMagick commandline im4java API should be useful. I didn't use im4java

Processing code doesn't work (Threads, draw(), noLoop(), and loop())

廉价感情. 提交于 2019-12-11 19:11:37
问题 The code below should make a shape flash twice, I triple checked the methods from root and I'm 99% sure it's that those methods are correct (I will post that code if needed though). What's the best way to make the current state of root pause on screen for a few seconds? noLoop(); root.setVal(newVal); root.highlight(0,255,0); root.setopacity(200); redraw(); try {Thread.sleep((long)1500);} catch (InterruptedException ex) {println("Error!");} root.setopacity(0); redraw(); try {Thread.sleep((long

Read the values of variables from a TXT file in Processing

大城市里の小女人 提交于 2019-12-11 18:13:18
问题 I have the following program in Proccessing and I try to find a way to read the values ​​of variables from a TXT file. static final int ribbon_length = 255, H = 200; void setup() { size(ribbon_length, H); //Διαστάσεις παλέτας } void draw() { float p = 1; int up_y = 10; int widthh = 1; int height = 180; float a = pow (ribbon_length, 1-p); float colour = 0; for (int step = 0; step <= 255; step++) { colour = a * pow (step, p); fill(colour,0,0); rect(widthh*step, up_y, widthh, height); noStroke()

Processing: Rotating a 3D object using Quaternions works for x-axis, but not for y or z axis?

不羁的心 提交于 2019-12-11 17:08:30
问题 I'm creating a Quaternion from input from a serial device. In Processing I rotate around the x-axis in the code below. My Quaternion object takes the input and uses the set function to set the values, euler angles, and normalize. Is there something wrong with the math? I commented out rotation for z and y, but basically the object doesn't rotate around very well or is jerky compared to the x-axis, which works perfectly. What am I doing wrong in the code below? For reference, the shape(model)

Class method not working properly in draw() in Processing

人盡茶涼 提交于 2019-12-11 16:58:22
问题 I'm writing some code in Processing, and basically what I'm trying to do is get a blue square to "light up" (change to a lighter shade), and then back again. I wrote a superclass and a subclass, with a method in the subclass that's intended to do this lighting up business. Here's the code: Superclass abstract class Squares { color darkBlue = color(0, 0, 204); color brightBlue = color(0, 0, 255); Squares(float x, float y) { _x = x; _y = y; } float _x; float _y; color _c; abstract void

OutOfBoundsException in Processing (Sound library)

大城市里の小女人 提交于 2019-12-11 15:36:18
问题 I recently started playing with Processing. I want to create a simple FFT visualizer that will import music file using Sound library. Here's my code and the console output. Console Output import processing.sound.*; SoundFile file; void setup() { size(); background(51); file = new SoundFile(this, "song.mp3"); file.play(); } void draw () { } Can someone explain why is this happening and how it can be fixed? By the way, sound file (song.mp3) is located in the same folder as the .pde file. 回答1:

Is there a way to check if one method draws over another method with Java Processing?

夙愿已清 提交于 2019-12-11 15:14:53
问题 I'm creating a rudimentary game and need to implement collision detection between the drawObstacle and drawRocketShip methods. I need to check if one method creates an image that overlaps another method. These aren't separated into different classes because of some randomization and position similarity checks I employ that have been omitted for the sake of brevity. I can elaborate further if required, but I thought that it wasn't necessarily needed to begin with. public class SideScrollGame

Processing on Java error on Mac OS

风流意气都作罢 提交于 2019-12-11 15:14:50
问题 I got this error message in the console when I tried to run, I just switched laptops and I've wiped my old one. This project has always been stored in a USB so I use that to run it on my new laptop. (So I had to re-download all the applications), I need this to fix so bad due to its my project for class and I haven't record it and I'm supposed to do that and I don't want to fail the class please could u help thank u: java.lang.NoClassDefFoundError: com/apple/eawt/QuitHandler at java.base/java

Modify a Global Variable with a Function?

大城市里の小女人 提交于 2019-12-11 14:21:35
问题 In mousePressed, I need the value of aNumber, but I can't pass mousePressed(int aNumber).. so I need some sort of global to remain modified when theNumbers is called via javascript.. int number = 0; int theNumbers(int aNumber) { //aNumber = 1, 2, or 3, from the javascript) println(number); // prints the correct number int number = aNumber; // set the global variable number equal to aNumber return number; } void mousePressed() { aLongNumber = 10000000000; println(number); // prints 0 right now