Murga-Projects Forums

Full Version: Drawing pixel to window
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

what is the easiest way to set pixel inside a window ?
I'd like to open a window and set pixels:

Code:
version="0.0001a"
window = fltk:Fl_Double_Window(100,64,"displaycc");
window:tooltip("pbLua displaycc by Chrimo and friends "..version);
window:color(55);
window:align(fltk.FL_ALIGN_CENTER);
window:position(10,10);

-- fltk.fl_draw("???",x,y)

function quit_callback(object)
        if fltk.fl_ask("Are you sure to quit now ?") >= 1 then
                window:hide()
        end
end

window:callback(quit_callback)

window:show();
Fl:run();


Nothing happens... ;-(
Is fl_draw the right function to set pixels ??? I'd like to draw something like trigonometric functions or some kind of mathematic function plotter...
I'm using murgaLua 0.5.5 at OSX (PPC)

Thanks for some hints or ideas to make it better
Bye
Christian

use this for per pixel drawing

Code:
fltk.fl_point(intx,inty)


use this for big fat 'pixel' boxes

Code:
fltk.fl_rectf(intx1,inty1,intx2,inty2)


Download a fairly full feature graphics function demo from this thread

FLTK docs on the graphics converted to real murga commands

Hi iGame3D,

I'm so sorry :-(
Sometimes I mix pbLua and murgaLua, cannot find the tree in the forrest,
smoking inexpensive shit, setting white pixels on white screen....

Thanks for wake me up
Bye
Christian


iGame3D Wrote:
use this for per pixel drawing

Code:
fltk.fl_point(intx,inty)


use this for big fat 'pixel' boxes

Code:
fltk.fl_rectf(intx1,inty1,intx2,inty2)


Download a fairly full feature graphics function demo from this thread

FLTK docs on the graphics converted to real murga commands

Hi,
yes I'm smoking again...
but where are the pixels ?

Code:
version="0.001";    
w = fltk:Fl_Double_Window(500,500,"Pixeltest mLua 0.5.5 OSX PPC");
w:tooltip("Pixeltest "..version);
w:color(55);
w:align(fltk.FL_ALIGN_CENTER);
w:position(10,10);


b=fltk:Fl_Button(200,450,100,40,"Show")
b:color(31);

function show()
    for x=0,500 do
        y=x;
        print("X:"..x.." Y:"..y);
        fltk.fl_color(79);
        fltk.fl_point(x,y);
        fltk.fl_rectf(x,y,10,10);
    end
end

function show_callback(object)
    show();
    w:show();
end


function quit_callback(object)
    if fltk.fl_ask("Are you sure to quit now ?") >= 1 then
        window:hide()
    end
end

b:callback(show_callback)
w:callback(quit_callback)
w:show();
Fl:run();


Thanks for any idea
Bye
Christian

Took me a minute or two, but the trick is in here

Code:
function show_callback(object)
w:make_current() -- says 'whats this?' in my demo--but it is THE MAGIC!
    show();
    --w:show();  -- not sure if this is needed commenting it doesn't hurt anything
end


Kindly pass the hookah'pon'the left hand side.

iGame3D,
I had a similar effect with subwindows at OSX and murgaLua 0.4 ;-(
Win32 XP works, OSX not!

Big Grin
Christian


iGame3D Wrote:
Took me a minute or two, but the trick is in here

Code:
function show_callback(object)
w:make_current() -- says 'whats this?' in my demo--but it is THE MAGIC!
    show();
    --w:show();  -- not sure if this is needed commenting it doesn't hurt anything
end


Kindly pass the hookah'pon'the left hand side.

yep it was your thread where I got that w:make_current() function from.
Just didn't know what it does exactly, I assume point fltk to the correct window.

chrimo Wrote:
iGame3D,
I had a similar effect with subwindows at OSX and murgaLua 0.4 ;-(
Win32 XP works, OSX not!


Known bug on Mac FLTK apparently, I think it's fixed in the latest snapshot (which will be used in the next murgaLua).

Cheers
JohnM

Hi,
does it mean, it is a general problem with fl_point(x,y) at any OS or just OSX ?

Bye
Christian

JohnMurga Wrote:

chrimo Wrote:
iGame3D,
I had a similar effect with subwindows at OSX and murgaLua 0.4 ;-(
Win32 XP works, OSX not!


Known bug on Mac FLTK apparently, I think it's fixed in the latest snapshot (which will be used in the next murgaLua).

Cheers
JohnM

Forget all I said before ;-(

This works fine at OSX Intel:

Code:
version="0.001";    
w = fltk:Fl_Double_Window(500,500,"Display Pixel murgaLua 0.5.5 OSX PPC");
w:tooltip("Pixeltest "..version);
w:color(55);
w:align(fltk.FL_ALIGN_CENTER);
w:position(10,10);


b=fltk:Fl_Button(200,450,100,40,"Display")
b:color(31);

function show()
    for x=0,500 do
        y=x;
        print("X:"..x.." Y:"..y);
        fltk.fl_color(0);
        fltk.fl_point(x,y);
        --fltk.fl_rectf(x,y,10,10);
        
    end
end

function show_callback(object)
    w:make_current();
    show();
end


function quit_callback(object)
    if fltk.fl_ask("Are you sure to quit now ?") >= 1 then
        window:hide()
    end
end

b:callback(show_callback)
w:callback(quit_callback)
w:show();
Fl:run();


Cheers
Christian

Pages: 1 2
Reference URL's