Howdy, Stranger!

We are about to switch to a new forum software. Until then we have removed the registration on this forum.

  • How do I load and draw an image once as opposed to every frame to display it in every frame?

    Why do you want your sketch to keep looping?

    If the image is not big, it should be ok to let draw execute its draw normally.

    You could use noLoop() and this will ensure draw is run only once. If you answer my first question or provide some code, we will be able to understand your question better.

    Also, please post in the new forum: https://discourse.processing.org

    Kf

  • How do I make the timer stop and reset?

    Hard to say

    Look at function inputs

    connect the main ifs with else if so only one of them can be executed at a time

    Also at the end of the function say key=0;

    Note that there is a new forum

  • Emulator Opens Briefly then Closes, "lost connection with emulator"

    Brand-new to Android Mode. I have run a few Android Mode apps on my Galaxy 7 but wanted to develop on my Windows 10 64 bit computer with the emulator. When I try emulation itm the emulator, briefly opens up, nothing happens in it and then it closes and errors are reported in the Processing console: _BUILD SUCCESSFUL in 37s 28 actionable tasks: 28 executed Emulator process exited with status -1073741819. EmulatorController: Emulator never booted. NOT_RUNNING Error while starting the emulator. (NOT_RUNNING) Shutting down any existing adb server... Done. _

    My setup: I installed the latest Processing 3.4 yesterday and the Android SDK. Here is what I get when I select to update the SDK google usb_driver 11.0.0
    Android SDK Build-Tools 26.0.2
    Google APIs Intel x86 Atom System Image 11
    Android SDK Platform 26 2
    Android SDK Build-Tools 26.0.3
    Android SDK Tools 26.1.1
    Android SDK Platform-Tools 28.0.1

  • How do you redraw over this pixel array?

    Hello again, I'm trying to redraw over this 2D pixel array of this program.

    // main setup settings
    int dimy = 800;            // screen width 1681
    int dimx = 850;            //screen height 1019
    int bailout = 2000;         // number of iterations before bail
    int plots = 171294;        // number of plots to execute per frame (x30 = plots per second) 171294
    //zoom/magnification
    float magx = 4.0; // default 3.0, smaller means more zoom
    float magy = magx*(dimy/float(dimx));
    //pan
    float panx = 0.3; //default is 0.5
    float pany = 0.0; //default is 0.0
    //brightness multiplier
    float brt = 1.0; // brightness factor
    
    // 2D array to hold exposure values
    int[] exposure = new int[dimx*dimy];
    
    // maximum exposure value
    int maxexposure;           
    
    int time = 0;
    int exposures = 0;
    
     float Ex = 2;
    
     float x, y;
     float x0, y0;
    
    boolean drawing; 
    
    int sgn(float value) {            //if signus is needed sgn(x)=x/abs(x) = 1, 0 or -1
     if (value < 0) {return -1;}
     if (value > 0) {return 1;}
     return 0;
    }
    float cosh(float value1) {
     return 0.5*(exp(value1)+exp(-value1));
    }
    float sinh(float value2) {
     return 0.5*(exp(value2)-exp(-value2));
    }
    float arg(float axis1, float axis2) {
     if (axis2==0) {return PI;}
     else {return -atan(axis1/axis2)+PI*sgn(axis2)*0.5;}
    }
    float spharg(float axisa, float axisb, float axisc) {
     return acos(axisc/sqrt(sq(axisa)+sq(axisb)+sq(axisc)));
    }
    void setup() {
     // set up drawing area
     size(800,850,P3D);
    }
    void draw() {
     plotPlots();
     time++;
     if (time%1==0) { //every second
       findMaxExposure();
       // Infinitely Looping, nested boolean iteration(x0,y0,DrawIt)
       renderBrot();
     }
    }
    void plotPlots() {
    
     // iterate through some plots
     for (int n=0;n<plots;n++) {
       // Choose a random point in same range
       x = random(-2.0,2.0);
       y = random(-2.0,2.0);
       x0 = random(-2.0,2.0);
       y0 = random(-2.0,2.0);
    
       if (iterate(x,y,false)) {
        //Pauses Boolean, (d=pause, D=start)
         if (Ex > 1){
           iterate(x,y,true);
           exposures++;
          }
          if (Ex < 2){
           iterate(x,y,false);
          }
       }
    
     }
    }
    void renderBrot() {
     colorMode(RGB,1.0);
     // draw to screen
     for (int i=0;i<dimx;i++) {
       for (int j=0;j<dimy;j++) {
         float ramp = brt * exposure[i*dimy+j] / maxexposure;
         // blow out ultra bright regions
         if (ramp > 1)  {
           ramp = 1;
         }
         //shading formulae
         color c = color(pow(sin(ramp),0.4),pow(ramp,0.75),pow(ramp,2.5)); // sunset
         set(j,i,c);
       }
     }
    } 
    //   Iterate the Mandelbrot and return TRUE if the point exits
    //   Also handle the drawing of the exit points
    boolean iterate(float x0, float y0, boolean drawIt) {
     float x = 0.0;
     float y = 0.0;
     //float t = random(0,1);
     //float r = random(0,1);  
    
     //x0 = 0.0;
     //y0 = 0.0;
    
     float xnew, ynew;
     int ix,iy;
    
     for (int i=0;i<bailout;i++) {
    
       // Display iterations before false DrawIt boolean
       //if (i>0){
       //println(i);
       // }
    
       //set your costum formula here...
       //example:
       //default Mandelbrot
       xnew = x * x - y * y + x0;
       ynew = 2 * x * y + y0;
    
    // Draws pixel to screen -
    // Based on if drawIt boolean is true, and iterations[i] > 3
    
      // Defines and Draws Pixels in 2D Exposure Array
      // Draws pixel when iteration[i] > 3 within current boolean cycle of xnew, ynew values
      if (drawIt && (i > 3)) {
    
         ix = int(dimx*(panx+xnew+magx/2.0)/magx);
         iy = int(dimy*(pany+ynew+magy/2.0)/magy);
    
         //Defines points (ix,iy) within screen ranges
         if (ix >= 0 && iy >= 0 && ix < dimx && iy < dimy) {
           // rotate and expose point
           exposure[ix*dimy+iy]++;
       }
     }
    
       if ((xnew*xnew + ynew*ynew) > 4) {
         // escapes
         return true;
       }
       x = xnew;
       y = ynew;
     }
     // does not escape
     return false;
    }
    void findMaxExposure() {
     // assume no exposure
     maxexposure=0;
     // find the largest density value
     for (int i=0;i<dimy;i++) {
       for (int j=0;j<dimx;j++) {
         maxexposure = max(maxexposure,exposure[i*dimx+j]);
       }
     }
    } 
     void keyPressed(){
    
        //Return Iterate(x0,y0,DrawIt) False in Plot  
        if (key == 'r') {
         Ex = 1;
        }
        //Return Iterate(x0,y0,DrawIt) True in Plot  
        if (key == 'R') {
         Ex = 2;
        }
    }
    

    I've studied and tested many pixel array programs recently, but don't understand it enough to figure it out the exact method. I know the pixel array exposure[] is a 2D array within the looping, nested boolean iterate(x0,y0,drawIt) and that the pixel array output is derived from the specific code:

        // Draws pixel to screen -
        // Based on if drawIt boolean is true, and iterations[i] > 3
    
          // Defines and Draws Pixels in 2D Exposure Array
          // Draws pixel when iteration[i] > 3 within current boolean cycle of xnew, ynew values
          if (drawIt && (i > 3)) {
    
             ix = int(dimx*(panx+xnew+magx/2.0)/magx);
             iy = int(dimy*(pany+ynew+magy/2.0)/magy);
    
             //Defines points (ix,iy) within screen ranges
             if (ix >= 0 && iy >= 0 && ix < dimx && iy < dimy) {
               // rotate and expose point
               exposure[ix*dimy+iy]++;
           }
         }
    

    It's not a boolean true/false issue as the entire program is written in an infinite loop of nested booleans drawing, iterate(x0,y0,drawIt) and when halted either in the drawing section or the plotPlots() section the pixel array remains intact upon continuation of the program (as demonstrated with Keypressed 'r', 'R'). The program is well threaded into itself with it's booleans and I have no reason to change that fact.

    How would I go about updating the entire pixel array in this program to a single color (black) upon key press? Blanking out the canvas and the program continuing it's constant pixel drawing process of exposure points on screen again without the old pixels.

  • Run library PixelFlow on Android

    Can anyone run this project to android?

    https://github.com/diwi/PixelFlow/tree/master/examples/Fluid2D/Fluid_WindTunnel

    I spent a weeks to find solution but nothing.

    after remove unuse function (eg. mouseButton) i got this error.

    * What went wrong:
    Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
    > java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
    

    If anyone know the solution please tell me

  • how to make a batch file from processing?

    I am going to do the UI in VScode and I find that it cannot be executed with the .exe file I compiled. I searched and many say I should make a .bat file. I tried in my Processing but I cannot find where I can exported a .bat file. Know it is trivial, but still many thanks for your time.

  • Filepath Issue

    Thanks Kfrajer, I tried the code and got errors while compiling...

    3. ERROR in /private/var/folders/71/whbl6c5x08gczcqq00k33m4w0000gn/T/android317694126990055572sketch/src/processing/test/pixelpetal_v09/pixelpetal_v09.java (at line 354)
        stream =  surface.getAssets().open(filename); //new FileInputStream(filename);//createInput(filename);
                  ^^^^^^^
    surface cannot be resolved
    ----------
    3 problems (1 error, 2 warnings)
    
    BUILD FAILED
    /var/folders/71/whbl6c5x08gczcqq00k33m4w0000gn/T/android317694126990055572sketch/build.xml:15: The following error occurred while executing this line:
    /var/folders/71/whbl6c5x08gczcqq00k33m4w0000gn/T/android317694126990055572sketch/build.xml:28: Compile failed; see the compiler error output for details.
    
    Total time: 1 second
    

    And here is my sketch....

    Any ideas?

    Thanks again.

    Phil

    `
    import com.heroicrobot.dropbit.registry.*;
    import com.heroicrobot.dropbit.devices.pixelpusher.Pixel;
    import com.heroicrobot.dropbit.devices.pixelpusher.Strip;
    import java.util.*;
    import controlP5.*;
    import java.io.*;
    import android.graphics.*;
    
    
    Button myButton1;
    Button myButton2;
    Button myButton3;
    Button myButton4;
    Button myButton5;
    Button myButton6;
    Button myButton7;
    Button myButton8;
    Button myButton9;
    Button myButton10;
    Button myButton11;
    
    
    boolean noStrips = true;
    int buttonYpos = 0;
    
    ControlP5 cp5;
    
    // Set this to true to enable a debug display of the current frame.
    boolean onscreenDebug = true;
    
    int currentFrame = 0;
    
    // setup file path a durations for the image sequences
    
    String[] pathBases = {"null", "black", "grad", "buddah", "wipe", "orange", "embers", "psych", "petals", "sunrise", "smoke", "allseq"};
    int[] durations =     {0,   1,   2000,  1500, 1250, 750, 500, 1000, 1000, 1000, 240,  9704};
    int[] buttonOffsets = {0,   250, 350,   450,  550,  650, 750, 850,  950,  1050, 1150, 1250};
    
    String pathBase = pathBases[1]; // set start patern to "all off"
    int numFrames = durations[1];
    int whichMovie=1;
    
    PImage mainMovie;
    
    
    
    DeviceRegistry registry;
    PusherObserver observer;
    PGraphics offScreenBuffer;
    PImage bg;
    PImage errorScreen;
    PImage loadingScreen;
    
    
    // flags to control whether we redraw the UI
    boolean uiChanged = true;
    
    int Yoffset = -50; // this helps me quickly modify the position of the buttons 
    
    ArrayList<PImage[]> imageSequences;
    
    
    PImage[] loadImageSequence(String basename, int numFrames) {
      // create the array of references
      println("Loading image sequence "+basename+", "+numFrames+" frames.");
      PImage[] imageSequence = new PImage[numFrames];
    
      // now loop over the sequence loading them
      for (int i=0; i<numFrames; i++) {
        String imageName = "sequences/" + basename + "_pixelData/pixelData" + nf(i, 5) + ".png";
        imageSequence[i] = loadImage(imageName);
        println("Image "+imageName+" was loaded as "+imageSequence[i]);
      }
      return imageSequence;
    }
    
    void setup() {
      size(800, 1280, P3D); // Must be first in setup()
    
      // Load all our images.  
    
      imageSequences= new ArrayList<PImage[]>();
      // Add a null object to compensate for the 1-based numbering.
      imageSequences.add(null);
    
      // Load each image sequence and add it to the ArrayList  
      for (int i=1; i<pathBases.length; i++) {
        imageSequences.add(loadImageSequence(pathBases[i], durations[i]));
      }
    
      bg = loadImage("UI_Background.jpg");
      errorScreen = loadImage("noLEDSs.jpg");
      loadingScreen = loadImage("noLEDSs.jpg");
    
      stroke(255);
      noFill();
      strokeWeight(4); 
    
      cp5 = new ControlP5(this); // 
    
      cp5.setAutoDraw(false);
    
      frameRate(24);
    
      // create a new buttons for the UI
    
      myButton1 = cp5.addButton("alloff")
    
        .setCaptionLabel("All Off")
          .setValue(0)
            .setPosition(100, 250+Yoffset)
              .setSize(500, 60)
    
                ;
    
      myButton2 = cp5.addButton("grad")
    
        .setCaptionLabel("Color Grad")
          .setValue(0)
            .setPosition(100, 350+Yoffset)
              .setSize(500, 60)
    
                ;
    
      myButton3 = cp5.addButton("buddah")
    
        .setCaptionLabel("Pink Buddah")
          .setValue(0)
            .setPosition(100, 450+Yoffset)
              .setSize(500, 60)
    
                ;
    
      myButton4 = cp5.addButton("colorwipe")
        .setCaptionLabel("Color Wipe")
          .setValue(0)
            .setPosition(100, 550+Yoffset)
              .setSize(500, 60)
    
                ;
    
      myButton5 = cp5.addButton("orange")
        .setCaptionLabel("Orange Blossom")
          .setValue(0)
            .setPosition(100, 650+Yoffset)
              .setSize(500, 60)
    
                ;
    
    
    
      myButton6 = cp5.addButton("rustySwirl")
        .setCaptionLabel("Embers")
          .setValue(0)
            .setPosition(100, 750+Yoffset)
              .setSize(500, 60)
    
                ;
    
      myButton7 = cp5.addButton("psych")
        .setCaptionLabel("psychedelic blue")
          .setValue(0)
            .setPosition(100, 850+Yoffset)
              .setSize(500, 60)
    
                ;
    
      myButton8 = cp5.addButton("petals")
        .setCaptionLabel("rainbow petals")
          .setValue(0)
            .setPosition(100, 950+Yoffset)
              .setSize(500, 60)
    
                ;
    
      myButton9 = cp5.addButton("sunrise")
        .setCaptionLabel("Sunrise")
          .setValue(0)
            .setPosition(100, 1050+Yoffset)
              .setSize(500, 60)
    
                ;
    
      myButton10 = cp5.addButton("smoke")
        .setCaptionLabel("Ice Drops")
          .setValue(0)
            .setPosition(100, 1150+Yoffset)
              .setSize(500, 60)
    
                ;
    
      myButton11 = cp5.addButton("allSeq")
        .setCaptionLabel("All Sequences")
          .setValue(0)
            .setPosition(100, 1250+Yoffset)
              .setSize(500, 60)
    
                ;
    
    
      whichMovie=1; //default
    
      offScreenBuffer = createGraphics(326, 7);// offscreen buffer to hold the pattern
      registry = new DeviceRegistry();
      observer = new PusherObserver();
      registry.addObserver(observer);
      registry.setAntiLog(true);
      registry.setAutoThrottle(true);
    } 
    
    
    
    
    void draw() {
      if (!uiChanged)
        cp5.draw();        // we must do this every frame, or the event handler never fires.
    
      if (uiChanged) {
        buttonYpos = buttonOffsets[whichMovie] + Yoffset;
        background(bg);
        cp5.draw();
        pushMatrix();
        translate(0, buttonYpos);
        rect (100, 0, 500, 60); // selection state for the buttons
        popMatrix();
    
        numFrames = durations[whichMovie];
    
        uiChanged = false;
      }
    
      currentFrame = (currentFrame+1) % numFrames;  // Use % to cycle through frames and loop
      mainMovie = (imageSequences.get(whichMovie))[currentFrame];      // we just reference the images we loaded earlier.
    
      if (noStrips) {
        image(errorScreen, 000, 0, 800, 1280);
        uiChanged = true;
      } // display error if there are no strips detected
    
      if (onscreenDebug)
        image(mainMovie, 0, 0); // blit it so we can see what's happening
      offScreenBuffer.beginDraw();
      offScreenBuffer.image(mainMovie, 0, 0);
      //println(mainMovie);
      scrape(); // scrape the offscreen buffer 
      offScreenBuffer.endDraw();
    
    }
    
    
    
    
    
    // UI selections
    public void controlEvent(ControlEvent theEvent) {
      uiChanged = true;
      println("Took control event.");
      currentFrame = 0;
    }
    
    // ControlP5 automatic event handler methods.
    public void alloff(int theValue) {
      whichMovie = 1;
    }
    
    public void grad(int theValue) {
      whichMovie = 2;
    }
    
    
    
    public void buddah(int theValue) {
      whichMovie = 3;
    }
    
    public void colorwipe(int theValue) {
      whichMovie = 4;
    }
    
    public void orange(int theValue) {
      whichMovie = 5;
    }
    
    public void rustySwirl(int theValue) {
      whichMovie = 6;
    }
    
    public void psych(int theValue) {
      whichMovie = 7;
    }
    
    public void petals (int theValue) {
      whichMovie = 8;
    }
    
    
    public void sunrise(int theValue) {
      whichMovie = 9;
    }
    
    public void smoke(int theValue) {
      whichMovie = 10;
    }
    
    
    public void allSeq(int theValue) {
      whichMovie = 11;
    }
    
    
    void displayLoading() {
    
      loadingScreen = loadImage("noLEDSs.jpg");
      image(loadingScreen, 000, 0, 800, 1280);
    
    }
    
    
    
      public PImage loadImage(String filename) { //, Object params) {
      //    return loadImage(filename, null);
    
      println("Processing CUSTOM loading image....");
    
      InputStream stream=null;
      try {
        stream =  surface.getAssets().open(filename); //new FileInputStream(filename);//createInput(filename);
      }
      //catch(FileNotFoundException e) {}
      catch(IOException e) {}
    
    
      if (stream == null) {
        System.err.println("Could not find the image " + filename + ".");
        return null;
      }
      //    long t = System.currentTimeMillis();
      Bitmap bitmap = null;
      try {
        bitmap = BitmapFactory.decodeStream(stream);
      } 
      finally {
        try {
          stream.close();
          stream = null;
        } 
        catch (IOException e) {
        }
      }
      //    int much = (int) (System.currentTimeMillis() - t);
      //    println("loadImage(" + filename + ") was " + nfc(much));
      if (bitmap == null) {
        System.err.println("Could not load the image because the bitmap was empty.");
        return null;
      } else {
        PImage image = new PImage(bitmap);
        image.parent = this;
        return image;
      }
    }`
    
  • Problem with running sketch through usb debugging mode

    Howdy,

    I’m trying to build a simple App in processing and run it on my Google Pixel.

    In procesing I am getting the following error.

    I’m not even sure what information would be useful in debugging this. Can you help?

    Build folder: C:\Users\davef\AppData\Local\Temp\android1587529277536989285sketch :app:preBuild UP-TO-DATE :app:preDebugBuild :app:compileDebugAidl :app:compileDebugRenderscript FAILED

    FAILURE: Build failed with an exception.

    What went wrong: Execution failed for task ‘:app:compileDebugRenderscript’. llvm-rs-cc is missing

    Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

    Get more help at https://help.gradle.org

  • [NEVERMIND] How to make my sketch receive the file dragged onto the executable?

    I already found the answer to my question, just 3 seconds after posting it here. Sorry. Here's the original post:

    Using Windows 10 64bit. So I exported my sketch, and I have a .exe file that starts by double-clicking. Nothing special here, I know. However, if I drag another random file in Explorer and drop it onto the .exe file, then it doesn't open - not even a window. Investigating with task manager shows that javaw.exe opens and then instantly closes right away.

    From what I read, dropping a file onto a .exe simply makes Explorer run the .exe with path to the dropped file as a command line argument. But this isn't the case, or else the sketch wouldn't instantly close and I'd be able to get the received file path by reading args[0]. (args is an array of strings that contains every command line argument received)

    I want to have a .exe on which I can quickly drag and drop files and which will perform my code on such files. How?

    edit: After dropping the file onto the .exe 100th time out of desperacy, it actually opened and received the file as args[0]. This removes this question immediately, but I can't find the delete button(yet), and this also sparks a new question: why it didn't work previous 99 times?

  • processing and node.js stdin and stdout

    in a microservices architecture, i would like to make Processing generated applet to perform some task

    You need to provide more details. Like what sort of stdin and stdout you want to work with? For stdin, you could use the args passed to a processing sketch if you run it from node.js via the exec command (not tested). The exec command is demonstrated by Shifman here:

    Kf

  • unmanageable CPU cost when a video is loaded using video library

    You are using this in P3D. is this necessary? How do you display your movies?

    Also, if you execute this in draw(), shouldn't it be:

    if (but1_1==1 && !movie.isPlaying()) {
           println("video 1");
           movie = new Movie(this, "1.mp4"));
           movie.loop();
           movie.volume(0);
           but1_1=false;
    }
    

    Kf

  • Error when trying to use Processing

    Can you erase the Processing folder and download the zip again?

    Remember to extract the zip and then go to the folder and run the executable. What OS are you using?

    Kf

  • Huge Slowdown on Sketches with Type using Mac OS High Sierra

    In both cases it took longer when using the P3D (OpenGL) renderer than it did with the standard Java AWT renderer.

    This is not surprising because it will take longer for OpenGL to initialise because of its complexity compared with Java AWT. The size of the script will have no impact on the time to initialise the renderer.

    From the users perspective waiting several seconds might seem unacceptable for a tiny Processing script to execute but perfectly acceptable for a large Processing script. In both cases the efficiency is the same.

    There are many factors that can affect the start up time including

    • CPU type and speed
    • amount of RAM
    • Operating system and its version
    • GPU processor, speed, memory etc.
    • OpenGL drivers (version)
    • Java version
    • ...

    From a students perspective it probably seems worse because the code-run-code-run... cycle is very quick so any delay in executing the script can be annoying.

  • While value in array

    For a snake game, I have the food teleport to a random spot on the screen when you eat it, but it's possible for the food to end up on your tail, and not on an empty space. Basically, I sort of need some way to check if the food's x is in the arrayList for the snake's x, and the smae with y, and if so, to execute an action until that is not true.

  • Closing app on Backpress using Android Processing

    Just to inform you, package on processing 3.3.7 is recognized as an error so I could not use the Keycode you sent me.

    But based on your inputs, with research and experimentation, indicated are the following details. (Please correct me if I am wrong).

    (1) I needed to use the System.exit(0); due to the reason that it is the only tested way I used to disconnect the target device with the app via bluetooth. When I don't use the indicated code, the app disconnects with the process but target device does not disconnect, creating an inefficiency in accessing app when placed on the background, which only happens when the back button is pressed.

    (2) onBackPressed(); onHomePressed(); is not read in processing 3.3.7. I think that the reason to this is that, onBackPressed and onHomePressed runs in an activity and not in a fragment. And P3.3.7 executes commands in a fragment

    (2) onStop(); onPause(); are affected by all buttons, that is why running System.exit(0); affected all buttons making all of the them disconnect application with the target device.

    (3)onStop(); onPause(); when used in running System.exit(0); affects the app background button, giving it a minor inefficiency, wherein when the button is pressed if it is the only app on the background, there is a situation wherein you need to re-access the application twice.

    (4) Based on my observation, pressing the backbutton destroys the app before it places it on the background, making the application disconnect without making the target device disconnect bluetooth connection. So due to this instead on focusing codes using onBackpress();, I used on onDestroy(); because it is not affect by the app backround button and homebutton. So applying system.exit(0); onDestroy, is just like executing the exit upon back button press.

    So tested and finalized, due to the reason that the application has no more issues when pressing the 3 buttons, I used the indicated code below in exchange for the code that I used in this thread.

    public void onDestroy(){ System.exit(0); }

    These is a shared effort, so I will just indicate it as answered from akenaton's last response. Thank you.

  • Do things on a thread separate of draw

    I have found out that the algorithm is kind of faulty, because of lines 20-30. Only the one specific device should be updated, but instead I am updating all of them for each device. That means the number of updated devices would increase exponentially with each device added, which could result in terrible performance.

    int dupdates = 0;
    boolean changed;
    for (ExDevice d : devices) {
        d.resolved = false;
        for (ExDevice.Pin p : d.pins) p.resolved = false;
    }
    do {
        changed = false;
        for (ExDevice d : devices)
            if (!d.resolved) {
                d.behavior(); // execute the behavior no matter what because some things are done in an external JS script, even if nothing is connected
                for (ExDevice.Pin p : d.pins)
                    if (p.isInput) {
                        if (!p.resolved) {
                            for (ExDevice.Pin cp : p.connected)
                                if (!cp.resolved) {
                                    p.level = cp.level;
                                    p.resolved = true;
                                    changed = true;
                                }
                        }
                    }
                boolean allires = true; // ik this name is crap but it stands for "ALL Input pins RESolved" (capital letters = letters used in name)
                for (ExDevice.Pin p : d.pins) { // this was the faulty part: the input pins weren't checked for resolving properly
                    if (p.isInput && p.resolved) {
                        allires = false;
                    }
                }
                if (allires) {
                    d.behavior();
                    d.resolved = true;
                    changed = true;
                }
            }
        dupdates++;
    } while (changed && dupdates < 1024);
    
  • Is object creation delayed when managed into a P5js instance?
    • The sketch variable is passed to p5's constructor as a callback.
    • In order to know when that callback is actually invoked, we'd need to study p5.js' source code.
    • Also notice that setup() is a callback of the sketch callback.
    • Until the execution reaches the alert() inside setup(), the property type had been assigned to "A" a long time ago.
  • running app as root on rpi

    @jayson You should be able to run Processing as root by executing root processing in a terminal.

    Another possibility is to simply make the USB webcam available to all users, by running something like this sudo chmod 666 /dev/video*.

  • processing-java can't export to a specific platform

    I've always had problems with this tool. I'm running Windows 10, and using this command:

    processing-java --sketch=[path] --no-java --platform=linux --export
    

    And it always exports just the Windows executables.

    I am thinking about using --build to have more control over my build, but it's kind of inconvenient. Am I typing the command wrong?

    Also I can't find any reference to processing-java in the Processing source code, so that just makes it harder for me to understand this tool.

  • android build error: failed to create directory

    Hi, everyone. I am now trying Processing android mode. But cant build a simple sketch.

    I am on windows 7 64x and a Huawei phone with android version 4.4.4

    I used p5 version: 3.3.7 And the android mode version: 4.0.1

    The android sdk environment is: Google Repository 58.0.0
    google usb_driver 11.0.0
    Android SDK Build-Tools 26.0.2
    Android SDK Platform 26 2
    Android SDK Build-Tools 26.0.3
    Android Support Repository 47.0.0
    Android SDK Tools 26.1.1
    Android SDK Platform-Tools 27.0.1

    I just test the simple example:Basic-Color-Brightness I didnt modify any code but it cant run on the device

    the console shows:

        Build folder: C:\Users\User\AppData\Local\Temp\android5727509137112162348sketch
        :app:preBuild UP-TO-DATE
        :app:preDebugBuild
        :app:compileDebugAidl
        :app:compileDebugRenderscript
        :app:checkDebugManifest
        :app:generateDebugBuildConfig
        :app:prepareLintJar
        :app:generateDebugResValues
        :app:generateDebugResources
        :app:mergeDebugResources
        :app:createDebugCompatibleScreenManifests
        :app:processDebugManifest
        :app:splitsDiscoveryTaskDebug
        :app:processDebugResources
    

    and then the error in red:

    error: failed to create directory 'C:\Users\User\AppData\Local\Temp\android5727509137112162348sketch\app\build\generated\source\r\debug\processing\test\brightness'.

        Failed to execute aapt
    com.android.ide.common.process.ProcessException: Failed to execute aapt
        at com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:796)
        at com.android.build.gradle.tasks.ProcessAndroidResources.invokeAaptForSplit(ProcessAndroidResources.java:551)
        at com.android.build.gradle.tasks.ProcessAndroidResources.doFullTaskAction(ProcessAndroidResources.java:285)
        at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.java:109)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
        at org.gradle.api.internal.project.taskfactory.IncrementalTaskAction.doExecute(IncrementalTaskAction.java:46)
        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:121)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:110)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
        at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
        at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
        at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
        at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:60)
        at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:97)
        at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:87)
        at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
        at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
        at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:626)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:581)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
        at java.lang.Thread.run(Thread.java:748)
    Caused by: java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
        at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:503)
        at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:482)
        at com.google.common.util.concurrent.AbstractFuture$TrustedFuture.get(AbstractFuture.java:79)
        at com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:794)
        ... 50 more
    Caused by: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
        at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:503)
        at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:462)
        at com.google.common.util.concurrent.AbstractFuture$TrustedFuture.get(AbstractFuture.java:79)
        at com.android.builder.internal.aapt.v2.QueueableAapt2.lambda$makeValidatedPackage$1(QueueableAapt2.java:179)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        ... 1 more
    Caused by: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
        at com.android.builder.png.AaptProcess$NotifierProcessOutput.handleOutput(AaptProcess.java:463)
        at com.android.builder.png.AaptProcess$NotifierProcessOutput.err(AaptProcess.java:415)
        at com.android.builder.png.AaptProcess$ProcessOutputFacade.err(AaptProcess.java:332)
        at com.android.utils.GrabProcessOutput$1.run(GrabProcessOutput.java:104)
    

    There are more info but too long for the text area of this forum...so I post a screenshot below: https://photos.app.goo.gl/8HvxdZZgXYHF69xE6