Page 1 of 1
Need Help in PB
Posted: Mon Jun 30, 2003 12:45 pm
by SeeD
Code: Select all
If OpenWindow(1, 100, 200, 300, 200, #PB_Window_SystemMenu, "abc")
If CreateImage (1, 100, 100 )
If StartDrawing(ImageOutput())
BackColor (128, 8, 128) ; purple
Box(10,10,20,20)
StopDrawing()
EndIf
EndIf
EndIf
how am i gonna do it so the PB will open a the program ??
i've compiled it and nothing come out ...
almost all the copy from the example source ~~
Posted: Mon Jun 30, 2003 2:09 pm
by GedB
SeeD,
There are two problems with your code.
First problem is that your window does not include the event loop.
This means that you are creating a window, and then your program ends. The window is then automatically destroyed.
Because PB is so lightening fast, you don't get to see a thing.
You need to put in a loop (doing the same thing over and over again) until the user closes the window.
like this:
Code: Select all
If OpenWindow(1, 100, 200, 300, 200, #PB_Window_SystemMenu, "abc")
If StartDrawing(WindowOutput())
BackColor (128, 8, 128) ; purple
Box(10,10,20,20)
StopDrawing()
EndIf
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
The second problem is that you are drawing onto an image. An image is an invisible thing that you use in the background, the user cannot see it.
If you want immediate results for your drawing, you should draw onto the window canvas direct (as above). If you do want to use a 'back' image first then you have to remember to draw it to the window when you've finished, otherwise it won't be seen.
Posted: Mon Jun 30, 2003 3:41 pm
by SeeD
i got the 1 mistake smoothly ...
but 2nd mistake is the problem ...
if its a invisible thing in the background ... then how are we gonna edit it ??
------
another problem ...
i can't put the colors in the box or something ...
nvm ... i've know how to put the colors ...
ekek ...
now its the image thingie ~~

please explain ...
Posted: Mon Jun 30, 2003 4:56 pm
by GedB
Take a look at Image.pb in the examples directory.
Posted: Tue Jul 01, 2003 11:19 am
by SeeD
what code should i write to move the circle aside so i can see both the rectangular and the circle ??
Code: Select all
If OpenWindow(1, 100, 200, 300, 200, #PB_Window_SystemMenu, "abc")
If StartDrawing(WindowOutput())
Box(20,20,30,60,RGB (12, 200, 80))
Circle (40, 100, 70,RGB(240, 100, 50))
FrontColor(255,0,0) ; Finally, red lines..
For k=0 To 20
Linexy(120,1+k*15,180, 100)
Next
StopDrawing()
EndIf
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
i've used locate ... but i don't know where to put locate or its not the code ...
please help

Posted: Tue Jul 01, 2003 11:57 am
by LarsG
You might want to do something like this:
Code: Select all
If OpenWindow(1, 100, 200, 300, 200, #PB_Window_SystemMenu, "abc")
If StartDrawing(WindowOutput())
Box(20,20,30,60,RGB (12, 200, 80))
Circle (130, 100, 70,RGB(240, 100, 50))
FrontColor(255,0,0) ; Finally, red lines..
For k=0 To 20
LineXY(260,1+k*15,210, 100)
Next
StopDrawing()
EndIf
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
You only use locate in conjuction with drawing text on the screen..
When you want to move graphics, you just adjust the x and y parametres..
(try hitting F1 when the cursor is on a graphics command, like "circle")
-Lars
Posted: Sun Jul 06, 2003 3:45 am
by SeeD
yea ... thanks alot LarsG
yea ... i've tried reading the manual ...
but sometimes dun understand em ~~