Jsui loading image files


    Jun 29 2011 | 6:44 am
    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,

    • Jun 29 2011 | 7:46 am
      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.
    • Jun 29 2011 | 7:48 am
      By the way - jsui uses JavaScript not Java (just because the thread is in the Java forum). Similar name very different things.... ;)
    • Jun 30 2011 | 3:22 pm
      moved to JavaScript forum...