Draw a sphere: Difference between revisions
Content added Content deleted
m (→{{header|REXX}}: added notes about show output when executing on an ASCII machine.) |
m ({{out}}) |
||
Line 1:
{{task}}{{requires|Graphics}}
The task is to 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.
=={{header|Ada}}==
Line 268 ⟶ 269:
END
</lang>
{{out}}
[[File:Sphere_BBC.jpeg]]
Line 335 ⟶ 336:
return 0;
}</lang>
}</lang>Output:<lang> #############%%%% ▼
{{out}}
##&&eeeeeeeeee&&&&&&&####%%%%%%%%
&&eeooooooooooooooeeeee&&&&######%%%%%%%%
Line 395 ⟶ 398:
eeeeeeeeeeeeeeeeeeeeeeeeeeeee
eeeeeeeeeeeeeeeeeeeee
eeeeeeeeeeeee </
===Fun with 3D noise texture===
Line 767 ⟶ 770:
</lang>
{{out}}
<pre>
&&&&&&&&&&#######
Line 890 ⟶ 893:
drawSphere(19, 4, 0.1);
</lang>
=={{header|Go}}==
[[file:GoSphere.png|right|thumb|Output png]]
Line 1,103 ⟶ 1,107:
}
}</lang>
{{out}}
<pre> &&&&&&&&&&#######
&eeeeeeeeeeeeeeee&&&&&&#######%
Line 1,316 ⟶ 1,320:
draw_sphere (20, 4, 0.1)
draw_sphere (10, 2, 0.4)</lang>
{{out}}
<pre> &&&&&&&&&&&&#####
&eeeoooooooooeeeeee&&&&&#######
Line 1,430 ⟶ 1,434:
drawSphere 20, 4.0, 0.1
drawSphere 10, 2.0, 0.4</lang>
{{out}}
<pre> &&&&&&&&&&#######
&eeeeeeeeeeeeeeee&&&&&&#######%
Line 1,698 ⟶ 1,702:
(drawSphere 20.0 4 0.1)
(drawSphere 10.0 2 0.4)</lang>
{{out}}
<pre> ##############%%%
#&&eeeeeeeeeee&&&&&&######%%%%%
Line 2,122 ⟶ 2,126:
draw_sphere(20,4,0.1, light)
draw_sphere(10,2,0.4, light)</lang>
{{out}}
<pre> &&&&&&&&&&######
&&eeeeeeeeeeeeeeee&&&&&&######%%
Line 2,187 ⟶ 2,191:
===Python: Using Pygame===
Renders a sphere with random Perlin noise.
This code contains unnecessary functions which are part of a 3D graphics library I wrote.
Uses Pygame and Python 3.2.2
[[File:PythonSphere.png]]
<lang python>
Line 3,025 ⟶ 3,031:
do k=j+5 to 0 by -1; if m.k>11 then numeric digits m.k; g=.5*(g+x/g); end
numeric digits d; return g/1</lang>
<pre style="height:105ex">
eeeeeeeeee@@@@@@@
|