Howdy, Stranger!

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

  • PGraphics in P2D mode renders only black color.

    If the server is running 'headless', ie it has no gui, then you may lose the ability to create pictures on it.

    See here: https://github.com/processing/processing/wiki/Running-without-a-Display

    What operating system is the server running?

  • Proposal idea: Processing in Bash

    Hi folks, thanks for the quick responses.

    Dan, I've used Processing-Java. It's great but I'm proposing something a little different as this would actually literally be written and running in Bash with ImageMagick powering it. It's like the differences between p5.js and processing.js It would be good for headless mode and any functionality that needs bash interoperability. Other reasons I'm excited about Bash are because it's old and will be around forever; it's a way of working that offers a potentially different paradigm or way of coding (input/output, KISS, small functionality, ability to use system or local $vars aliases, call other programs and functions, among other reasons.

    Jeremy, Here's my current working model (though open to change)

    • You can write a sketch (can include setup and/or draw loop or not)
    • You write many of the Processing options we know and love (see my earliest version of commands in the reference below) as well as you're able to use Bash functions
    • The image gets generated and rendered (in x-windows) and is also saved as probably a gif or jpeg by default but you could specify bmp, jpeg, pdf, gif, png, tif, psd, etc etc etc (there are dozens of options due to imagemagick)
    • Currently my setup is that the image is built/rendered at the end of the setup block, with all of the specified options from that block added in order
    • I am unsure how draw should work. It could be on a loop occurring every t number of seconds (and then would coalesce OR overlay depending on specification), or it could just render one additional time by default (this is how basil.js works for example)
    • I could potentially hook into ffmpeg for outputting video files instead of the moving gifs made using ImageMagick
    • Piping is potentially exciting. You could pipe an image into (or out of) p5.sh, potentially even specifying additional options.

    Thanks for any feedback. This is the very first version of my reference. I'll be building out more of the basic Processing commands. I'm still unsure if I should be using Processing-like parens or Bash-like just leave the parentheses and commas out and leave a space between everything.

    Color

    background(0) OR OR background (100, 0.5) OR background(20, 40, 120, 0.8)
    stroke(20) OR stroke (40, 100, 250) fill(0, 102, 150)

    SHAPE

    point(40,100)
    line(20,30,100,180)
    rect(100,100,100,100)
    ellipse(100,100,10,10)

    DATA

    x = 100
    x = 100.1
    x = "hello"
    arrayName=(Value1 Value2 Value3 ValueN)
    random (min value, max value)

    TEXT

    print("string",xLocation,yLocation)

    CONTROL

    borrow from Bash or Processing?
    comment #
    debug echo

    STRUCTURE

    functions - borrow from Bash

    INPUT

    NO! mouseX, mousePressed() at this time!

    IMAGES

    image(path/to/image)
    save(specifyName.jpg)

  • Proposal idea: Processing in Bash

    Thanks for this idea! As a reference take a look at how Processing Command Line works.

    https://github.com/processing/processing/wiki/Command-Line

    I have worked on several projects where I need to run Processing to generate images on a "headless" machine (combined with a web server or some other technology). It often involves a lot of acrobatics to create a "fake" display. Making this easier for people could be interesting.

  • Problems running sketch exported to Linux

    Hello all,

    I'm not very familiar with Linux or running programs via the shell, but following Daniel Shiffman's tutorial series, I wrote a sketch which outputs a PNG and posts it to Twitter. The sketch was exported as a Linux application and runs in headless mode on my server. However, an almost identical method for another sketch doesn't seem to run at all and I'm not sure where the problem lies.

    When inspecting the files in Linux, my terminal colour codes one of the exported applications green (meaning an executable), but the non-functional one is coloured white (i.e. not recognised). This probably isn't a reliable means to debug, but could there be something in my sketch which is preventing it from exporting properly?

    I've tried troubleshooting using the Wiki, but can't see anything which might be causing it. If anyone has experienced anything similar (or can see something glaring which I'm overlooking), I'd really appreciate some advice.

    Full sketch code can be found here: https://github.com/CodeMacabre/obitbot/blob/master/tombstone/tombstone.pde

    Thanks.

  • Headless 2D drawing, saved as a jpeg

    Thank you.

    The headless link goes to some technical Linux thing so I don't think it applies (I am trying to write this for a Windows desktop), but thanks for looking.

    If the programme runs quickly enough it might appear and dis-appear without being noticed or too obvious.

    Thanks for that, now all I need is to write the rest of the code (!).

  • Headless 2D drawing, saved as a jpeg

    1) Sort of. You will always get a sketch window that appears, but there is no need to use it for anything. You can just leave it blank, do whatever you like, and the call exit() to close the sketch. If you really, really need a headless mode, I think there is one, but it's a trick and a half to get it to work.

    2) Yes.

    Here's an example sketch that may suit your needs:

    void setup(){
      size(200,200);
      background(0);
      fill(255);
      textAlign(CENTER);
      text("Unused window - Please ignore", 100,100);
    
      PGraphics pg = createGraphics(400,400);
      pg.beginDraw();
      pg.background(255);
      for( int i=0; i<100; i++){
        pg.fill(random(255),random(255),random(255));
        pg.ellipse(random(pg.width),random(pg.height),10,10);
      }
      pg.fill(0);
      pg.textAlign(CENTER);
      pg.text("Do you believe in magic?", 200,200);
      pg.endDraw();
      PImage pi = pg.get();
      pi.save("magic.PNG");
    }
    
    void draw(){
      exit();
    }
    
  • Headless 2D drawing, saved as a jpeg

    Hello,

    I've been a programmer for a while and I am interested in using the built-in graphics libraries in Processing, I think can manage the Java part of Processing but I have two particular features that my programme would have and I'd like to check it would be possible in processing before I start :

    1. Can it work in a non-interactive mode (shewing no UI), in this case opening a file, doing some tasks and then closing?
    2. Can it draw to some non-visible area (of memory), e.g. using coloured lines, hatching, fills, text etc and then save that drawing as a jpeg?

    Thanks for your help.

  • Using p5.js in a node.js server

    @jgeist -- thanks for sharing that your solution was Java headless.

    Nice project. You should post it to the forum Share Your Work channel!

    Re:headless p5.js -- if someone wanted to pursue this, the suggestion from @blindfish to run it by scripting phantomjs actually sound like it should work to me! (Although maybe I'm wrong -- you try it, jgeist?) It also sounds like it would be a big pain....

  • Using p5.js in a node.js server

    So, what I ended up doing was using plain old Processing/Java on a server and invoking Schiffman's ideas regarding running P5 headless.

    https://github.com/processing/processing/wiki/Running-without-a-Display

    It works pretty well for now, but it would be nice to role this into a .js solution which was kinda a p5.js server. Anyhow, check it out on twitter, tweeting texts derived from Guy Debord's Society of the Spectacle, with some noise based images here: @nanofortran

  • Development using Windows IOT, processing & Rpi 3?

    I don't know, but Windows IOT is headless, no?

  • Include p5 libs and sketch via 'require' or npm install?

    If you're looking for a "headless" vector lib, I've got 1 written in TypeScript. :-\"
    But it's just casually experimental. I've never tested it yet, lazy moi! b-(
    But I guess it's worth a try. It's based on the Pjs library btW: O:-)

    Download:

    https://GitHub.com/GoToLoop/pjs-proto/blob/master/Pjs.js

    Source:

    https://GitHub.com/GoToLoop/pjs-proto/tree/master/math

    Extremely Loose Reference:

    http://ProcessingJS.org/reference/PVector/

  • Include p5 libs and sketch via 'require' or npm install?

    Browserify looks pretty slick. I'm working on something that will have a bunch of little script files (for classes etc) and now I should be able to bundle those all up for a 'release'. Thanks!

    On another point you mentioned - is it all of p5 that cannot run on the server side, or just the stuff that interacts with the window? It would be nice to able to use the vector stuff and collide2D on the server side - I've done vector math and collision detection from scratch before, but...

    If not, I wonder if a 'headless' version of p5 would be possible - or perhaps it's just too limited a use case to bother creating.

  • can't run the processing-java command from Raspberry Pi terminal (for a twitter bot)

    Hi all, I've made a twitter bot using node and processing and it seems I cant get the processing program to run properly from the Raspberry Pi's terminal command.

    When I run this command in the terminal: processing-java --sketch=pwd/bomb/ --run media.jpeg
    I get an error of "Exception in thread "main" java.awt.AWTError: Can't connect to x11 window server using ':1' as the value of the DISPLAY variable. . .

    I've tried running this command as well: processing-java --sketch=pwd/bomb/ --run media.jpeg -Djava.awt.headless=true
    But I still get an error.

    And this is after I've tried setting the display variable using this command I found from another post: export DISPLAY=":1"; /usr/local/lib/processing-3.1.1/processing-java

    Does anyone have any advice for how to troubleshoot this some more? (I'm new to Raspberry Pi so apologies if the answer is obvious)

  • Rendering 3D scenes correctly from headless Processing instance

    I have the following test sketch, which aims to render a cube with perspective and shading, and write the rendered scene to a PDF file:

    import processing.pdf.*;
    
    void setup() {
      size(640, 360, P3D);
      noStroke();
      fill(204);
    }
    
    void draw() {
      beginRaw(PDF, "output.pdf");
    
      // Do all your drawing here
      background(0);
      lights();
    
      float fov = PI/3.0;
      float cameraZ = (height/2.0) / tan(fov/2.0);
      perspective(fov, float(width)/float(height), cameraZ/2.0, cameraZ*2.0);
    
      translate(width/2, height/2, 0);
      rotateX(-PI/6);
      rotateY(PI/3);
      box(160);
    
      endRaw();
      println("Finished.");
      exit();
    }
    

    If I render this scene from a headless instance of processing-java via an Xvfb frame buffer, then I get a cube with the wrong background color and no shading (lighting):

    If I modify the code so that I don't exit from the script, e.g.:

    import processing.pdf.*;
    
    void setup() {
      size(640, 360, P3D);
      noStroke();
      fill(204);
    }
    
    void draw() {
      beginRaw(PDF, "output.pdf");
    
      // Do all your drawing here
      background(0);
      lights();
    
      float fov = PI/3.0;
      float cameraZ = (height/2.0) / tan(fov/2.0);
      perspective(fov, float(width)/float(height), cameraZ/2.0, cameraZ*2.0);
    
      translate(width/2, height/2, 0);
      rotateX(-PI/6);
      rotateY(PI/3);
      box(160);
    
      endRaw();
      //println("Finished.");
      //exit();
    }
    

    Then the "headed"-display renders with correct shading:

    So I think the script itself is correct, insofar as it creates the scene I want so long as I don't call exit(), but I'm not doing something correct to get a rendering into a PDF file. Is there something I am missing or doing incorrectly here? Thanks for any advice.

  • Running headless on Raspberry Pi

    I'm trying to run an exported Processing app on my Raspberry Pi, but I'm getting an error when running headless. I tried following the suggested Processing instructions but I get this error when running the Xvfb command:

    sudo Xvfb :1 -screen 0 1024x768x24
    _XSERVTransSocketOpenCOTSServer: Unable to open socket for inet6
    _XSERVTransOpen: transport open failed for inet6/botserver:1
    _XSERVTransMakeAllCOTSServerListeners: failed to open listener for inet6
    [dix] Could not init font path element /usr/share/fonts/X11/misc, removing from list!
    [dix] Could not init font path element /usr/share/fonts/X11/cyrillic, removing from list!
    [dix] Could not init font path element /usr/share/fonts/X11/100dpi/:unscaled, removing from list!
    [dix] Could not init font path element /usr/share/fonts/X11/75dpi/:unscaled, removing from list!
    [dix] Could not init font path element /usr/share/fonts/X11/100dpi, removing from list!
    [dix] Could not init font path element /usr/share/fonts/X11/75dpi, removing from list!
    [dix] Could not init font path element /var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType, removing from list!
    

    After which it just hangs until I control-C out.

    Any help is most appreciated!

  • Can I create processing files and run them from command line in debian?

    server

    This but might be trouble, especially if it's headless. What will the sketches do?

  • Solutions to Some G4P Window Issues

    All the G4P dialog boxes are linked to the main PS window to make them appear centred. This behaviour seemed good to me especially if there are multiple applications running on a high res display. Also PS was not designed to operate in headless mode so I always assumed the main display window would be visible and in use.

    You could always make the main window visible only when you call selectInput and then hide it afterwards. You could also use PS's selectInput method but this provides asynchronous input rather than the synchronous access provided by G4P. This means that these PS and G4P dialog boxes are NOT interchangeable without significant code changes.

    By default new GWindows are 'set on top' so will always appear over other windows. You can change this with gwin.setOnTop (false)

    GWindow extends Frame so you can use the methods setMinimumSize, setPreferedSize and setMaximumSize with the GWindow directly.

  • Building a headless mode
    • Seems like main stumbling block is createGraphics() in order to properly instantiate 1 of the PGraphics subclasses. :-<
    • In the past I did some experiments in subclassing PGraphics which bypass createGraphics().
    • Dunno whether it's enough to use PGraphics in headless mode.
    • But it's worth a shot me guess... :-\"
    1. http://forum.processing.org/two/discussion/5238/creating-a-layer-class-that-extends-pgraphics
    2. http://forum.processing.org/two/discussion/6884/question-about-pgraphics
  • Building a headless mode

    This question asks how to draw graphics on a headless workstation. If I run an X server, then obviously, I can run with a PApplet and this is moot. However, it seemed pretty simple to just attach a PGraphics to an image and draw on that instead of a PApplet.

    However, @GotoLoop, if the only way of constructing a PGraphics is to have a PApplet do it, then this approach is useless since it won't work on a headless machine.

    I looked at the source code for createGraphics, but I could not construct a sequence of operations that would work on an image.

  • Building a headless mode

    In case you wish to clone an already existing PGraphics instead, the process is very similar.
    We only need to find out which renderer it is via isPG(), is2D() & is3D() tests:

    // forum.processing.org/two/discussion/10305/building-a-headless-mode
    
    PGraphics pgClone;
    
    void setup() {
      size(300, 300, P2D);
      smooth(4);
      noLoop();
    
      PGraphics pgTmp = createGraphics(width, height);
      pgTmp.beginDraw();
      pgTmp.fill(#0000FF);
      pgTmp.ellipse(pgTmp.width>>1, pgTmp.height>>1, pgTmp.width>>1, pgTmp.height>>1);
      pgTmp.endDraw();
    
      pgClone = clonePGraphics(pgTmp);
    }
    
    void draw() {
      background(pgClone);
    }
    
    PGraphics clonePGraphics(PGraphics pg) {
      String renderer  = !pg.isGL()? JAVA2D : (pg.is2D()? P2D : P3D);
      PGraphics cloned = createGraphics(pg.width, pg.height, renderer);
    
      cloned.beginDraw();
      cloned.background(pg);
      cloned.endDraw();
    
      return cloned;
    }