From: brabuhr@... Date: 2009-12-05T02:22:00+09:00 Subject: Re: Graphics mode again On Fri, Dec 4, 2009 at 12:11 PM, Teodor Carstea wrote: > to unknown (Guest) > > yeah! THANKS! By the way, I've made several tests, you don't need x2 and > y2 at all to draw a single ball. > > And... err.. I think there IS something like "repaint", because the > clock moves its pointers, example:they dissappear at 12:00 mark and > appear at 12:01. I'll find it. I'll be looking for more documentation > upon this. > > thanks again! Sure. Here's a bit better example, I think: gnome_canvas_ball.rb require 'gnomecanvas2' class GnomeCanvasBall def initialize(canvas, x, y, radius) @canvas, @x, @y, @radius = canvas, x, y, radius @ellipse = Gnome::CanvasEllipse.new( @canvas.root, { :x1 => @x - @radius, :y1 => @y - @radius, :x2 => @x + @radius, :y2 => @y + @radius, :fill_color => "white", :outline_color => "steelblue", :width_pixels => 1 } ) end def show; @ellipse.show; end def hide; @ellipse.hide; end def x=(val) @x = val @ellipse.x1 = @x - @radius @ellipse.x2 = @x + @radius end def y=(val) @y = val @ellipse.y1 = @y - @radius @ellipse.y2 = @y + @radius end end foozle.rb require 'gnome_canvas_ball' class Foozle < Gtk::Window def initialize super @canvas = Gnome::Canvas.new(true) @foozle = GnomeCanvasBall.new( @canvas, 50, 50, 10 ) @canvas.show add(@canvas) signal_connect_after('show') { start } signal_connect_after('hide') { stop } signal_connect("delete_event") { Gtk::main_quit } end def start @tid= Gtk::timeout_add(1000) { @foozle.x = rand(100) @foozle.y = rand(100) true } end def stop Gtk::timeout_remove(@tid) if @tid; @tid = nil end end Gtk.init(); Foozle.new.show; Gtk.main()