Sha256: d9e37c072dc8c28798997ed8cbfaea1429e961670293799b2983eab94f658273

Contents?: true

Size: 700 Bytes

Versions: 4

Compression:

Stored size: 700 Bytes

Contents

load_library :file_chooser
attr_reader :img

###########
# Example file chooser (in this case an image file chooser).
# We delay setting size of sketch until we know image size, probably
# would not work vanilla processing. Note we can wrap much code in the
# file_chooser block, no need for reflection. As with selectInput vanilla
# processing.
###########

def setup
  file_chooser do |fc|
    fc.set_filter "Image Files",  [".png", ".jpg"] # easily customizable chooser
    @img = load_image(fc.display)                  # fc.display returns a path String
    size(img.width, img.height)
  end
end

def draw
  background img                                  # img must be same size as sketch
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ruby-processing-2.6.3 samples/processing_app/library/file_chooser/image_viewer.rb
ruby-processing-2.6.2 samples/processing_app/library/file_chooser/image_viewer.rb
ruby-processing-2.6.1 samples/processing_app/library/file_chooser/image_viewer.rb
ruby-processing-2.6.0 samples/processing_app/library/file_chooser/image_viewer.rb