How to resolve the algorithm Yin and yang step by step in the XPL0 programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Yin and yang step by step in the XPL0 programming language

Table of Contents

Problem Statement

One well-known symbol of the philosophy of duality known as yin and yang is the taijitu.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Yin and yang step by step in the XPL0 programming language

Source code in the xpl0 programming language

include c:\cxpl\codes;          \intrinsic 'code' declarations

def Black=0, Red=4, White=$F;

proc Circle(X0, Y0, R, CL, CR); \Show a filled circle
int X0, Y0, R, CL, CR;          \left and right half colors
int X, Y;
[for Y:= -R to R do
    for X:= -R to R do
        if X*X + Y*Y <= R*R then
            Point(X+X0, Y+Y0, if X<0 then CL else CR);
]; \Circle

proc YinYang(X0, Y0, R);
int  X0, Y0, R;
[Circle(X0, Y0,     R,   White, Black);
 Circle(X0, Y0-R/2, R/2, White, White);
 Circle(X0, Y0-R/2, R/6, Black, Black);
 Circle(X0, Y0+R/2, R/2, Black, Black);
 Circle(X0, Y0+R/2, R/6, White, White);
]; \YinYang

[SetVid($101);                  \640x480 graphics
Circle(320, 240, 400, Red, Red);\fill screen with background color
YinYang(80, 80, 70);
YinYang(240, 240, 150);
if ChIn(1) then [];             \wait for keystroke
SetVid(3);                      \restore normal text mode
]

  

You may also check:How to resolve the algorithm Pragmatic directives step by step in the RPL programming language
You may also check:How to resolve the algorithm Date format step by step in the BaCon programming language
You may also check:How to resolve the algorithm Evolutionary algorithm step by step in the Ceylon programming language
You may also check:How to resolve the algorithm 24 game step by step in the Sidef programming language
You may also check:How to resolve the algorithm Runge-Kutta method step by step in the R programming language