开发者

How to use drawText on FXCanvas in FXRuby?

开发者 https://www.devze.com 2023-01-25 09:26 出处:网络
I am trying to make text appear on a FXCanvas. when I use this code: def 开发者_如何学Pythonscore_box(event)

I am trying to make text appear on a FXCanvas. when I use this code:

def 开发者_如何学Pythonscore_box(event)
FXDCWindow.new(@canvas) do |dc|

    dc.drawText(640, 450, @score)
end     
end  

but it gives me an error saying I need to select a font, how do I do this? or could you provide anyway to make text on a canvas? Thanks

-bipolarpants


You need to select an FXFont object into the device context (dc), e.g.

FXDCWindow.new(@canvas) do |dc|
  font = FXFont.new(...)
  font.create
  dc.font = font
  dc.drawText(640, 450, @score)
end
0

精彩评论

暂无评论...
验证码 换一张
取 消