Sha256: eb9b245b13957b23d0be71ecd5b6ad93ec15a216643f27568b0a411d7d6ad113

Contents?: true

Size: 923 Bytes

Versions: 4

Compression:

Stored size: 923 Bytes

Contents

# frozen_string_literal: true

# NOTE:
# This example displays images that can be freely downloaded from the Studio Ghibli website.

require 'glimmer-dsl-libui'
require 'chunky_png'
require 'open-uri'

include Glimmer

IMAGE_ROWS = []

50.times do |i|
  url = format('https://www.ghibli.jp/gallery/thumb-redturtle%03d.png', (i + 1))
  puts "Processing Image: #{url}"
  f = URI.open(url)
  canvas = ChunkyPNG::Canvas.from_io(f)
  f.close
  data = canvas.to_rgba_stream
  width = canvas.width
  height = canvas.height
  img = image(width, height) {
    image_part(data, width, height, width * 4)
  }
  IMAGE_ROWS << [img] # array of one column cell
rescue StandardError => e
  warn url, e.message
end

window('The Red Turtle', 310, 350, false) {
  horizontal_box {
    table {
      image_column('www.ghibli.jp/works/red-turtle')
      
      cell_rows IMAGE_ROWS
    }
  }
  
  on_closing do
    puts 'Bye Bye'
  end
}.show

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
glimmer-dsl-libui-0.0.22 examples/basic_table_image.rb
glimmer-dsl-libui-0.0.21 examples/basic_table_image.rb
glimmer-dsl-libui-0.0.20 examples/basic_table_image.rb
glimmer-dsl-libui-0.0.19 examples/basic_table_image.rb