Re: [Fxruby-users] hard time using images (thank you)
Status: Inactive
Brought to you by:
lyle
From: Andre' W. <an...@sy...> - 2004-07-07 20:59:08
|
Thank you so much for everyone's help, I couldn't do without you! Someday someone has to write a tutorial on that. (maybe I will, if ever got some experience) So here is my final code. Any hints on optimization would be appreciated. require 'fox' include Fox class Test def initialize app =3D FXApp.new main_window =3D FXMainWindow.new(app, "test", nil, nil, D= ECOR_ALL, 500, 330, 540, 370) # Canvas & image canvas =3D FXCanvas.new(main_window, nil, 0, LAYOUT_FIX_W= IDTH|LAYOUT_FIX_HEIGHT, 0, 0, 30, 30) @buffer =3D FXImage.new(app, nil, IMAGE_KEEP) @buffer.create canvas.connect(SEL_PAINT) { |sender, sel, evt|=20 FXDCWindow.new(sender, evt) { |dc| dc.drawImage(@buffer, 0, 0) } } canvas.connect(SEL_CONFIGURE) { |sender, sel, evt| @buffer.create unless @buffer.created? @buffer.resize(sender.width, sender.height) draw } app.create main_window.show # sets the pixel setPixel(10, 10, FXRGB(0,0,0)) =20 app.run =20 end def draw FXDCWindow.new(@buffer) { |dc| dc.setForeground(FXRGB(255, 255, 255)) dc.fillRectangle(0, 0, @buffer.width, @buffer.hei= ght) } end def setPixel(x, y, color) FXDCWindow.new(@buffer) { |dc| dc.foreground =3D color dc.drawPoint(x, y) } end end t =3D Test.new Regards to all, Andr=E9 --=20 =A9 Andre' Wagner - 2004 - All rights reserved |