BBC BASIC for Windows
Programming >> Graphics and Games >> Antialiased line problem
http://bb4w.conforums.com/index.cgi?board=graphics&action=display&num=1424539268

Antialiased line problem
Post by Joe68 on Feb 21st, 2015, 4:21pm

I wrote a simple program to display an analogue clock.
I am trying to improve it using antialiased lines from GDIPLIB (e.g. for the hands) but I can't get this to work.

As far as I can see, my code is in accordance with that shown in the BB4W Help, but I keep receiving 'Syntax error' each time the program reaches
FN_gdipcreatepen(PenColour%,PenStyle%,PenWidth%)
Can anyone please show me where I am going wrong?

Here is a sample of a test program I used to try to discover my error:

MODE 8

INSTALL @lib$+"GDIPLIB"
PROC_gdipinit

PenColour%=&FFFFFFFF
PenStyle%=&12
PenWidth%=5
PRINT PenColour%

FN_gdipcreatepen(PenColour%,PenStyle%,PenWidth%)

PROC_gdipline(pen%,100,100,500,200)

END

Thanks in advance for the help.
Joe.
Re: Antialiased line problem
Post by VBI on Feb 21st, 2015, 6:48pm

As specified in the related help documentation, FN_gdipcreatepen has a return value for your newly created pen, so you need to supply a variable to store it in the usual way. This value is then required as Pen% by PROC_gdipline, so that it knows which pen it is being asked to draw with.

Your example, modified -

Code:
      INSTALL @lib$+"GDIPLIB"
      PROC_gdipinit
      
      MODE 8
      
      PenColour%=&FFFFFFFF
      PenStyle%=&12
      PenWidth%=5
      PRINT PenColour%
      
      pen%=FN_gdipcreatepen(PenColour%,PenStyle%,PenWidth%)
      
      PRINT pen%
      
      PROC_gdipline(pen%,100,100,500,200)
      
      PROC_gdipexit
      
      END
 


Hope that helps.
Re: Antialiased line problem
Post by Joe68 on Feb 21st, 2015, 8:54pm

Thank you very much, your mod works perfectly.
I didn't find this specifically stated in the Help, and being rather new to programming I didn't realise where the 'pen' variable in the line drawing command was coming from!
Always nice to be shown a new trick! smiley