Task

Draw a sphere.

The sphere can be represented graphically, or in ASCII art, depending on the language capabilities.

Either static or rotational projection is acceptable for this task.



Related tasks

 draw a cuboid
 draw a rotating cube
 write language name in 3D ASCII
 draw a Deathstar


INT ARRAY SinTab=[
  0 4 9 13 18 22 27 31 36 40 44 49 53 58 62 66 71 75 79 83
  88 92 96 100 104 108 112 116 120 124 128 132 136 139 143
  147 150 154 158 161 165 168 171 175 178 181 184 187 190
  193 196 199 202 204 207 210 212 215 217 219 222 224 226
  228 230 232 234 236 237 239 241 242 243 245 246 247 248
  249 250 251 252 253 254 254 255 255 255 256 256 256 256]
 
INT FUNC Sin(INT a)
  WHILE a<0 DO a==+360 OD
  WHILE a>360 DO a==-360 OD
  IF a<=90 THEN
    RETURN (SinTab(a))
  ELSEIF a<=180 THEN
    RETURN (SinTab(180-a))
  ELSEIF a<=270 THEN
    RETURN (-SinTab(a-180))
  ELSE
    RETURN (-SinTab(360-a))
  FI
RETURN (0)
 
INT FUNC Cos(INT a)
RETURN (Sin(a-90))
 
PROC Ellipse(INT x0,y0,rx,ry)
  INT i
  CARD x
  BYTE y
 
  x=x0+rx*Sin(0)/256
  y=y0+ry*Cos(0)/256
  Plot(x,y)
  FOR i=5 TO 360 STEP 5
  DO
    x=x0+rx*Sin(i)/256
    y=y0+ry*Cos(i)/256
    DrawTo(x,y)
  OD
RETURN
 
PROC Main()
  BYTE CH=$02FC,COLOR1=$02C5,COLOR2=$02C6
  INT cx=[160],cy=[96],r=[90],r2
  BYTE i
 
  Graphics(8+16)
  COLOR1=$0C
  COLOR2=$02
  Color=1
 
  Ellipse(cx,cy,r,r)
  FOR i=10 TO 90 STEP 10
  DO
    r2=r*Cos(i)/256
    Ellipse(cx,cy,r,r2)
    Ellipse(cx,cy,r2,r)
  OD
 
  DO UNTIL CH#$FF OD
  CH=$FF
RETURN