Possibly the last hype library example I will be posting. Put me in mind of the hybrid ruby-processing and contextfree-art tool that I created to pixelize images that I have resurrected for JRubyArt.

colorist.rb


load_library 'hype'

java_import 'hype.extended.colorist.HPixelColorist'
java_import 'hype.extended.layout.HGridLayout'
include_package 'hype'

CELL_SIZE = 25

def settings
  size(640, 640)
end

def setup
  sketch_title 'Colorist'
  H.init(self)
  H.background(color('#242424'))

  colors = HPixelColorist.new(data_path('sintra.jpg'))
                         .fill_only
  # .stroke_only
  # .fill_and_stroke

  pool = HDrawablePool.new(576)
  pool.auto_add_to_stage
      .add(HRect.new.rounding(4))
      .layout(
        HGridLayout.new
                   .start_x(21)
                   .start_y(21)
                   .spacing(CELL_SIZE + 1, CELL_SIZE + 1)
                   .cols(24)
      )
      .on_create do |obj|
        obj.no_stroke.anchor_at(H::CENTER).size(CELL_SIZE)
        colors.apply_color(obj)
      end.request_all
  H.draw_stage
  no_loop
end