Sketches not Translating Correctly to Procoding

Home Forums Procoding Sketches not Translating Correctly to Procoding

Tagged: ,

This topic contains 5 replies, has 1 voice, and was last updated by  audiocommander 5 years, 5 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1021

    pablillojose

    Hello! Thank you for this really nice piece of software. I like that everything is in one window. It feels like one strong piece of software that can accomplish many things at once. There are few errors that I’m encountering and I can’t find a solution for it. I have old .pde sketches made in processing that display correctly in Processing but when moved to Procoding they don’t display at all. The proportions of the size of the windows doesn’t match with the preview window and when I hit refresh it doesn’t load all the objects made. It is a really simple sketch without using any java libraries… so I can’t really find the reason behind it. Also another problem that I’m encountering is that I want to translate another .pde sketch which pulls references from other .pde sketches. I have moved them to the resources windows but no luck as of anything showing… I’m aware that the ‘demos’ brought with Procoding work fine. None of my sketches come close to the complexities of the demos.

    #1022

    audiocommander
    Keymaster

    Hi pablillojose,

    glad to hear you like Procoding.

    As for the size, this is easy to answer: the one and only difference from Procoding to processing.js is that you can omit the size() when you run your sketch in Procoding and it’ll be automatically full (window) size. Usually this kind of fullscreen behavior is otherwise pretty complicated to achieve. However, when you set the size explicitly, the rendering (not the canvas view) should reflect this size.

    Regarding the problem with the class resources: if there are many (and long) files, there might be issues with JavaScript timing out. However, as you write your sketches are less complex than the provided demos, this sounds unlikely.

    I’m contacting you by the e-mail address you provided. If you send me the sketch you’re having troubles with, I can take a look.

    By the way: If you have Processing2 installed, you can also try to “run with processing-java”. Your sketch will compile and launch in Processing. This might help to nail down the error.

    Regards,
    Michael

    #1023

    audiocommander
    Keymaster

    Hi,

    1. The sketch “liveAMA” uses the Processing JSON library which is not available in JavaScript mode. As a general rule of thumb: if it doesn’t run in Processing 2’s JavaScript mode, it won’t run in Procoding either.
    Also: always look at your error messages. It already tells you everything you need to know: "Can't find variable: loadJSONObject".

    As a sidenote: processing.js needs to preload images. You can drag the image from the resource folder into your code to see how it should be done. Also see the documentation at processingjs.org

    As a second sidenode: displaying a map and drawing stuff onto it and loading JSON strings is really much easier to achieve with JavaScript. Everything is there, even native JSON support and xhr requests. Have a look at leaflet.js: http://leafletjs.com. Depending on the source, you can just take the JSON response and hand it over to leaflet and everything is handled automatically.
    Doing this with a png image in Processing in order to run that in a browser is a bit awkward.

    2. The sketch “munecorojo_ventana” has a couple of issues (e.g. setting the size twice or setting a framerate for basic mode). The main issue and the reason you’re seeing a blank page is that procoding has only limited support for processing’s basic mode, because on touch devices we want a dynamic fullscreen which adapts to screen rotations. This creates a conflict with the basic mode. So, just switch to continuous mode. In other words: use setup() and draw(). If you wrap your code inside those two functions, the sketch runs fine.

    In general:
    – Always read your error messages and the console log, fix your code until the errors disappear.
    – Check if you have an #import statement. That’s a Processing library which won’t work for processing.js. Remove the library and all functions using it.
    – Try “Run with processing-java” from within Procoding to see if it runs natively, this also gives you a couple of extra warnings and alerts. Fix your code until all warnings disappear.
    – Test your sketch in Processing 2 / JavaScript mode. Fix it until it runs there.
    – If you did all this and it still doesn’t work in Procoding you can contact me again with a detailed error description

    Hope this helps!

    All Best,
    Michael

    #1025

    pablillo jose

    Thank you! I will have a look at this. I’m still learning about the whole process… so its is great that you guide me through.

    #1026

    pablillo jose

    Hello Again,

    Once again. I’m getting a lot of this error: “Error: Processing.js: Unable to execute pjs sketch: SyntaxError: Invalid character: ‘#’” I was able to finally see the munecorojo_ventana being preview at the Procoding but still I get this errors based on the colors which I can’t find to understand why it does it. It looks like javascript accepts hex color codes… so I don’t see a problem. I’m looking through the IRC chat for help… just in case. In other words, the sketch seem to be working all fine but I keep getting an alert code red on the bottom of the editor displaying the syntax error….

    thanks,
    pablillo jose

    #1027

    audiocommander
    Keymaster

    Hej,

    JavaScript does’t know hex with #, you need to wrap those in quotes: “#FFFFFF”

    Best,
    Michael

Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘Sketches not Translating Correctly to Procoding’ is closed to new replies.