Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Just a curious question

Status
Not open for further replies.

qbasicking

Programmer
Aug 19, 2001
628
US
how does Qbasic determine how to place a dotted line on the screen. I mean, how does it get putting a dot every two pixils out of &H5555 and one out of every three for &H2222? I changed it to decimal and binary, but i see no pattern
 
I found this in my archives (without notes -- shame on me)and hope it may be of use to you. Please keep in mind that it uses screen 13, but should work well with whatever screen you want.

[tt]
'--Ref: use of LINE function
SCREEN 13
COLOR 2
FOR BackDropY = 0 TO 100
FOR BackDropX = 0 TO 100
PSET (BackDropX, BackDropY), 14
NEXT BackDropX, BackDropY

LeftMarg = 10
TopMarg = 2

LINE (LeftMarg, TopMarg)-STEP(0, 100), 0 'show left margin

FOR Cycle = 0 TO 15
LINE (LeftMarg, TopMarg)-STEP([red]16[/red], 0), 1, , Cycle
TopMarg = TopMarg + 3
SLEEP 1
NEXT
'END

TopMarg = TopMarg + 3
LINE (LeftMarg, TopMarg)-STEP(16, 0), 3, , [red]&H1F[/red]
TopMarg = TopMarg + 1
LINE (LeftMarg, TopMarg)-STEP(16, 0), 1, , &H10
'--notice that 0 is a place holder to make #1
' the significant bit?

TopMarg = TopMarg + 1
LINE (LeftMarg, TopMarg)-STEP(16, 0), 1, , &HF
'--notice that F is preceeded by imaginary 000.

'--this is your examples from above.

TopMarg = TopMarg + 3
LINE (LeftMarg, TopMarg)-STEP(16, 0), 3, , &H2222
TopMarg = TopMarg + 1
LINE (LeftMarg, TopMarg)-STEP(16, 0), 1, , &H2000
TopMarg = TopMarg + 1
LINE (LeftMarg, TopMarg)-STEP(16, 0), 1, , &H200
TopMarg = TopMarg + 1
LINE (LeftMarg, TopMarg)-STEP(16, 0), 1, , &H20
TopMarg = TopMarg + 1
LINE (LeftMarg, TopMarg)-STEP(16, 0), 1, , &H2

TopMarg = TopMarg + 3
LINE (LeftMarg, TopMarg)-STEP(16, 0), 3, , &H5555
TopMarg = TopMarg + 1
LINE (LeftMarg, TopMarg)-STEP(16, 0), 1, , &H5000
TopMarg = TopMarg + 1
LINE (LeftMarg, TopMarg)-STEP(16, 0), 1, , &H500
TopMarg = TopMarg + 1
LINE (LeftMarg, TopMarg)-STEP(16, 0), 1, , &H50
TopMarg = TopMarg + 1
LINE (LeftMarg, TopMarg)-STEP(16, 0), 1, , &H5
[/tt]

Based on the workings, it uses 4-16 bits to draw the line. But, I never tested it to check on the vertical, only horizontal. Anyways, hope this helps you.
--MiggyD
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top