My Glitch sketch doesn't work in JavaScript

Hello everyone, I am new in processing and I have a problem with playing/exporting/running with my sketch of glitch. It doesn't work in javascript. Can you help me please?

Code:

import glitchP5.*;

GlitchP5 glitchP5;

static final int DIAM = 0100, FPS = 10;

PImage img;

void setup() {

size(1000, 1000, JAVA2D); frameRate(FPS); smooth(4); img = loadImage("01.jpg"); glitchP5 = new GlitchP5(this);

}

void draw() { background(img); glitchP5.run();

}

void mousePressed() {

glitchP5.glitch(mouseX, mouseY, 200, 400, 200, 1200, 3, 1.0f, 10, 40); }

Tagged:

Answers

  • What exactly do you mean when you say that it doesn't work? Do you see any errors? Check the JavaScript console.

    I see a few things that I'd be suspicious of: you're importing a library- is that a Java library? If so, it won't work in JavaScript mode. You're also using JAVA2D rendering, which I don't think will work in JavaScript mode either.

  • Thank you very much. But how can I put this imported library to JavaScript?

  • You can't use Java libraries in JavaScript. The best you can hope for is that the makers of the library have also released a JavaScript library as well.

    I'm unfamiliar with the Glitch library, so you'd have to check with them.

    • All Processing's renderer constants are recognized in both JS & CS Modes.
    • And much probably in any Processing modes as well!
    • Although the actual engine is chosen by the framework mode of course. :-\"
  • Perhaps including the source code of the Glitch library in your sketch might work, unless they are themselves importing Java libraries...

Sign In or Register to comment.