[wxruby-users] Transparent line in Frame

Alex Fenton alex at pressure.to
Mon Apr 21 10:34:41 EDT 2008


Andreas Warberg wrote:
> Thanks! I'm having a bit of trouble, though. Here is a small example I 
> use:
>
> require 'wx'
> include Wx
>
> App.run do
>   frame = Frame.new(nil, :title => 'GraphicsContext example', :width => 
> [300,400])
>
>   frame.evt_paint do
>     frame.paint do |dc|
>       gdc = GraphicsContext.create(dc)
>       siz = dc.size
>       h, w = siz.height, siz.width
>       #dc.draw_line(0,0,w,h)
>   
      gdc.pen = Wx::Pen.new( Wx::Colour.new(255, 0, 0, 128), 20)
>       gdc.stroke_line(0,0,w,h)
>     end
>   end
>
>   frame.show
> end
>
> It should draw / stroke a diagonal line in the frame. This works if I 
> use draw_line.
>
> What am I missing? :)

It seems with GraphicsContext, you need to set some sort of pen before 
starting drawing - there is no default pen when it's first created.

alex




More information about the wxruby-users mailing list