mirror of
https://github.com/processing/processing4.git
synced 2026-02-13 18:35:37 +01:00
Merge branch 'master' of https://github.com/processing/processing.git
This commit is contained in:
@@ -78,7 +78,7 @@ public abstract class EditorToolbar extends JComponent implements MouseInputList
|
||||
|
||||
protected ArrayList<Button> buttons;
|
||||
|
||||
static final int ARROW_WIDTH = 6;
|
||||
static final int ARROW_WIDTH = 7;
|
||||
static final int ARROW_HEIGHT = 6;
|
||||
static Image modeArrow;
|
||||
|
||||
|
||||
@@ -391,12 +391,12 @@ public class JSONArray {
|
||||
/**
|
||||
* Get the JSONArray associated with an index.
|
||||
*
|
||||
* @param index The index must be between 0 and length() - 1.
|
||||
* @return A JSONArray value.
|
||||
* @webref jsonobject:method
|
||||
* @brief Gets the JSONArray associated with an index value
|
||||
* @param index must be between 0 and length() - 1.
|
||||
* @return A JSONArray value.
|
||||
* @throws JSONException If there is no value for the index. or if the
|
||||
* value is not a JSONArray
|
||||
* @webref jsonarray:method
|
||||
* @brief Get the JSONArray associated with an index
|
||||
*/
|
||||
public JSONArray getJSONArray(int index) {
|
||||
Object object = this.get(index);
|
||||
@@ -410,12 +410,12 @@ public class JSONArray {
|
||||
/**
|
||||
* Get the JSONObject associated with an index.
|
||||
*
|
||||
* @param index subscript
|
||||
* @return A JSONObject value.
|
||||
* @webref jsonobject:method
|
||||
* @brief Gets the JSONObject associated with an index value
|
||||
* @param index the index value of the object to get
|
||||
* @return A JSONObject value.
|
||||
* @throws JSONException If there is no value for the index or if the
|
||||
* value is not a JSONObject
|
||||
* @webref jsonarray:method
|
||||
* @brief Get the JSONObject associated with an index
|
||||
*/
|
||||
public JSONObject getJSONObject(int index) {
|
||||
Object object = this.get(index);
|
||||
@@ -928,7 +928,9 @@ public class JSONArray {
|
||||
|
||||
/**
|
||||
* @webref jsonarray:method
|
||||
* @brief To come...
|
||||
* @brief Sets the JSONArray value associated with an index value
|
||||
* @param index the index value to target
|
||||
* @param value the value to assign
|
||||
*/
|
||||
public JSONArray setJSONArray(int index, JSONArray value) {
|
||||
set(index, value);
|
||||
@@ -937,7 +939,9 @@ public class JSONArray {
|
||||
|
||||
/**
|
||||
* @webref jsonarray:method
|
||||
* @brief To come...
|
||||
* @brief Sets the JSONObject value associated with an index value
|
||||
* @param index the index value to target
|
||||
* @param value the value to assign
|
||||
*/
|
||||
public JSONArray setJSONObject(int index, JSONObject value) {
|
||||
set(index, value);
|
||||
@@ -978,7 +982,7 @@ public class JSONArray {
|
||||
* Get the number of elements in the JSONArray, included nulls.
|
||||
*
|
||||
* @webref jsonarray:method
|
||||
* @brief Gets the number of elements in the JSONArray, included nulls
|
||||
* @brief Gets the number of elements in the JSONArray
|
||||
* @return The length (or size).
|
||||
*/
|
||||
public int size() {
|
||||
@@ -1001,8 +1005,8 @@ public class JSONArray {
|
||||
* Remove an index and close the hole.
|
||||
*
|
||||
* @webref jsonarray:method
|
||||
* @brief Remove an index and close the hole
|
||||
* @param index The index of the element to be removed.
|
||||
* @brief Removes an element
|
||||
* @param index the index value of the element to be removed
|
||||
* @return The value that was associated with the index, or null if there was no value.
|
||||
*/
|
||||
public Object remove(int index) {
|
||||
|
||||
@@ -555,11 +555,11 @@ public class JSONObject {
|
||||
/**
|
||||
* Gets the String associated with a key
|
||||
*
|
||||
* @param key A key string.
|
||||
* @return A string which is the value.
|
||||
* @throws JSONException if there is no string value for the key.
|
||||
* @webref jsonobject:method
|
||||
* @brief Gets the string associated with a key
|
||||
* @param key a key string
|
||||
* @return A string which is the value.
|
||||
* @throws JSONException if there is no string value for the key.
|
||||
*/
|
||||
public String getString(String key) {
|
||||
Object object = this.get(key);
|
||||
@@ -573,12 +573,12 @@ public class JSONObject {
|
||||
/**
|
||||
* Gets the int value associated with a key
|
||||
*
|
||||
* @param key A key string.
|
||||
* @return The integer value.
|
||||
* @throws JSONException if the key is not found or if the value cannot
|
||||
* be converted to an integer.
|
||||
* @webref jsonobject:method
|
||||
* @brief Gets the int value associated with a key
|
||||
* @param key a key string
|
||||
* @return The integer value.
|
||||
* @throws JSONException if the key is not found or if the value cannot
|
||||
* be converted to an integer.
|
||||
*/
|
||||
public int getInt(String key) {
|
||||
Object object = this.get(key);
|
||||
@@ -613,7 +613,8 @@ public class JSONObject {
|
||||
|
||||
/**
|
||||
* @webref jsonobject:method
|
||||
* @brief To come...
|
||||
* @brief Gets the float value associated with a key
|
||||
* @param key a key string
|
||||
*/
|
||||
public float getFloat(String key) {
|
||||
return (float) getDouble(key);
|
||||
@@ -642,11 +643,11 @@ public class JSONObject {
|
||||
/**
|
||||
* Get the boolean value associated with a key.
|
||||
*
|
||||
* @param key A key string.
|
||||
* @return The truth.
|
||||
* @throws JSONException if the value is not a Boolean or the String "true" or "false".
|
||||
* @webref jsonobject:method
|
||||
* @brief Gets the boolean value associated with a key
|
||||
* @param key a key string
|
||||
* @return The truth.
|
||||
* @throws JSONException if the value is not a Boolean or the String "true" or "false".
|
||||
*/
|
||||
public boolean getBoolean(String key) {
|
||||
Object object = this.get(key);
|
||||
@@ -666,11 +667,11 @@ public class JSONObject {
|
||||
/**
|
||||
* Get the JSONArray value associated with a key.
|
||||
*
|
||||
* @brief Gets the JSONArray value associated with a key
|
||||
* @webref jsonobject:method
|
||||
* @param key A key string
|
||||
* @return A JSONArray which is the value.
|
||||
* @throws JSONException if the key is not found or if the value is not a JSONArray.
|
||||
* @brief Gets the JSONArray value associated with a key
|
||||
* @param key a key string
|
||||
* @return A JSONArray which is the value.
|
||||
* @throws JSONException if the key is not found or if the value is not a JSONArray.
|
||||
*/
|
||||
public JSONArray getJSONArray(String key) {
|
||||
Object object = this.get(key);
|
||||
@@ -684,11 +685,11 @@ public class JSONObject {
|
||||
/**
|
||||
* Get the JSONObject value associated with a key.
|
||||
*
|
||||
* @param key A key string.
|
||||
* @return A JSONObject which is the value.
|
||||
* @throws JSONException if the key is not found or if the value is not a JSONObject.
|
||||
* @webref jsonobject:method
|
||||
* @brief Gets the JSONObject value associated with a key
|
||||
* @param key a key string
|
||||
* @return A JSONObject which is the value.
|
||||
* @throws JSONException if the key is not found or if the value is not a JSONObject.
|
||||
*/
|
||||
public JSONObject getJSONObject(String key) {
|
||||
Object object = this.get(key);
|
||||
@@ -1113,7 +1114,9 @@ public class JSONObject {
|
||||
|
||||
/**
|
||||
* @webref jsonobject:method
|
||||
* @brief To come...
|
||||
* @brief Put a key/String pair in the JSONObject
|
||||
* @param key a key string
|
||||
* @param value the value to assign
|
||||
*/
|
||||
public JSONObject setString(String key, String value) {
|
||||
return put(key, value);
|
||||
@@ -1123,12 +1126,12 @@ public class JSONObject {
|
||||
/**
|
||||
* Put a key/int pair in the JSONObject.
|
||||
*
|
||||
* @param key A key string.
|
||||
* @param value An int which is the value.
|
||||
* @return this.
|
||||
* @throws JSONException If the key is null.
|
||||
* @webref jsonobject:method
|
||||
* @brief Put a key/int pair in the JSONObject
|
||||
* @param key a key string
|
||||
* @param value the value to assign
|
||||
* @return this.
|
||||
* @throws JSONException If the key is null.
|
||||
*/
|
||||
public JSONObject setInt(String key, int value) {
|
||||
this.put(key, new Integer(value));
|
||||
@@ -1151,7 +1154,9 @@ public class JSONObject {
|
||||
|
||||
/**
|
||||
* @webref jsonobject:method
|
||||
* @brief To come...
|
||||
* @brief Put a key/float pair in the JSONObject
|
||||
* @param key a key string
|
||||
* @param value the value to assign
|
||||
*/
|
||||
public JSONObject setFloat(String key, float value) {
|
||||
this.put(key, new Double(value));
|
||||
@@ -1176,12 +1181,12 @@ public class JSONObject {
|
||||
/**
|
||||
* Put a key/boolean pair in the JSONObject.
|
||||
*
|
||||
* @param key A key string.
|
||||
* @param value A boolean which is the value.
|
||||
* @return this.
|
||||
* @throws JSONException If the key is null.
|
||||
* @webref jsonobject:method
|
||||
* @brief Put a key/boolean pair in the JSONObject
|
||||
* @param key a key string
|
||||
* @param value the value to assign
|
||||
* @return this.
|
||||
* @throws JSONException If the key is null.
|
||||
*/
|
||||
public JSONObject setBoolean(String key, boolean value) {
|
||||
this.put(key, value ? Boolean.TRUE : Boolean.FALSE);
|
||||
@@ -1190,7 +1195,9 @@ public class JSONObject {
|
||||
|
||||
/**
|
||||
* @webref jsonobject:method
|
||||
* @brief To come...
|
||||
* @brief Sets the JSONObject value associated with a key
|
||||
* @param key a key string
|
||||
* @param value value to assign
|
||||
*/
|
||||
public JSONObject setJSONObject(String key, JSONObject value) {
|
||||
return put(key, value);
|
||||
@@ -1198,7 +1205,9 @@ public class JSONObject {
|
||||
|
||||
/**
|
||||
* @webref jsonobject:method
|
||||
* @brief To come...
|
||||
* @brief Sets the JSONArray value associated with a key
|
||||
* @param key a key string
|
||||
* @param value value to assign
|
||||
*/
|
||||
public JSONObject setJSONArray(String key, JSONArray value) {
|
||||
return put(key, value);
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
|
||||
IntList lottery;
|
||||
IntList results;
|
||||
IntList ticket;
|
||||
|
||||
void setup() {
|
||||
size(640, 360);
|
||||
frameRate(30);
|
||||
lottery = new IntList();
|
||||
results = new IntList();
|
||||
ticket = new IntList();
|
||||
// Let's add some numbers to our list
|
||||
for (int i = 0; i < 20; i++) {
|
||||
lottery.append(i);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
int index = int(random(lottery.size()));
|
||||
ticket.append(lottery.get(index));
|
||||
}
|
||||
}
|
||||
|
||||
void draw() {
|
||||
background(51);
|
||||
|
||||
lottery.shuffle();
|
||||
|
||||
showList(lottery, 16, 48);
|
||||
showList(results, 16, 100);
|
||||
showList(ticket, 16, 140);
|
||||
|
||||
for (int i = 0; i < results.size(); i++) {
|
||||
if (results.get(i) == ticket.get(i)) {
|
||||
fill(0, 255, 0, 100);
|
||||
}
|
||||
else {
|
||||
fill(255, 0, 0, 100);
|
||||
}
|
||||
ellipse(16+i*32, 140, 24, 24);
|
||||
}
|
||||
|
||||
if (frameCount % 30 == 0) {
|
||||
// Pick a new lottery number!
|
||||
if (results.size() < 5) {
|
||||
int val = lottery.get(0);
|
||||
lottery.remove(0);
|
||||
results.append(val);
|
||||
} else {
|
||||
// Ok we picked five numbers, let's reset
|
||||
for (int i = 0; i < results.size(); i++) {
|
||||
lottery.append(results.get(i));
|
||||
}
|
||||
results.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void showList(IntList list, float x, float y) {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
int val = list.get(i);
|
||||
stroke(255);
|
||||
noFill();
|
||||
ellipse(x+i*32, y, 24, 24);
|
||||
textAlign(CENTER);
|
||||
fill(255);
|
||||
text(val, x+i*32, y+6);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -563,8 +563,8 @@ getString FUNCTION2 JSONObject_getString_
|
||||
setBoolean FUNCTION2 JSONObject_setBoolean_
|
||||
setFloat FUNCTION2 JSONObject_setFloat_
|
||||
setInt FUNCTION2 JSONObject_setInt_
|
||||
getJSONArray FUNCTION2 JSONObject_setJSONArray_
|
||||
getJSONObject FUNCTION2 JSONObject_setJSONObject_
|
||||
setJSONArray FUNCTION2 JSONObject_setJSONArray_
|
||||
setJSONObject FUNCTION2 JSONObject_setJSONObject_
|
||||
setString FUNCTION2 JSONObject_setString_
|
||||
key KEYWORD4 key
|
||||
keyCode KEYWORD4 keyCode
|
||||
@@ -610,6 +610,7 @@ mouseMoved FUNCTION4 mouseMoved
|
||||
mousePressed FUNCTION4 mousePressed
|
||||
mousePressed KEYWORD4 mousePressed
|
||||
mouseReleased FUNCTION1 mouseReleased_
|
||||
mouseWheel FUNCTION4 mouseWheel
|
||||
mouseX KEYWORD4 mouseX
|
||||
mouseY KEYWORD4 mouseY
|
||||
nf FUNCTION1 nf_
|
||||
@@ -674,6 +675,7 @@ enableStyle FUNCTION2 PShape_enableStyle_
|
||||
endContour FUNCTION2 PShape_endContour_
|
||||
endShape FUNCTION2 PShape_endShape_
|
||||
getChild FUNCTION2 PShape_getChild_
|
||||
getChildCount FUNCTION2 PShape_getChildCount_
|
||||
getVertex FUNCTION2 PShape_getVertex_
|
||||
getVertexCount FUNCTION2 PShape_getVertexCount_
|
||||
isVisible FUNCTION2 PShape_isVisible_
|
||||
@@ -695,6 +697,7 @@ array FUNCTION2 PVector_array_
|
||||
copy FUNCTION2 PVector_copy_
|
||||
cross FUNCTION2 PVector_cross_
|
||||
dist FUNCTION2 PVector_dist_
|
||||
div FUNCTION2 PVector_div_
|
||||
dot FUNCTION2 PVector_dot_
|
||||
fromAngle FUNCTION2 PVector_fromAngle_
|
||||
get FUNCTION2 PVector_get_
|
||||
@@ -703,6 +706,7 @@ lerp FUNCTION2 PVector_lerp_
|
||||
limit FUNCTION2 PVector_limit_
|
||||
mag FUNCTION2 PVector_mag_
|
||||
magSq FUNCTION2 PVector_magSq_
|
||||
mult FUNCTION2 PVector_mult_
|
||||
normalize FUNCTION2 PVector_normalize_
|
||||
random2D FUNCTION2 PVector_random2D_
|
||||
random3D FUNCTION2 PVector_random3D_
|
||||
@@ -812,8 +816,11 @@ clearRows FUNCTION2 Table_clearRows_
|
||||
findRow FUNCTION2 Table_findRow_
|
||||
findRows FUNCTION2 Table_findRows_
|
||||
getColumnCount FUNCTION2 Table_getColumnCount_
|
||||
getFloat FUNCTION2 Table_getFloat_
|
||||
getInt FUNCTION2 Table_getInt_
|
||||
getRow FUNCTION2 Table_getRow_
|
||||
getRowCount FUNCTION2 Table_getRowCount_
|
||||
getString FUNCTION2 Table_getString_
|
||||
getStringColumn FUNCTION2 Table_getStringColumn_
|
||||
matchRow FUNCTION2 Table_matchRow_
|
||||
matchRows FUNCTION2 Table_matchRows_
|
||||
@@ -821,6 +828,9 @@ removeColumn FUNCTION2 Table_removeColumn_
|
||||
removeRow FUNCTION2 Table_removeRow_
|
||||
removeTokens FUNCTION2 Table_removeTokens_
|
||||
rows FUNCTION2 Table_rows_
|
||||
setFloat FUNCTION2 Table_setFloat_
|
||||
setInt FUNCTION2 Table_setInt_
|
||||
setString FUNCTION2 Table_setString_
|
||||
trim FUNCTION2 Table_trim_
|
||||
TableRow KEYWORD5 TableRow
|
||||
getFloat FUNCTION2 TableRow_getFloat_
|
||||
@@ -860,7 +870,9 @@ getChild FUNCTION2 XML_getChild_
|
||||
getChildren FUNCTION2 XML_getChildren_
|
||||
getContent FUNCTION2 XML_getContent_
|
||||
getFloat FUNCTION2 XML_getFloat_
|
||||
getContent FUNCTION2 XML_getFloatContent_
|
||||
getInt FUNCTION2 XML_getInt_
|
||||
getContent FUNCTION2 XML_getIntContent_
|
||||
getName FUNCTION2 XML_getName_
|
||||
getParent FUNCTION2 XML_getParent_
|
||||
getString FUNCTION2 XML_getString_
|
||||
|
||||
Reference in New Issue
Block a user