Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
15
Task/Draw-a-sphere/Zkl/draw-a-sphere-1.zkl
Normal file
15
Task/Draw-a-sphere/Zkl/draw-a-sphere-1.zkl
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
img:=PPM(640,480);
|
||||
R:=100; R2:=R*R; //radius, in pixels; radius squared
|
||||
X0:=640/2; Y0:=480/2; //coordinates of center of screen
|
||||
foreach Y in ([-R..R]){ //for all the coordinates near the circle
|
||||
foreach X in ([-R..R]){ // which is under the sphere
|
||||
D2:=X*X + Y*Y;
|
||||
C:=0; //default color is black
|
||||
if(D2<=R2){ //coordinate is inside circle under sphere
|
||||
Z:=(R2-D2).toFloat().sqrt();//height of point on surface of sphere above X,Y
|
||||
C=0x82+Z-(X+Y)/2; //color is proportional; offset X and Y, and
|
||||
} // shift color to upper limit of its range
|
||||
img[X+X0,Y+Y0]=C.shiftLeft(8)+C; //green + blue = cyan
|
||||
}
|
||||
}
|
||||
img.write(File("foo.ppm","wb"));
|
||||
1
Task/Draw-a-sphere/Zkl/draw-a-sphere-2.zkl
Normal file
1
Task/Draw-a-sphere/Zkl/draw-a-sphere-2.zkl
Normal file
|
|
@ -0,0 +1 @@
|
|||
img[X+X0,Y+Y0]=C*140+C;
|
||||
23
Task/Draw-a-sphere/Zkl/draw-a-sphere-3.zkl
Normal file
23
Task/Draw-a-sphere/Zkl/draw-a-sphere-3.zkl
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
#<<<
|
||||
cmd:=0'|
|
||||
set term wxt
|
||||
set parametric
|
||||
set urange [0:pi]
|
||||
set vrange [0:2*pi]
|
||||
set xyplane 0
|
||||
set view equal xyz
|
||||
set pm3d hidden3d 100 depthorder
|
||||
set style line 100 lt 7 lw 0.1
|
||||
set palette defined (0 "dark-blue", 1 "light-blue")
|
||||
unset key
|
||||
set samples 24
|
||||
set isosamples 36
|
||||
set title 'sphere (pm3d)' font "Times,20"
|
||||
R = 3
|
||||
splot R*sin(u)*cos(v), R*sin(u)*sin(v), R*cos(u) w pm3d
|
||||
|;
|
||||
#<<<
|
||||
|
||||
gnuplot:=System.popen("gnuplot","w");
|
||||
gnuplot.write(cmd); gnuplot.flush();
|
||||
ask("Hit return to finish"); gnuplot.close();
|
||||
Loading…
Add table
Add a link
Reference in a new issue