require 'ruby2d' set title: '6' set width: 200 set height: 200 r=12 set background: 'green' interactive_circles = [] class InteractiveCircle def initialize(x, y, r) extend Ruby2D::DSL @circle = Image.new(x:x-r, y: y-r, path:"03.png", color: "yellow") @hover_event = on :mouse_move do |e| if @circle.contains?(e.x, e.y) @circle.color = "yellow" else @circle.color = "orange" end end end end on :mouse_down do |e| if e.button == :right interactive_circles << InteractiveCircle.new(e.x, e.y, r) end end show