ofxjavascript


Javascript addon for openframeworks

About

ofxJavascript is an addon developped for openframeworks that allows applications to embed and execute Javascript thanks to Mozilla engine (called "Spidermonkey" / "Tracemonkey").

http://www.v3ga.net/of/screenshots/090910_ofxJS_testFontWheel.png

Bindings

ofxJavascript exposes several classes of openframeworks library to Javascript * Global functions * ofxJSImage * ofxJSTrueTypeFont * ofxJSOpenGL * ... more to come soon !

But you can also : * call your C++ functions from Javascript * call Javascript functions from C++ * create your "own" Javascript classes (like ofxJSImage for example)

Applications

Livecoding (*coming very soon*) is a parallel project built upon openframeworks and ofxjavascript that makes possible to modify a program while it is running.

Example

Script used to generate the image above : ``` //-------------------------------------------------------------- function setup() { of.SetWindowTitle("OpenframeworksJS / testFontWheel.js");

myFont = new ofxJSTrueTypeFont();
myFont.loadFont("Batang.ttf",20);

of.SetWindowShape(1000, 300);
of.SetBackgroundAuto(false);
of.SetVerticalSync(true);
of.EnableSmoothing();
of.Background(0,0,0);

data = <root>
            <t v="openframeworks"/>
            <t v="ofxJavascript"/>
            <t v="released in"/>
            <t v="September 2009"/>
            <t v="http://code.google.com/p/ofxjavascript"/>
        </root>

}

//-------------------------------------------------------------- function update() { rot = -(mouseX-of.GetWidth()/2)/of.GetWidth() * 360; }

//-------------------------------------------------------------- function draw() { of.Background(0,0,0);

var strings = data.t;
var nb = data.t.length();
of.Translate(of.GetWidth()/2,of.GetHeight()/2,-30);
of.RotateX(-20);
of.RotateY(rot);
for (i=0;i<nb;i++)
{
    of.RotateY(360 / nb);
    myFont.drawString(strings[i].@v.toString(), 20,0);
}

}

//-------------------------------------------------------------- function mouseMoved(x,y) { mouseX = x; mouseY = y; }

//-------------------------------------------------------------- mouseX = 0; mouseY = 0; rot = 0; ```

Javascript version

ofxJavascript includes Javascript v1.6

Links

Project Information

Labels:
openframeworks c javascript spidermonkey livecoding