Using GUIDO with JS

edited October 2014 in Library Questions

I am trying to use GUIDO with JS on a web server.

I am NOT using the processing IDE to do my work here.

I cant get the library to work right, and i am having trouble finding documentation on how to use the thing.

I have tried to use it in the following manner:

SimpleButton button;

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

    // make the manager

    Interactive.make( this );

    // create some buttons

    int w = (width-20)/20;
    for ( int ix = 20, k = width-w; ix <= k; ix += 2*w )
    {
        for ( int iy = 20, n = height-w; iy <= n; iy += 2*w )
        {
            new SimpleButton( ix, iy, w, w );
        }
    }
}


void draw ()
{
    background(0);
}

public class SimpleButton
{
    float x, y, width, height;
    boolean on;

    SimpleButton ( float xx, float yy, float w, float h )
    {
        x = xx; y = yy; width = w; height = h;

        Interactive.add( this ); // register it with the manager
    }

    // called by manager

    void mousePressed ( float mx, float my ) 
    {
        on = !on;
    }

    void draw () 
    {
        if ( on ) fill( 200 );
        else fill( 100 );

        rect(x, y, width, height);
    }
}

It doesn't seem to work for me. even though it doesn't throw any errors, nothign gets drawn.

do i need to use it differently in JS mode?

Answers

  • Answer ✓

    That is the 1st example which comes bundled w/ GUIDO library!
    If you activate JS Mode and run it, it's gonna create a "/web-export/" subfolder.
    Hit CTRL+K to open sketch's folder in order to reach that subfolder.

    When using a 3rd-party JS library, it goes into subfolder "/web-export/libs/". And that's where "Guido.js" is! (*)
    Last step is adapt the "index.html" for your particular needs. #:-S

Sign In or Register to comment.