mirror of
https://github.com/processing/processing4.git
synced 2026-02-11 17:40:48 +01:00
new preproc work for int() et al on arrays.. routes through PApplet
This commit is contained in:
@@ -1534,9 +1534,13 @@ public class PApplet extends Applet
|
||||
* Wrapper for tedious Integer.parseInt function
|
||||
*/
|
||||
static public int toInt(String what) {
|
||||
return toInt(what, 0);
|
||||
try {
|
||||
return Integer.parseInt(what);
|
||||
} catch (NumberFormatException e) { }
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Wrapper for tedious Integer.parseInt function
|
||||
*/
|
||||
@@ -1562,6 +1566,7 @@ public class PApplet extends Applet
|
||||
return toInt(what, 0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Make an array of int elements from an array of String objects.
|
||||
* If the String can't be parsed as a number, its entry in the
|
||||
@@ -1585,6 +1590,26 @@ public class PApplet extends Applet
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Cast a float to an int.
|
||||
*/
|
||||
static public int toInt(float what) {
|
||||
return (int) what;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create an array of ints that correspond to an array of floats.
|
||||
*/
|
||||
static public int[] toInt(float what[]) {
|
||||
int inties[] = new int[what.length];
|
||||
for (int i = 0; i < what.length; i++) {
|
||||
inties[i] = (int)what[i];
|
||||
}
|
||||
return inties;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Wrapper for tedious new Float(string).floatValue().
|
||||
*/
|
||||
@@ -1607,6 +1632,27 @@ public class PApplet extends Applet
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Cast an int to a float.
|
||||
*/
|
||||
static public float toFloat(int what) {
|
||||
return (float)what;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create an array of ints that correspond to an array of floats.
|
||||
*/
|
||||
static public float[] toFloat(int what[]) {
|
||||
float floaties[] = new float[what.length];
|
||||
for (int i = 0; i < what.length; i++) {
|
||||
//floaties[i] = (float)what[i];
|
||||
floaties[i] = what[i];
|
||||
}
|
||||
return floaties;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert an array of Strings into an array of floats.
|
||||
* See the documentation for toInt().
|
||||
@@ -1615,6 +1661,7 @@ public class PApplet extends Applet
|
||||
return toFloat(what, 0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert an array of Strings into an array of floats.
|
||||
* See the documentation for toInt().
|
||||
|
||||
Reference in New Issue
Block a user