[wxruby-users] Transparent line in Frame

Andreas Warberg lists at ruby-forum.com
Mon Apr 21 10:20:40 EDT 2008


Alex Fenton wrote:
> The standard DC doesn't support transparency (except on OS X I think).
> But you can instead use wxGraphicsContext which fully supports
> transparency, antialiasing and other advanced drawing tools like splines
> and transforms. You create one from an ordinary DC like this:
> 
> paint.do | dc |
>   gdc = Wx::GraphicsContext.create(dc)
>   gdc.stroke_line(0, 0, 500, 500)
>   # etc
> end

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.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? :)

Andreas
-- 
Posted via http://www.ruby-forum.com/.


More information about the wxruby-users mailing list