Well here it is in action my ruby-processing file_chooser library, that like control panel takes a block the fc.display returns a a string that you can use in load_image etc to load a file, you can do all this in a block if you like (see below). Is a replacement for vanilla processing selectInput function that relies on reflection (and the chooser cannot be so easily customised). PS the my_file temporary variable is not required. The chooser starts in the users home folder on unix (mac/linux) or the working directory on windoes.
load_library :file_chooser
attr_reader :img
def setup
size 600, 600
file_chooser do |fc|
fc.look_feel "Nimbus"
fc.set_filter "Image Files", [".png", ".jpg"]
my_file = fc.display
@img = load_image(my_file)
img.resize(width, height)
end
end
def draw
image img, 0, 0
end
 |
The Chooser (a customised JFileChooser) |
 |
The Sketch |
No comments:
Post a Comment