Murga-Projects Forums
Drawing pixel to window - Printable Version

+- Murga-Projects Forums (http://www.murga-projects.com/forum)
+-- Forum: Project Forums (/forumdisplay.php?fid=1)
+--- Forum: MurgaLua - General (/forumdisplay.php?fid=2)
+--- Thread: Drawing pixel to window (/showthread.php?tid=169)


Drawing pixel to window - chrimo - 08-12-2007 06:43 AM

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


RE: Drawing pixel to window - iGame3D - 08-12-2007 08:38 AM

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


RE: Drawing pixel to window - chrimo - 08-12-2007 09:13 AM

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




RE: Drawing pixel to window - chrimo - 08-12-2007 10:38 AM

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


RE: Drawing pixel to window - iGame3D - 08-12-2007 10:52 AM

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.


RE: Drawing pixel to window - chrimo - 08-12-2007 11:00 AM

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.




RE: Drawing pixel to window - iGame3D - 08-12-2007 01:16 PM

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.


RE: Drawing pixel to window - JohnMurga - 08-12-2007 10:15 PM

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


RE: Drawing pixel to window - chrimo - 08-13-2007 12:33 AM

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




RE: Drawing pixel to window - chrimo - 08-13-2007 02:07 AM

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


RE: Drawing pixel to window - JohnMurga - 08-13-2007 04:47 AM

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


No, there is a bug with sub windows on OSX ...

I think, I can't test it ...

Cheers
JohnM


RE: Drawing pixel to window - chrimo - 08-13-2007 07:27 AM

JohnMurga Wrote:

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


No, there is a bug with sub windows on OSX ...

I think, I can't test it ...

Cheers
JohnM


Hi John,
I think, I can test it Big Grin

And now as a result of your very excelent support, the Lego Mindstorms NXT Roboter Display Hardcopy Tool, written in murgaLua Big Grin
Usage:
Robot reads own displaybuffers and create murgaLua-code, transfer it to PC and result can be called my murgaLua...

http://nxt.moccy.dyndns.org/pbLuaHardCopy.png
http://nxt.moccy.dyndns.org/GPS.png

Thanks to ALL
Bye
Christian


RE: Drawing pixel to window - iGame3D - 08-13-2007 07:42 PM

How does the legobot send the data to the computer?
Can your app talk to this basic kit


RE: Drawing pixel to window - chrimo - 08-13-2007 09:14 PM

Hi,

YES! But I use pbLua at this device as alternate operating system

The NXT can send data via Bluetooth or USB...
The Mac/PC communicates by serial profile with the NXT pbLuaConsole.
Cool piece of hardware to waste my sparetime Big Grin

Bye
Christian

At the beginning of the year, I started a simple Mac/PC simulation of core basics for the NXT written in murgaLua...
Give me some more time to port it to murgaLua 0.5.5 Big Grin