News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_mr_lou

Drawing a circle in BASIC - fast

Started by mr_lou, 19:12, 08 January 20

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

mr_lou

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.


10 MODE 1:INK 0,0:BORDER 0:INK 1,2:INK 2,6:INK 3,18
20 DEG:DIM s%(360),c%(360):x%=320:y%=298:p%=1
30 ORIGIN x%,y%:FOR n%=0 TO 360:s%(n%)=SIN(n%)*100:c%(n%)=COS(n%)*100:PLOT s%(n%),c%(n%),p%:NEXT
40 FOR t%=1 TO 15:LOCATE 1,1:PRINT CHR$(11)
50 p%=p%+1:IF p%=4 THEN p%=1
60 GOSUB 90:NEXT
70 LOCATE 1,1:PRINT CHR$(11):p%=p%+1:IF p%=4 THEN p%=1
80 GOSUB 90:GOTO 70
90 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

SRS


AMSDOS

Quote from: SRS on 20:14, 08 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 :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

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

roudoudou

there is many ways to draw circles fast in pure basic depending on what you really need

so, what do you need?  ;D
My pronouns are RASM and ACE

Powered by SMFPacks Menu Editor Mod