LB Booster
« Graphics: White on Black »

Welcome Guest. Please Login or Register.
Apr 1st, 2018, 04:23am



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Speed up Liberty BASIC programs by up to ten times!
Compile Liberty BASIC programs to compact, standalone executables!
Overcome many of Liberty BASIC's bugs and limitations!
LB Booster Resources
LB Booster documentation
LB Booster Home Page
LB Booster technical Wiki
Just BASIC forum
BBC BASIC Home Page
Liberty BASIC forum (the original)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Graphics: White on Black  (Read 511 times)
datwill
Guest
xx Graphics: White on Black
« Thread started on: Apr 26th, 2015, 4:16pm »

I seem to be having this problem where I try to draw white text on a black background. It makes white rectangles and resembles nothing of text at all. Do you know what the problem is?
EDIT: I'm using LBB v.3
EDIT: Here's some example code, trying to keep as best I can to the conditions of the time I found this when I came across it while coding my computer game:

Code:
nomainwin
WindowWidth = DisplayWidth: WindowHeight = DisplayHeight
open "test" for graphics_nf_nsb as #main
#main "trapclose [quit] ; color white ; font geogia italic 10 ; fill black ; home ; down"
#main "\testing text"
wait

[quit]
#main "cls": close #main 
« Last Edit: Apr 26th, 2015, 4:23pm by datwill » User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Graphics: White on Black
« Reply #1 on: Apr 26th, 2015, 4:32pm »

on Apr 26th, 2015, 4:16pm, Daniel Atwill wrote:
I seem to be having this problem where I try to draw white text on a black background. It makes white rectangles and resembles nothing of text at all. Do you know what the problem is?

It's impossible even to guess what the problem might be without seeing some code! A trivial example of white text on a black background works OK here:

Code:
    open "Test" for graphics as #w
    #w "backcolor black; color white"
    #w "\\This is some text"
    wait 

It's perhaps worth noting that in LBB (and in LB 4.5 when it is released) you can also create white-on-black text in a texteditor:

Code:
    open "Test" for text as #w
    #w "!backcolor black"
    #w "!forecolor white"
    #w "This is some text"
    wait 
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Graphics: White on Black
« Reply #2 on: Apr 26th, 2015, 5:27pm »

on Apr 26th, 2015, 4:16pm, Daniel Atwill wrote:
EDIT: Here's some example code

There's no backcolor command, so you're drawing white-on-white text!

Richard.
User IP Logged

datwill
Guest
xx Re: Graphics: White on Black
« Reply #3 on: Apr 26th, 2015, 7:56pm »

OH grin grin silly me! rolleyes
User IP Logged

datwill
Guest
xx Re: Graphics: White on Black
« Reply #4 on: Apr 26th, 2015, 8:14pm »

Thanks for the text thing, but I'm still having trouble. One with the timer statement in LBB, and a scrolling text issue...
OK, I have some code that's directly from my game. What I want to do is make a "poem" (yeah, it's not that good ::) and don't take any notice of it's contents ;D), scroll form bottom to top, beginning off the screen beyond the bottom, all the way off the top. But something's DEFINITELY not right! Here's some edited code from my game, adding a few lines to make it work. This happens once you wish to play the game with the selected file. It waits for 5 seconds (which it is - good) then begins the scrolling, but the poem suddenly appears near the TOP of the screen :-/ I've notice an issue with the timer statement trying to use it in my progammes, it doesn't time right:
Code:
WindowWidth = DisplayWidth: WindowHeight = DisplayHeight
nomainwin: open "test" for graphics_nf_nsb as #main
#main "trapclose [quit] ; cls ; fill black ; backcolor black ; color white ; font georgia italic 10"
timer 5000, [startToScroll] 'This is actually 5 seconds...
wait
[continueAfterTimer]
timer 1, [startToScroll] '... YET THIS IS SUPPOSED TO BE A MILISECOND (not what I will use in the actual game), BUT LOOK AT HOW SLOW IT IS!
originalTextPos = DisplayHeight+751
[startToScroll]
originalTextPos -= 5
#main "cls ; fill black ; place 400 ";originalTextPos
#main "\There was once a guardian,"
#main "place 400 ";originalTextPos+15
#main "\Who was once the best of them all,"
#main "place 400 ";originalTextPos+30
#main "\But his gigantic pride,"
#main "place 400 ";originalTextPos+45
#main "\Lead to his downfall."
#main "place 400 ";originalTextPos+70
#main "\he formed a rebel group of other guardians,"
#main "place 400 ";originalTextPos+85
#main "\About a third of the whole population,"
#main "place 400 ";originalTextPos+100
#main "\Which turned against their Master,"
#main "place 400 ";originalTextPos+115
#main "\The very One which gave them their damnation."
#main "place 400 ";originalTextPos+140
#main "\Although He was angry against His rebel servants,"
#main "place 400 ";originalTextPos+155
#main "\He did not let this blind Him of the true prize,"
#main "place 400 ";originalTextPos+180
#main "\For, after six lights and darks,"
#main "place 400 ";originalTextPos+195
#main "\Once his eyes were opened, he made his rise -"
#main "place 400 ";originalTextPos+220
#main "\From the dust, you awake,"
#main "place 400 ";originalTextPos+235
#main "\To find you're in a flower bed,"
#main "place 400 ";originalTextPos+250
#main "\And what you saw was good, as He proclaimed,"
#main "place 400 ";originalTextPos+265
#main "\So you made a decision, to make the first tred..."
if originalTextPos = -325 then timer 0: goto [afterSequence]
wait

[quit]
#main "cls": close #main: end 

There must be something wrong.
User IP Logged

datwill
Guest
xx Re: Graphics: White on Black
« Reply #5 on: Apr 26th, 2015, 8:25pm »

I have found a problem, but don't know what's happening undecided

originalTextPos -= 5 'after [startToScroll]

This isn't taking away 5, it's ASSIGNING -5 to the variable! I found this out with the debugger. I tried the extended version:

originalTextPos = originalTextPos - 5

But is still assigning -5 for some reason.
« Last Edit: Apr 26th, 2015, 8:26pm by datwill » User IP Logged

tsh73
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 210
xx Re: Graphics: White on Black
« Reply #6 on: Apr 26th, 2015, 9:20pm »

No, that's all problems in program logic.
Code:
WindowWidth = DisplayWidth: WindowHeight = DisplayHeight
nomainwin: open "test" for graphics_nf_nsb as #main
#main "trapclose [quit] ; cls ; fill black ; backcolor black ; color white ; font georgia italic 10"
timer 5000, [continueAfterTimer]
 'This is actually 5 seconds...
'originalTextPos = DisplayHeight+751 'why?
originalTextPos = DisplayHeight

wait
[continueAfterTimer]
timer 1, [startToScroll] '... YET THIS IS SUPPOSED TO BE A MILISECOND (not what I will use in the actual game), BUT LOOK AT HOW SLOW IT IS!
wait
[startToScroll]
originalTextPos -= 5
#main "cls ; fill black ; place 400 ";originalTextPos
#main "place 40 40" 
#main "\";originalTextPos

#main "place 400 ";originalTextPos
#main "\There was once a guardian,"
#main "place 400 ";originalTextPos+15
#main "\Who was once the best of them all,"
#main "place 400 ";originalTextPos+30
#main "\But his gigantic pride,"
#main "place 400 ";originalTextPos+45
#main "\Lead to his downfall."
#main "place 400 ";originalTextPos+70
#main "\he formed a rebel group of other guardians,"
#main "place 400 ";originalTextPos+85
#main "\About a third of the whole population,"
#main "place 400 ";originalTextPos+100
#main "\Which turned against their Master,"
#main "place 400 ";originalTextPos+115
#main "\The very One which gave them their damnation."
#main "place 400 ";originalTextPos+140
#main "\Although He was angry against His rebel servants,"
#main "place 400 ";originalTextPos+155
#main "\He did not let this blind Him of the true prize,"
#main "place 400 ";originalTextPos+180
#main "\For, after six lights and darks,"
#main "place 400 ";originalTextPos+195
#main "\Once his eyes were opened, he made his rise -"
#main "place 400 ";originalTextPos+220
#main "\From the dust, you awake,"
#main "place 400 ";originalTextPos+235
#main "\To find you're in a flower bed,"
#main "place 400 ";originalTextPos+250
#main "\And what you saw was good, as He proclaimed,"
#main "place 400 ";originalTextPos+265
#main "\So you made a decision, to make the first tred..."
if originalTextPos < -325 then timer 0: goto [afterSequence]
wait

[quit]
#main "cls": close #main: end  


EDIT RE: 1ms
windows might support bigger time chunks. For XP it is 16 ms - it will do 16 even if you ask for 1
« Last Edit: Apr 26th, 2015, 9:22pm by tsh73 » User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Graphics: White on Black
« Reply #7 on: Apr 26th, 2015, 9:24pm »

on Apr 26th, 2015, 8:25pm, Daniel Atwill wrote:
This isn't taking away 5, it's ASSIGNING -5 to the variable! I found this out with the debugger.

I cannot reproduce that. I commented out the NOMAINWIN and added a diagnostic PRINT statement here:

Code:
originalTextPos -= 5
print originalTextPos ' debug 

This is what I get in the mainwin (a new number is printed every 5 seconds as expected):

Code:
-5
-10
-15
-20
-25 

So, here at least, it is definitely subtracting 5, not assigning -5. If you are seeing something different, I do not understand it.

Richard.
User IP Logged

datwill
Guest
xx Re: Graphics: White on Black
« Reply #8 on: Apr 27th, 2015, 08:53am »

tsh73
I assigned the originalTextPos to be greater than the DisplayHeight because doesn't, with text, the coordinates given relate to the LL corner of the block of text? If this is true, assigning the variable DisplayHeight, the first line will just appear at the bottom of the screen and not scroll on, not really what I want. But it is true that I shouldn't be adding 700 odd (why did I do that? undecided), I only need to add 15. Thank you for pointing that out.
I tried typing 1ms as the amount of time and LBB came up witht a syntax error sad. The time is more like a second...

Richard
That is true that it's taking away 5, but for some reason, after testing my programme out AGAIN after tsh73's advice about the DisplayHeight thing, it STILL comes out as -5. How is
originalTextPos = DisplayHeight+15
the same as
originalTextPos = -5
sad sad sad Me don't get...
« Last Edit: Apr 27th, 2015, 08:54am by datwill » User IP Logged

tsh73
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 210
xx Re: Graphics: White on Black
« Reply #9 on: Apr 27th, 2015, 09:02am »

Daniel,
my advice was not about "DisplayHeight thing"

Run code from my post.
See how fast ot scrolls.

Pay attention to timer labels - there was error in program flow
(and I think originalTextPos cames as -5 not because it gets assigned, but rather because it wasn't assigned before: so it had value 0, and -=5 just decreased it to -5 (as should)
And it was not assigned again because of wrong program logic: it just never executes line
Code:
originalTextPos = DisplayHeight+751 

)
« Last Edit: Apr 27th, 2015, 09:03am by tsh73 » User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Graphics: White on Black
« Reply #10 on: Apr 27th, 2015, 09:51am »

While you're making changes, please correct the spelling!

Code:
#main "\Lead to his downfall." 

My three top hates:
  • Writing it's when it should be its.
  • Writing loose when it should be lose.
  • Writing lead when it should be led.
You might also want to consider putting the text strings in DATA statements and reading them in a loop, which is more efficient and easier to change (for example if you wanted to alter the line spacing).

Richard.
User IP Logged

datwill
Guest
xx Re: Graphics: White on Black
« Reply #11 on: Apr 27th, 2015, 11:03am »

Thank you Richard and tsh73, I've figured out that the code flow went to the wrong branch label (skipping the variable declaration so it equalled 0 when i took 5 from it resulting in -5) once the 5 seconds were up! and no wonder it was slow because the timer was 5000ms not 1ms! smiley smiley
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls