processing-p5-convert

source code translator that converts Processing Java code to p5.js Javascript code

Home Minimal_example Command_line Notes About Project

(tests) hello bounce grid bounce_with_class cat hello_font hello_sound explode bounce_vectors hello_3d

(live conversion tests) phyllotaxis dandelin dogfooding

(student project tests) cow_game cross_the_road dinosaur_game greenhouse_game

bounce

Transformations:

Converted p5.js:

//
// bounce
//
let x = 100;
let y = 100;
let vx = 5;
let vy = 3;
function setup() {
    createCanvas(400, 400);
}
function draw() {
    background(0);
    ellipse(x, y, 100, 100);
    x += vx;
    y += vy;
    if (x < 50 || x > width - 50) vx *= -1;
    if (y < 50 || y > height - 50) vy *= -1;
}

Original Processing:

//
// bounce
//


float x = 100;
float y = 100;
float vx = 5;
float vy = 3;


void setup()
{
    size(400, 400);
}


void draw()
{
    background(0);
    ellipse(x, y, 100, 100);

    x += vx;
    y += vy;

    if (x < 50 || x > width-50)
        vx *= -1;

    if (y < 50 || y > height-50)
        vy *= -1;
}


home