Experiments with ruby-processing (processing-2.2.1) and JRubyArt for processing-3.0

Friday, 23 August 2013

Image Viewer Ruby Processing

Here is a little sketch, exploring the possibility of using my file_chooser to create a neat little image viewer. I does not make too much sense on its own, but we can take a look at images in ruby-processing, and then possibly do something with them along the lines of exporting to a "pixelated" sketch to cfdg for example.
load_library :file_chooser
attr_reader :img

###########
# Example usage of file_chooser (in this case image file chooser) 
# not sure this is exactly possible with vanilla processing. Here we
# defer setting the size of the sketch, until we know the size of image.
###########

def setup
  file_chooser do |fc|
    fc.look_feel "Nimbus"
    fc.set_filter "Image Files",  [".png", ".jpg"]
    my_file = fc.display
    @img = load_image(my_file)
    size img.width, img.height
  end
end

def draw
  background img
end

No comments:

Post a Comment

Followers

Blog Archive

About Me

My photo
I have developed JRubyArt and propane new versions of ruby-processing for JRuby-9.1.5.0 and processing-3.2.2