Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
18
Task/Draw-a-sphere/XPL0/draw-a-sphere.xpl0
Normal file
18
Task/Draw-a-sphere/XPL0/draw-a-sphere.xpl0
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
include c:\cxpl\codes; \intrinsic 'code' declarations
|
||||
def R=100, R2=R*R; \radius, in pixels; radius squared
|
||||
def X0=640/2, Y0=480/2; \coordinates of center of screen
|
||||
int X, Y, Z, C, D2; \coords, color, distance from center squared
|
||||
[SetVid($112); \set 640x480x24 graphics mode
|
||||
for Y:= -R to +R do \for all the coordinates near the circle
|
||||
for X:= -R to +R do \ which is under the sphere
|
||||
[D2:= X*X + Y*Y;
|
||||
C:= 0; \default color is black
|
||||
if D2 <= R2 then \coordinate is inside circle under sphere
|
||||
[Z:= sqrt(R2-D2); \height of point on surface of sphere above X,Y
|
||||
C:= Z-(X+Y)/2+130; \color is proportional; offset X and Y, and
|
||||
]; \ shift color to upper limit of its range
|
||||
Point(X+X0, Y+Y0, C<<8+C); \green + blue = cyan
|
||||
];
|
||||
repeat until KeyHit; \wait for keystroke
|
||||
SetVid($03); \restore normal text mode
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue