Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Support render keywords in size() #50

Closed
4 tasks done
jeremydouglass opened this issue May 12, 2017 · 2 comments
Closed
4 tasks done

Support render keywords in size() #50

jeremydouglass opened this issue May 12, 2017 · 2 comments

Comments

@jeremydouglass
Copy link
Member

jeremydouglass commented May 12, 2017

The Processing size() command takes keywords for each renderer. In addition to the default renderer, other renderers are: (from https://processing.org/reference/size_.html )

  • P2D (Processing 2D): 2D graphics renderer that makes use of OpenGL-compatible graphics hardware.
  • P3D (Processing 3D): 3D graphics renderer that makes use of OpenGL-compatible graphics hardware.
  • FX2D (JavaFX 2D): A 2D renderer that uses JavaFX, which may be faster for some applications, but has some compatibility quirks.
  • PDF: The PDF renderer draws 2D graphics directly to an Acrobat PDF file.

So, currently the Processing.R example sketch 3d-cube.R:

settings <- function()
{
  processing$size(500, 500, "processing.opengl.PGraphics3D")
}

Would become:

settings <- function()
{
  processing$size(500, 500, P3D)
}

While this issue is unresolved, I would recommend that current and future example sketches have render keywords defined in the header so that settings() more closely mirrors normal Processing code -- using this style:

P3D <- "processing.opengl.PGraphics3D"
settings <- function()
{
  processing$size(500, 500, P3D)
}

Supporting render keywords in Processing.R will make it much easier to translate sketches back and for between Processing(Java) and Processing.R -- especially for new learners.

@jeremydouglass
Copy link
Member Author

jeremydouglass commented May 12, 2017

...related: I see that currently select keywords -- "width" "height" etc. -- are being mapped in RLangPApplet wrapProcessingVariables():

https://github.com/gaocegege/Processing.R/blob/a5a51a9fcdf9032f56edff97003b0f65602bd31d/src/rprocessing/RLangPApplet.java#L206

protected void wrapProcessingVariables() {
        log("Wrap Processing built-in variables into R top context.");
        this.renjinEngine.put("width", width);
        this.renjinEngine.put("height", height);
        this.renjinEngine.put("displayWidth", displayWidth);
        this.renjinEngine.put("displayHeight", displayHeight);
        this.renjinEngine.put("focused", focused);
        this.renjinEngine.put("keyPressed", keyPressed);
        this.renjinEngine.put("frameCount", (double) frameCount);
        this.renjinEngine.put("frameRate", frameRate);
        // TODO: Find some ways to push constants into R.
    }

@gaocegege
Copy link
Member

Yeah it is a future work. I am not familiar with the logic of renjin about variable binding now.

ref https://forum.processing.org/two/discussion/comment/97742/#Comment_97742

@gaocegege gaocegege added this to the Final Evaluation milestone May 26, 2017
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants