I know that Brandy BASIC doesn't support VDU 23,23... to set the thickness of lines, but presumably there must be some way of drawing lines that are more than one pixel thick.
For example one could in principle draw two or more parallel lines so close together that they merge into one thick line, or one might draw a thick line in the form of a long thin rectangle (probably as two triangles).
But neither approach seems particularly straightforward, especially if one wants the line thickness to be substantially independent of its angle. So has somebody already done this and created a general-purpose thick-line drawing routine for Brandy BASIC (or Matrix Brandy BASIC)?
How to draw thick lines in Brandy BASIC?
-
- Posts: 457
- Joined: Tue 18 Jun 2024, 09:32
-
- Posts: 222
- Joined: Tue 17 Apr 2018, 21:03
Re: How to draw thick lines in Brandy BASIC?
I think multiple lines is the only method that works efficiently, if one uses two triangles a circle needs to be plotted at either end as well if the thick line has that property. Although I guess if the line was thicker than say 10 pixels it may be quicker to plot triangles and circles.
Kind Regards Ric.
6502 back in the day, BB4W 2017 onwards, BBCSDL from 2023
6502 back in the day, BB4W 2017 onwards, BBCSDL from 2023
-
- Posts: 50
- Joined: Thu 05 Apr 2018, 14:08
Re: How to draw thick lines in Brandy BASIC?
I've usually used code along these lines:
with appropriate scaling for the pixel sizes.
Code: Select all
DEFPROCdraw(x1,y1,x2,y2,thick):LOCAL n
IF ABS(x2-x1)<ABS(y2-y1):FOR n=1 TO thick:MOVE x1+n,y1:DRAW x2+n,y2:NEXT:ENDPROC
FOR n=1 TO thick:MOVE x1,y1+n:DRAW x2,y2+n:NEXT:ENDPROC
-
- Posts: 457
- Joined: Tue 18 Jun 2024, 09:32
Re: How to draw thick lines in Brandy BASIC?
It's only in BB4W that thick lines have 'round' ends (presumably because that's what GDI32 does, by default). In BBCSDL they don't, they have 'flat' ends (similarly because that's what the underlying library, SDL2_gfxPrimitives, does).
So I'm not too concerned about the ends, especially as the 'thick' lines I'm typically wanting to draw are perhaps only 6-8 pixels thick, and the shape of the ends probably won't be apparent unless you look very closely (especially when you consider the effects of aliasing).
Any solution which works in Brandy, and results in the thickness of the line being substantially independent of its angle, is OK by me. But it doesn't look trivial, and I was hoping not to have to write it from scratch (especially as in BB4W and BBCDSL it's done for me).
-
- Posts: 457
- Joined: Tue 18 Jun 2024, 09:32
Re: How to draw thick lines in Brandy BASIC?
OK, thanks, but the results are pretty rough! If you look at the output from this program (admittedly rendered in BBCSDL, not Brandy) the line thickness is uneven, so is the spacing, and the ends are all over the place. In the NE and SW directions something seems to go seriously wrong. I was hoping for something better.

Code: Select all
ORIGIN 640,512
FOR a = 0 TO 2*PI STEP PI/20
PROCdraw(0, 0, 400*COS(a), 400*SIN(a), 20)
NEXT
END
DEFPROCdraw(x1,y1,x2,y2,thick):LOCAL n
IF ABS(x2-x1)<ABS(y2-y1):FOR n=1 TO thick:MOVE x1+n,y1:DRAW x2+n,y2:NEXT:ENDPROC
FOR n=1 TO thick:MOVE x1,y1+n:DRAW x2,y2+n:NEXT:ENDPROC
You do not have the required permissions to view the files attached to this post.
-
- Posts: 457
- Joined: Tue 18 Jun 2024, 09:32
Re: How to draw thick lines in Brandy BASIC?
Once I put my mind to it, the triangle method actually isn't so hard, and works quite well:Richard Russell wrote: ↑Thu 11 Sep 2025, 10:37 I was hoping not to have to write it from scratch (especially as in BB4W and BBCDSL it's done for me).
Code: Select all
ORIGIN 640,512
FOR a = 0 TO 2*PI STEP PI/20
PROCthick(0, 0, 400*COS(a), 400*SIN(a), 20)
NEXT
END
DEFPROCthick(x1,y1,x2,y2,t) : LOCAL dx,dy,d
dx = x2-x1 : dy = y2-y1 : d = t*0.5 / SQR(dx*dx+dy*dy) : dx = dx*d : dy = dy*d
MOVE x1+dy,y1-dx : MOVE x1-dy,y1+dx : PLOT 85,x2+dy,y2-dx : PLOT 85,x2-dy,y2+dx
ENDPROC
You do not have the required permissions to view the files attached to this post.
-
- Posts: 457
- Joined: Tue 18 Jun 2024, 09:32
Re: How to draw thick lines in Brandy BASIC?
And in Matrix Brandy BASIC:Richard Russell wrote: ↑Thu 11 Sep 2025, 11:15 Once I put my mind to it, the triangle method actually isn't so hard, and works quite well:
You do not have the required permissions to view the files attached to this post.
-
- Posts: 457
- Joined: Tue 18 Jun 2024, 09:32
Re: How to draw thick lines in Brandy BASIC?
Just to clarify, the thickness is in BASIC graphics units (as it was in Jonathan's code), to change it to pixels - e.g. for compatibility with VDU 23,23... - remove the *0.5 from the calculation:
Code: Select all
REM Line thickness t in pixels
DEF PROCthickline(x1,y1,x2,y2,t) : LOCAL dx,dy
dx = x2-x1 : dy = y2-y1 : t = t / SQR(dx*dx + dy*dy) : dx = dx*t : dy = dy*t
MOVE x1+dy,y1-dx : MOVE x1-dy,y1+dx : PLOT 85,x2+dy,y2-dx : PLOT 85,x2-dy,y2+dx
ENDPROC
-
- Posts: 457
- Joined: Tue 18 Jun 2024, 09:32
Re: How to draw thick lines in Brandy BASIC?
Even works quite nicely on the BBC Micro (MODE 0, changing ORIGIN 640,512 to VDU 29,640;512;):
You do not have the required permissions to view the files attached to this post.