Skip to content

Instantly share code, notes, and snippets.

@roblogic
Created December 17, 2020 02:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roblogic/7b2633a4469b0369f49993b02d542304 to your computer and use it in GitHub Desktop.
Save roblogic/7b2633a4469b0369f49993b02d542304 to your computer and use it in GitHub Desktop.
Apple II BASIC code for drawing the "hacker logo": a glider from Conway's Game of Life
0data51,29,73,51,73,73,51,73,29,73
1hgr2:hcolor=3:fori=0to191:hplot0,i to191,i:hplot i,0toi,191:next
2hcolor=0:fori=18to84step22:hplot18,i to84,i:hplot i,18toi,84:next
3fori=1to5:reada,b:a=a+.5:b=b+.5:gosub4:next:end
4forr=0to9step0.5:r2=r*r:for x=0 to r:y=sqr(r2-x*x)
5hplot a+x,y+b:hplot a-x,y+b:hplot a+x,-y+b:hplot a-x,-y+b
6hplot a+y,x+b:hplot a-y,x+b:hplot a+y,-x+b:hplot a-y,-x+b
7next:next:return
@roblogic
Copy link
Author

0data... locates the circles. 1hgr2... draws white background. 2hcolor... draws grid. 3for..read.. gets data & calls the circle subroutine. (.5 is added at various points because of quirky Apple II drawing logic). 4for... to 7..return is a unique algorithm for circles using SQR. (algo adapted from this tutorial).

Verified at https://www.calormen.com/jsbasic/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment