Line (Graphics) B/BF question [RESOLVED]

New to FreeBASIC? Post your questions here.
Post Reply
bethell
Posts: 44
Joined: Sep 26, 2009 22:02

Line (Graphics) B/BF question [RESOLVED]

Post by bethell »

Hi,

In the Line (graphiics) command, what is B (or BF) - a number or a string ?

I need to draw a filled box if a condition is true, and an empty box if false.

Example:
'----------------------
dim as string btype;

if(condition =0) then
btype = "B"
else
btype= "BF"
endif

Line (15,15)- step(100, 100), RGB(70,70,70), btype
'------------------------
The above gives an error .

Is there no way but to write the entire line command twice- once with B and once with BF ?

Thanks !
Last edited by bethell on Dec 21, 2009 4:53, edited 1 time in total.
roook_ph
Posts: 402
Joined: Apr 01, 2006 20:50
Location: philippines
Contact:

Post by roook_ph »

B And BF are compiler constants, I think and cannot be used with variables but there are a lot of workaround to this simple routine.
MichaelW
Posts: 3500
Joined: May 16, 2006 22:34
Location: USA

Post by MichaelW »

Is there no way but to write the entire line command twice- once with B and once with BF ?
There is no way that I know of. And even if it were possible, writing it twice:

Code: Select all

if (condition = 0) then
    Line (15,15)- step(100, 100), RGB(70,70,70), B
else
    Line (15,15)- step(100, 100), RGB(70,70,70), BF
end if
Would require only a little more typing, and the code would be clearer and easier to understand and it would execute a little faster.
bethell
Posts: 44
Joined: Sep 26, 2009 22:02

Post by bethell »

Thanks, Michael,

Actually, there are 22 'line' statements in my function :P

I want to save a portion of my screen as a bmp in black & white (not even grayscale), for purpose of printing.
(They are some graphs plotted on screen in 32bit color)

The plan is:
When 'Print' is selected(in my program), I breifly redraw the relevant portion of the screen replacing all graphic commands with black line drawings on a white background, then save that portion as a bmp. Then I redraw the original graphics.

So I was looking for a 'single switch' way to convert all my filled boxes to bordered boxes for this purpose.

Oh well....
Richard
Posts: 3096
Joined: Jan 15, 2007 20:44
Location: Australia

Post by Richard »

Code: Select all

Sub Box(condition As Integer,_
    x1 As Integer,_
    y1 As Integer,_
    x2 As Integer,_
    y2 As Integer) 
    If (condition = 0) Then
        Line (x1,y1)- Step(x2, y2), Rgb(70,70,70), B
    Else
        Line (x1,y1)- Step(x2, y2), Rgb(70,70,70), BF
    End If
End Sub

Box(condition, 15, 15, 100, 100)
bethell
Posts: 44
Joined: Sep 26, 2009 22:02

Post by bethell »

Thanks, Richard,

Yes, I guess that's the way to go.

I hereby mark this topic as 'RESOLVED'

Regards !!
Post Reply