secret
anonymous / leak_test.rb
Created

  • Download Gist
leak_test.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
require 'gtk2'
 
class DrawThing < Gtk::DrawingArea
 
def initialize(parent)
@parent = parent
super()
modify_bg Gtk::STATE_NORMAL, Gdk::Color.new(0, 0, 0)
signal_connect "expose-event" do
expose
end
GLib::Timeout.add(50) { on_timer }
end
def on_timer
queue_draw
end
def expose
cr = window.create_cairo_context
ext = cr.clip_extents
20.times do
cr.set_source_rgb(rand(100)*0.01,rand(100)*0.01,rand(100)*0.01)
cr.arc(rand(ext[2]),rand(ext[3]),rand(20),0,2*Math::PI)
cr.fill
end
end
end
class RubyApp < Gtk::Window
def initialize
super
set_title "leak test"
set_size_request 1000, 600
set_window_position Gtk::Window::POS_CENTER
@cur_value = 0
vbox = Gtk::VBox.new false, 2
#set_motion_notify_event
@draw_thing = DrawThing.new(self)
vbox.pack_start @draw_thing
 
#set_events()
signal_connect "destroy" do
Gtk.main_quit
end
#gtk.gdk.ALL_EVENTS_MASK
add vbox
show_all
end
 
 
end
Gtk.init
window = RubyApp.new
Gtk.main

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.