From 12fdf47428d0be9feddb08336af440aea20d0b6b Mon Sep 17 00:00:00 2001 From: benfry Date: Fri, 23 Mar 2012 21:42:26 +0000 Subject: [PATCH] f*king delay() is back again --- core/src/processing/core/PApplet.java | 67 +++++++++++++++++---------- core/todo.txt | 15 ++++-- 2 files changed, 54 insertions(+), 28 deletions(-) diff --git a/core/src/processing/core/PApplet.java b/core/src/processing/core/PApplet.java index 6b7b16796..8c06f42da 100644 --- a/core/src/processing/core/PApplet.java +++ b/core/src/processing/core/PApplet.java @@ -1230,8 +1230,8 @@ public class PApplet extends Applet * redraw() causes the code inside draw() to execute once and * loop() will causes the code inside draw() to execute * continuously again. The number of times draw() executes in each - * second may be controlled with the delay() and frameRate() - * functions. There can only be one draw() function for each sketch + * second may be controlled with frameRate() function. + * There can only be one draw() function for each sketch * and draw() must exist if you want the code to run continuously or * to process events such as mousePressed(). Sometimes, you might * have an empty call to draw() in your program as shown in the @@ -1811,7 +1811,7 @@ public class PApplet extends Applet // render a single frame //handleDraw(); if (g != null) g.requestDraw(); - + if (frameCount == 1) { // Call the request focus event once the image is sure to be on // screen and the component is valid. The OpenGL renderer will @@ -2048,7 +2048,7 @@ public class PApplet extends Applet } } - + ////////////////////////////////////////////////////////////// @@ -2074,14 +2074,14 @@ public class PApplet extends Applet }); } - + public void removeListeners() { removeMouseListener(this); removeMouseMotionListener(this); removeKeyListener(this); removeFocusListener(this); -// removeComponentListener(??); +// removeComponentListener(??); // addComponentListener(new ComponentAdapter() { // public void componentResized(ComponentEvent e) { // Component c = e.getComponent(); @@ -2095,10 +2095,10 @@ public class PApplet extends Applet // redraw(); // } // } -// }); +// }); } - - + + public void addListeners(Canvas canvas) { canvas.addMouseListener(this); canvas.addMouseMotionListener(this); @@ -2118,10 +2118,10 @@ public class PApplet extends Applet // redraw(); // } // } -// }); +// }); } - - + + public void removeListeners(Canvas canvas) { canvas.removeMouseListener(this); canvas.removeMouseMotionListener(this); @@ -2805,6 +2805,32 @@ public class PApplet extends Applet // controlling time (playing god) + /** + * The delay() function causes the program to halt for a specified time. + * Delay times are specified in thousandths of a second. For example, + * running delay(3000) will stop the program for three seconds and + * delay(500) will stop the program for a half-second. + * + * The screen only updates when the end of draw() is reached, so delay() + * cannot be used to slow down drawing. For instance, you cannot use delay() + * to control the timing of an animation. + * + * The delay() function should only be used for pausing scripts (i.e. + * a script that needs to pause a few seconds before attempting a download, + * or a sketch that needs to wait a few milliseconds before reading from + * the serial port). + */ + public void delay(int napTime) { + //if (frameCount != 0) { + //if (napTime > 0) { + try { + Thread.sleep(napTime); + } catch (InterruptedException e) { } + //} + //} + } + + /** * ( begin auto-generated from frameRate.xml ) * @@ -2815,13 +2841,6 @@ public class PApplet extends Applet * rate within setup(). The default rate is 60 frames per second. * * ( end auto-generated ) - *

Advanced

- * Set a target frameRate. This will cause delay() to be called - * after each frame so that the sketch synchronizes to a particular speed. - * Note that this only sets the maximum frame rate, it cannot be used to - * make a slow sketch go faster. Sketches have no default frame rate - * setting, and will attempt to use maximum processor power to achieve - * maximum speed. * @webref environment * @param newRateTarget number of frames per second * @see PApplet#setup() @@ -6686,16 +6705,16 @@ public class PApplet extends Applet ////////////////////////////////////////////////////////////// // URL ENCODING - + static public String urlEncode(String what) { try { return URLEncoder.encode(what, "UTF-8"); - } catch (UnsupportedEncodingException e) { // oh c'mon + } catch (UnsupportedEncodingException e) { // oh c'mon return null; } } - + static public String urlDecode(String what) { try { return URLDecoder.decode(what, "UTF-8"); @@ -6703,9 +6722,9 @@ public class PApplet extends Applet return null; } } - - + + ////////////////////////////////////////////////////////////// // SORT diff --git a/core/todo.txt b/core/todo.txt index 6e30475a4..3582f5af5 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -10,6 +10,16 @@ X repeatedly calling texture() with new image raises memory error X http://code.google.com/p/processing/issues/detail?id=806 X adding anti-alias methods so that FSAA can set up properly X several bug fixes inside Table as they relate to inserting/adding columns +X urlEncode() and urlDecode() added +X fix so that normals aren't attempted when no texture is set +X added setContent() to the XML library, other tweaks to XML export +X fix PImage.get() issue with width or height < 0 +X attempts to improve the performance of tint() with Java2D +X delay() remove or no? (keep adding it back...) +X serial and scripting need it. maybe edit the reference further... +X just can't remove it. needed for scripting. +X Fix OpenGL applets (again) +X http://code.google.com/p/processing/issues/detail?id=845 earlier o text using textMode(SCREEN) not displayed in Processing 1.5.1 @@ -40,7 +50,7 @@ _ need to decide if you specify the function name, or if it's specific _ fix edge + 1 issue on stroke/fill for rectangles -_ urlEncode() and urlDecode() +_ add reference/docs for urlEncode() and urlDecode() _ pause()/resume() need to work on the desktop side as well @@ -49,9 +59,6 @@ _ http://code.google.com/p/processing/issues/detail?id=904 _ add loadTable().. -_ delay() remove or no? (keep adding it back...) -_ serial and scripting need it. maybe edit the reference further... - _ do we need an option to disable XML whitespace? _ should this be the default to be more like old XML?