I’m doing some experiments with the ScreenDC class for on-screen
drawing. Drawing shapes like a circle or rectangle works fine, but when
I try to draw text onto the screen, nothing happens. I’m using the
wxruby-ruby19 gem with ruby 1.9.1p243 (2009-07-16 revision 24175)
[i686-linux] on an Ubuntu Karmic machine.
My code looks like this (I know, it doesn’t make much sense, but it’s
only to demonstrate the problem):
#!/usr/bin/env ruby #Encoding: UTF-8
require “wx”
class TestApp < Wx::App
include Wx
def on_init
Timer.every(1000) do
sc = ScreenDC.new
sc.font = NORMAL_FONT #To ensure there's a font to draw with
sc.draw_rectangle(0, 0, 100, 100) #This gets drawn...
sc.draw_text("Test", 0, 150) #...but this doesn't
end
end
end
x = TestApp.new
x.main_loop
The rectangle is drawn without problems, but I can’t find the text
anywhere on my screen.
I’m doing some experiments with the ScreenDC class for on-screen
drawing. Drawing shapes like a circle or rectangle works fine, but when
I try to draw text onto the screen, nothing happens. I’m using the
wxruby-ruby19 gem with ruby 1.9.1p243 (2009-07-16 revision 24175)
[i686-linux] on an Ubuntu Karmic machine.
My code looks like this
…
sc.draw_text("Test", 0, 150) #...but this doesn't
I got round to trying your sample, running it with a debug build on Mac.
The line above is causing an assertion in Wx to fail, and then a crash.
The message I get is rather cryptic,:
But I’m not sure if this is because ScreenDC doesn’t work properly on
Mac, or if there’s something else wrong with the usage. I’ve never tried
drawing directly on the screen.
sorry i can’t be more hlepful
alex
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.