MGraphics javascript api documentation inconsistency...


    Nov 13 2012 | 5:27 pm
    I am experiencing some strangeness with javascript and mgraphics.
    The code below shows a simple sketch. I have commented two lines,
    one that works one that does not.
    If you uncomment the line that does not work, you do not get a compiler
    error but the sketch is broken. Which means that there is an undocumented call
    to mgraphics matching the function signature fill(rgb), that is not documented.
    Is this interpretation correct?
    autowatch = 1;
    var width = 500;
    var height = 300;
    var mgfx = new MGraphics(width,height);
    mgfx.init();
    mgfx.relative_coords = 0;
    mgfx.autofill = 0;
    var outmatrix = new JitterMatrix(4, "char", width, height);
    var rotation = new Array(0.0, 0.0, 0.0);
    var curMatrix = new Array(0.0, 0.0, 0.0);
    var frameCount = 0;
    mgfx.redraw();
    function bang()
    {
    draw();
    frameCount++;
    }
    function draw()
    {
    var theImage = null;
    clearBackground();
    fill(100); // //mgfx.fill(100); // mgfx.rectangle(0, 0, 100, 100);
    mgfx.fill();
    mgfx.identity_matrix();
    theImage = new Image(mgfx.pop_group());
    mgfx.image_surface_draw(theImage);
    theImage.tonamedmatrix(outmatrix.name);
    outlet(0, "jit_matrix", outmatrix.name);
    gc();
    }
    function fill(rgb)
    {
    mgfx.set_source_rgba(rgb/255, rgb/255, rgb/255, 1);
    }
    function clearBackground() {
    background(0);
    }
    function background(rgb)
    {
    with (mgfx)
    {
    set_source_rgb(rgb/255, rgb/255, rgb/255);
    rectangle(0, 0, width, height);
    fill();
    }
    }