diff --git a/examples/reference/frameRateVar/.property.yml b/examples/reference/frameRateVar/.property.yml new file mode 100644 index 0000000..9ad732d --- /dev/null +++ b/examples/reference/frameRateVar/.property.yml @@ -0,0 +1,8 @@ +category: Environment +subcategory: +description: " +The system variable frameRateVar contains the approximate frame rate of a running sketch. The initial value is 10 fps and is updated with each frame. The value is averaged over several frames, and so will only be accurate after the draw function has run 5-10 times. +" +syntax: "" +related: + - frameRate diff --git a/examples/reference/frameRate_var/.property.yml b/examples/reference/frameRate_var/.property.yml deleted file mode 100644 index 1bd3d72..0000000 --- a/examples/reference/frameRate_var/.property.yml +++ /dev/null @@ -1,8 +0,0 @@ -category: Environment -subcategory: -description: " -The system variable frameRate contains the approximate frame rate of a running sketch. The initial value is 10 fps and is updated with each frame. The value is averaged over several frames, and so will only be accurate after the draw function has run 5-10 times. -" -syntax: "" -related: - - frameRate diff --git a/src/rprocessing/RLangPApplet.java b/src/rprocessing/RLangPApplet.java index b94499a..b3277cf 100644 --- a/src/rprocessing/RLangPApplet.java +++ b/src/rprocessing/RLangPApplet.java @@ -329,7 +329,7 @@ public void setup() { @Override public void handleDraw() { super.handleDraw(); - this.renjinEngine.put("frameCount", this.frameCount); + this.wrapFrameVariables(); } /** @@ -368,6 +368,11 @@ private boolean isMixMode() { return hasSize; } + protected void wrapFrameVariables() { + this.renjinEngine.put("frameRateVar", frameRate); + this.renjinEngine.put("frameCount", frameCount); + } + /** * Set Environment variables in R top context. */