Use clear(); and nothing render

edited February 2014 in JavaScript Mode

Hello. Try to create first sketch via JavaScriptMode:

    void setup() {
      size(500, 500, P2D); 
    }
    void draw() {
      clear(); // Commented: text becomes pixelate (due to superposition). Uncommented: no text
      textSize(30);
      fill(#FF0000);
      textAlign(LEFT, TOP);
      text ("Hello", 50, 50);
    }

In JavaMode it ok: i see "Hello" word. In JavaScriptMode have nothing. If comment out "clear();" row, than word becomes visible, but, as you no, we have pixels superposition what looks bad and not applicable for animation.

How to fix this problem?

Answers

  • edited February 2014 Answer ✓

    JS Mode is @ version 1.4.1 as long as I know Processing. >:P It's very close to old Processing v1.5.1 though! 3:-O
    However, function clear() (and a bunch more) is new to Processing 2+. It's merely background(0, 0); underneath BtW! #-o

  • Thanks a lot!

  • btw noLoop(); will make sure the draw() loop only executes once - no overdrawing, no wasting of cpu cycles...

  • edited February 2014

    And where i can know what functions have same problem? And what functions a must use for JS 1.4.1? For example, next problem in following rows:

        Table mytab; // Table to load data from csv data-file
        mytab = loadTable("KBO2.csv", "header");
    

    If I add this rows in setup - nothing render again.

    Sorry for my English. )

  • edited February 2014 Answer ✓

    Processing 2 launched w/ lotsa a new cool data structures like:

    • IntList
    • FloatDict
    • Table
    • JSONArray
    • XML
    • etc.

    So, if you happen to use any of those, they won't work on JS Mode, sorry.
    Perhaps if you grab a recent beta Processing.JS version, you might be luck to find some of them implemented already? :-/

    P.S.: You can use loadStrings() + split() as a simple substitute for ".csv" files!

  • Thanks, GoToLoop. Try to use this constructions

  • You can gather from http://processingjs.org/reference/ which functions are implemented in ProcessingJS.

Sign In or Register to comment.