News : The level of daily SPAM has reached insane proportions, all registrations are now manual. I ask you to send me an e-mail (john (at) murga (dot) org), to confirm that you want me to create an account for you.


Post Reply  Post Thread 
Pages (2): « First [1] 2 Next > Last »
Drawing pixel to window
Author Message
chrimo
Member
***


Posts: 94
Group: Registered
Joined: May 2007
Status: Offline
Reputation: 0
Post: #1
Drawing pixel to window

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

This post was last modified: 08-12-2007 06:44 AM by chrimo.

08-12-2007 06:43 AM
Find all posts by this user Quote this message in a reply
iGame3D
Moderator
***


Posts: 231
Group: Moderators
Joined: Apr 2007
Status: Offline
Reputation: 0
Post: #2
RE: Drawing pixel to window

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

This post was last modified: 08-12-2007 08:58 AM by iGame3D.

08-12-2007 08:38 AM
Visit this user's website Find all posts by this user Quote this message in a reply
chrimo
Member
***


Posts: 94
Group: Registered
Joined: May 2007
Status: Offline
Reputation: 0
Post: #3
RE: Drawing pixel to window

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

08-12-2007 09:13 AM
Find all posts by this user Quote this message in a reply
chrimo
Member
***


Posts: 94
Group: Registered
Joined: May 2007
Status: Offline
Reputation: 0
Post: #4
RE: Drawing pixel to window

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

08-12-2007 10:38 AM
Find all posts by this user Quote this message in a reply
iGame3D
Moderator
***


Posts: 231
Group: Moderators
Joined: Apr 2007
Status: Offline
Reputation: 0
Post: #5
RE: Drawing pixel to window

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.

08-12-2007 10:52 AM
Visit this user's website Find all posts by this user Quote this message in a reply
chrimo
Member
***


Posts: 94
Group: Registered
Joined: May 2007
Status: Offline
Reputation: 0
Post: #6
RE: Drawing pixel to window

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.

08-12-2007 11:00 AM
Find all posts by this user Quote this message in a reply
iGame3D
Moderator
***


Posts: 231
Group: Moderators
Joined: Apr 2007
Status: Offline
Reputation: 0
Post: #7
RE: Drawing pixel to window

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.

08-12-2007 01:16 PM
Visit this user's website Find all posts by this user Quote this message in a reply
JohnMurga
Administrator
*******


Posts: 381
Group: Administrators
Joined: Apr 2007
Status: Offline
Reputation: 2
Post: #8
RE: Drawing pixel to 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

08-12-2007 10:15 PM
Visit this user's website Find all posts by this user Quote this message in a reply
chrimo
Member
***


Posts: 94
Group: Registered
Joined: May 2007
Status: Offline
Reputation: 0
Post: #9
RE: Drawing pixel to window

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

08-13-2007 12:33 AM
Find all posts by this user Quote this message in a reply
chrimo
Member
***


Posts: 94
Group: Registered
Joined: May 2007
Status: Offline
Reputation: 0
Post: #10
RE: Drawing pixel to window

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

08-13-2007 02:07 AM
Find all posts by this user Quote this message in a reply
Pages (2): « First [1] 2 Next > Last »
Post Reply  Post Thread 

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites

Forum Jump: