### Author Topic: Drawing a circle in BASIC - fast  (Read 704 times)

0 Members and 1 Guest are viewing this topic.

#### mr_lou

• 6128 Plus
• Posts: 3.168
• Country:
• Liked: 1338
• Likes Given: 2647
##### Drawing a circle in BASIC - fast
« on: 20:12, 08 January 20 »
As a kid, I used to do this all the time: Draw a circle using PLOT with SIN and COS - taking about 13 seconds. I had no clue that "render" time could be significantly reduced by using precalculations and other tricks.

Code: [Select]
`10 MODE 1:INK 0,0:BORDER 0:INK 1,2:INK 2,6:INK 3,1820 DEG:DIM s%(360),c%(360):x%=320:y%=298:p%=130 ORIGIN x%,y%:FOR n%=0 TO 360:s%(n%)=SIN(n%)*100:c%(n%)=COS(n%)*100:PLOT s%(n%),c%(n%),p%:NEXT40 FOR t%=1 TO 15:LOCATE 1,1:PRINT CHR\$(11)50 p%=p%+1:IF p%=4 THEN p%=160 GOSUB 90:NEXT70 LOCATE 1,1:PRINT CHR\$(11):p%=p%+1:IF p%=4 THEN p%=180 GOSUB 90:GOTO 7090 PLOT s%(0),c%(0),p%:FOR n%=0 TO 360 STEP t%:DRAW s%(n%),c%(n%),p%:NEXT:DRAW s%(0),c%(0),p%:RETURN`
« Last Edit: 07:49, 09 January 20 by mr_lou »

#### SRS

• Supporter
• 6128 Plus
• Posts: 620
• Country:
• Schneider CPC464 - what else ?
• Liked: 612
• Likes Given: 351
##### Re: Drawing a circle in BASIC - fast
« Reply #1 on: 21:14, 08 January 20 »

#### AMSDOS

• Supporter
• 6128 Plus
• Posts: 3.939
• Country:
• Liked: 1156
• Likes Given: 1923
##### Re: Drawing a circle in BASIC - fast
« Reply #2 on: 12:16, 09 January 20 »
Remembers me of this Thread: http://www.cpcwiki.eu/forum/programming/drawing-fast-circles-in-locomotive-basic/msg12068/#msg12068

Unfortunately that old thing isn't very practical if Circles of various sizes were used, by taking the centre point and radius and storing the DATA of it into a file and use the other routine to Draw it. But it did help me learn more about DATA and how Assembly could use it for routines.

@mr_lou The other thread which is the more useful of the 2 uses the Bresenham algorithm and has some interesting routines as well as an article from Your Computer with some other Circle Routines.
* Using the old Amstrad Languages    * with the Firmware
* I also like to problem solve code in BASIC    * And type-in Type-Ins!

Home Computing Weekly Programs
Popular Computing Weekly Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

#### roudoudou

• 6128 Plus
• Posts: 908
• Country:
• Liked: 1238
• Likes Given: 768
##### Re: Drawing a circle in BASIC - fast
« Reply #3 on: 14:19, 09 January 20 »
there is many ways to draw circles fast in pure basic depending on what you really need

so, what do you need?
use RASM, the best assembler ever made :p

I will survive