Jsui loading image files

Jun 29, 2011 at 6:44am

Jsui loading image files

Hi,
how does one load image files into a jsui object? Could someone give me a coding example? I found some info here: http://cycling74.com/docs/max5/vignettes/js/jsimageobject.html

Sorry if this seems like a really simple question but I just can’t seem to get it to work.

thanks,

#57813
Jun 29, 2011 at 7:46am

This is how it works:

// define your drawing context (canvas) as 2d
sketch.default2d();

function draw(filename) {
	// a) contsructing the new image object with the filename
	var img = new Image(filename);

	// b) optionally: scale the image to a certain size
	img.scale(100,75);

	// c) copy the pixels from the object to the drawing context
	sketch.copypixels(img);

	// d)refresh the display of jsui
	refresh();
}

send the message [draw filename] to the jsui and the image will appear.

j.

#207427
Jun 29, 2011 at 7:48am

By the way – jsui uses JavaScript not Java (just because the thread is in the Java forum). Similar name very different things…. ;)

#207428
Jun 30, 2011 at 3:22pm

moved to JavaScript forum…

#207429

You must be logged in to reply to this topic.