MGraphics javascript api documentation inconsistency…

Nov 13, 2012 at 5:27pm

MGraphics javascript api documentation inconsistency…

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); // < ---- this works
//mgfx.fill(100); // < ---- no compiler error, and does not work!
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();
}
}

#65203
Nov 24, 2012 at 5:35pm

Are there any Cycling74 folk out there? Is this a bug?

#234986
Jan 10, 2013 at 6:14pm

This issue was a javascript parameter issue. See…

http://cycling74.com/forums/topic.php?id=43851

#234987

You must be logged in to reply to this topic.