ZealOS/docs/Demo/Graphics/MathAudioDemo.CC.html
2021-08-17 02:47:37 -04:00

141 lines
14 KiB
HTML
Executable file

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=US-ASCII">
<meta name="generator" content="ZealOS V1.00">
<style type="text/css">
body {background-color:#fef1f0;}
.cF0{color:#000000;background-color:#fef1f0;}
.cF1{color:#0148a4;background-color:#fef1f0;}
.cF2{color:#3b7901;background-color:#fef1f0;}
.cF3{color:#057c7e;background-color:#fef1f0;}
.cF4{color:#bb2020;background-color:#fef1f0;}
.cF5{color:#9e42ae;background-color:#fef1f0;}
.cF6{color:#b57901;background-color:#fef1f0;}
.cF7{color:#b2b6af;background-color:#fef1f0;}
.cF8{color:#555753;background-color:#fef1f0;}
.cF9{color:#678fbb;background-color:#fef1f0;}
.cFA{color:#82bc49;background-color:#fef1f0;}
.cFB{color:#0097a2;background-color:#fef1f0;}
.cFC{color:#e26a6a;background-color:#fef1f0;}
.cFD{color:#c671bc;background-color:#fef1f0;}
.cFE{color:#c7ab00;background-color:#fef1f0;}
.cFF{color:#fef1f0;background-color:#fef1f0;}
</style>
</head>
<body>
<pre style="font-family:monospace;font-size:12pt">
<a name="l1"></a><span class=cF1>F64</span><span class=cF0> MySin(</span><span class=cF1>F64</span><span class=cF0> d)
<a name="l2"></a>{ </span><span class=cF2>//Sin() does not have an address.</span><span class=cF0>
<a name="l3"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>Sin</span><span class=cF0>(d);
<a name="l4"></a>}
<a name="l5"></a>
<a name="l6"></a></span><span class=cF1>F64</span><span class=cF0> MyCos(</span><span class=cF1>F64</span><span class=cF0> d)
<a name="l7"></a>{ </span><span class=cF2>//Cos() does not have an address.</span><span class=cF0>
<a name="l8"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>Cos</span><span class=cF0>(d);
<a name="l9"></a>}
<a name="l10"></a>
<a name="l11"></a></span><span class=cF1>U0</span><span class=cF0> FunDraw1(</span><span class=cF9>CDC</span><span class=cF0> *dc, </span><span class=cF1>F64</span><span class=cF0> </span><span class=cF7>(</span><span class=cF0>*f</span><span class=cF7>)(</span><span class=cF1>F64</span><span class=cF0> t</span><span class=cF7>)</span><span class=cF0>)
<a name="l12"></a>{
<a name="l13"></a> </span><span class=cF9>I64</span><span class=cF0> i, w = </span><span class=cF5>Fs</span><span class=cF0>-&gt;pix_width, h = </span><span class=cF5>Fs</span><span class=cF0>-&gt;pix_height;
<a name="l14"></a> </span><span class=cF1>F64</span><span class=cF0> scale = h / </span><span class=cFE>5</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
<a name="l15"></a>
<a name="l16"></a> </span><span class=cF1>for</span><span class=cF0> (i = -w / </span><span class=cFE>2</span><span class=cF0>; i &lt;= w / </span><span class=cFE>2</span><span class=cF0>; i++)
<a name="l17"></a> </span><span class=cF5>GrLine</span><span class=cF0>(dc, w / </span><span class=cFE>2</span><span class=cF0> + i, h / </span><span class=cFE>2</span><span class=cF0> - scale * f</span><span class=cF7>(</span><span class=cF0>i / scale * </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF7>)</span><span class=cF0>,
<a name="l18"></a> w / </span><span class=cFE>2</span><span class=cF0> + i + </span><span class=cFE>1</span><span class=cF0>, h / </span><span class=cFE>2</span><span class=cF0> - scale * f</span><span class=cF7>(</span><span class=cF0>(i + </span><span class=cFE>1</span><span class=cF0>) / scale * </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF7>)</span><span class=cF0>);
<a name="l19"></a>}
<a name="l20"></a>
<a name="l21"></a></span><span class=cF1>U0</span><span class=cF0> FunDraw2(</span><span class=cF9>CDC</span><span class=cF0> *dc, </span><span class=cF1>F64</span><span class=cF0> </span><span class=cF7>(</span><span class=cF0>*f</span><span class=cF7>)(</span><span class=cF1>F64</span><span class=cF0> t, </span><span class=cF1>F64</span><span class=cF0> p</span><span class=cF7>)</span><span class=cF0>, </span><span class=cF1>F64</span><span class=cF0> T)
<a name="l22"></a>{
<a name="l23"></a> </span><span class=cF9>I64</span><span class=cF0> i, w = </span><span class=cF5>Fs</span><span class=cF0>-&gt;pix_width, h = </span><span class=cF5>Fs</span><span class=cF0>-&gt;pix_height;
<a name="l24"></a> </span><span class=cF1>F64</span><span class=cF0> scale = h / </span><span class=cFE>5</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
<a name="l25"></a>
<a name="l26"></a> </span><span class=cF1>for</span><span class=cF0> (i = -w / </span><span class=cFE>2</span><span class=cF0>; i &lt;= w / </span><span class=cFE>2</span><span class=cF0>; i++)
<a name="l27"></a> </span><span class=cF5>GrLine</span><span class=cF0>(dc, w / </span><span class=cFE>2</span><span class=cF0> + i, h / </span><span class=cFE>2</span><span class=cF0> - scale * f</span><span class=cF7>(</span><span class=cF0>i / scale, T</span><span class=cF7>)</span><span class=cF0>, w / </span><span class=cFE>2</span><span class=cF0> + i + </span><span class=cFE>1</span><span class=cF0>, h / </span><span class=cFE>2</span><span class=cF0> - scale * f</span><span class=cF7>(</span><span class=cF0>(i + </span><span class=cFE>1</span><span class=cF0>) / scale, T</span><span class=cF7>)</span><span class=cF0>);
<a name="l28"></a>}
<a name="l29"></a>
<a name="l30"></a></span><span class=cF1>U0</span><span class=cF0> Init(</span><span class=cF9>CDC</span><span class=cF0> *dc)
<a name="l31"></a>{
<a name="l32"></a> </span><span class=cF9>I64</span><span class=cF0> i, w = </span><span class=cF5>Fs</span><span class=cF0>-&gt;pix_width, h = </span><span class=cF5>Fs</span><span class=cF0>-&gt;pix_height;
<a name="l33"></a> </span><span class=cF1>F64</span><span class=cF0> scale = h / </span><span class=cFE>5</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
<a name="l34"></a>
<a name="l35"></a> </span><span class=cF5>DocClear</span><span class=cF0>;
<a name="l36"></a> </span><span class=cF5>DCFill</span><span class=cF0>(dc);
<a name="l37"></a> dc-&gt;color = </span><span class=cF3>BLACK</span><span class=cF0>;
<a name="l38"></a> </span><span class=cF5>GrLine</span><span class=cF0>(dc, </span><span class=cFE>0</span><span class=cF0>, h / </span><span class=cFE>2</span><span class=cF0>, w - </span><span class=cFE>1</span><span class=cF0>, h / </span><span class=cFE>2</span><span class=cF0>);
<a name="l39"></a> </span><span class=cF5>GrLine</span><span class=cF0>(dc, w / </span><span class=cFE>2</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>, w / </span><span class=cFE>2</span><span class=cF0>, h - </span><span class=cFE>1</span><span class=cF0>);
<a name="l40"></a> </span><span class=cF1>for</span><span class=cF0> (i = -</span><span class=cFE>2</span><span class=cF0>; i &lt;= </span><span class=cFE>2</span><span class=cF0>; i++)
<a name="l41"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l42"></a> dc-&gt;color = </span><span class=cF3>BLACK</span><span class=cF0>;
<a name="l43"></a> </span><span class=cF5>GrLine</span><span class=cF0>(dc, w / </span><span class=cFE>2</span><span class=cF0> - </span><span class=cFE>3</span><span class=cF0>, h / </span><span class=cFE>2</span><span class=cF0> - scale * i, w / </span><span class=cFE>2</span><span class=cF0> + </span><span class=cFE>3</span><span class=cF0>, h / </span><span class=cFE>2</span><span class=cF0> - scale * i);
<a name="l44"></a> </span><span class=cF1>if</span><span class=cF0> (i)
<a name="l45"></a> {
<a name="l46"></a> dc-&gt;color = </span><span class=cF3>DKGRAY</span><span class=cF0>;
<a name="l47"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc, w / </span><span class=cFE>2</span><span class=cF0> + </span><span class=cFE>5</span><span class=cF0>, h / </span><span class=cFE>2</span><span class=cF0> - scale * i - </span><span class=cF3>FONT_HEIGHT</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0>, </span><span class=cF6>&quot;%5.1f&quot;</span><span class=cF0>, </span><span class=cF5>ToF64</span><span class=cF7>(</span><span class=cF0>i</span><span class=cF7>)</span><span class=cF0>);
<a name="l48"></a> }
<a name="l49"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l50"></a> </span><span class=cF1>for</span><span class=cF0> (i = -</span><span class=cFE>4</span><span class=cF0>; i &lt;= </span><span class=cFE>4</span><span class=cF0>; i++)
<a name="l51"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l52"></a> dc-&gt;color = </span><span class=cF3>BLACK</span><span class=cF0>;
<a name="l53"></a> </span><span class=cF5>GrLine</span><span class=cF0>(dc, w / </span><span class=cFE>2</span><span class=cF0> + scale * i, h / </span><span class=cFE>2</span><span class=cF0> - </span><span class=cFE>3</span><span class=cF0>, w / </span><span class=cFE>2</span><span class=cF0> + scale * i, h / </span><span class=cFE>2</span><span class=cF0> + </span><span class=cFE>3</span><span class=cF0>);
<a name="l54"></a> </span><span class=cF1>if</span><span class=cF0> (i)
<a name="l55"></a> {
<a name="l56"></a> dc-&gt;color = </span><span class=cF3>DKGRAY</span><span class=cF0>;
<a name="l57"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc, w / </span><span class=cFE>2</span><span class=cF0> + scale * i - </span><span class=cFE>7</span><span class=cF0> * </span><span class=cF3>FONT_WIDTH</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0>, h / </span><span class=cFE>2</span><span class=cF0> + </span><span class=cFE>5</span><span class=cF0> + </span><span class=cF3>FONT_HEIGHT</span><span class=cF0>, </span><span class=cF6>&quot;%5.1f*T&quot;</span><span class=cF0>, </span><span class=cF5>ToF64</span><span class=cF7>(</span><span class=cF0>i</span><span class=cF7>)</span><span class=cF0>);
<a name="l58"></a> }
<a name="l59"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l60"></a>}
<a name="l61"></a>
<a name="l62"></a></span><span class=cF1>U0</span><span class=cF0> SoundMathDemo()
<a name="l63"></a>{
<a name="l64"></a> </span><span class=cF9>CDC</span><span class=cF0> *dc = </span><span class=cF5>DCAlias</span><span class=cF0>;
<a name="l65"></a>
<a name="l66"></a> Init(dc);
<a name="l67"></a> dc-&gt;color = </span><span class=cF3>RED</span><span class=cF0>;
<a name="l68"></a> FunDraw1(dc, &amp;MySin);
<a name="l69"></a> </span><span class=cF6>&quot;$RED$Sin$FG$\n&quot;</span><span class=cF0>;
<a name="l70"></a> </span><span class=cF5>PressAKey</span><span class=cF0>;
<a name="l71"></a> dc-&gt;color = </span><span class=cF3>BLUE</span><span class=cF0>;
<a name="l72"></a> FunDraw2(dc, &amp;</span><span class=cF5>Saw</span><span class=cF0>, </span><span class=cFE>1</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>);
<a name="l73"></a> </span><span class=cF6>&quot;$BLUE$Saw$FG$\n&quot;</span><span class=cF0>;
<a name="l74"></a> </span><span class=cF5>PressAKey</span><span class=cF0>;
<a name="l75"></a> dc-&gt;color = </span><span class=cF3>GREEN</span><span class=cF0>;
<a name="l76"></a> FunDraw2(dc, &amp;</span><span class=cF5>FullSaw</span><span class=cF0>, </span><span class=cFE>1</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>);
<a name="l77"></a> </span><span class=cF6>&quot;$GREEN$FullSaw$FG$\n&quot;</span><span class=cF0>;
<a name="l78"></a> </span><span class=cF5>PressAKey</span><span class=cF0>;
<a name="l79"></a>
<a name="l80"></a> Init(dc);
<a name="l81"></a> dc-&gt;color = </span><span class=cF3>RED</span><span class=cF0>;
<a name="l82"></a> FunDraw1(dc, &amp;MyCos);
<a name="l83"></a> </span><span class=cF6>&quot;$RED$Cos$FG$\n&quot;</span><span class=cF0>;
<a name="l84"></a> </span><span class=cF5>PressAKey</span><span class=cF0>;
<a name="l85"></a> dc-&gt;color = </span><span class=cF3>BLUE</span><span class=cF0>;
<a name="l86"></a> FunDraw2(dc, &amp;</span><span class=cF5>Caw</span><span class=cF0>, </span><span class=cFE>1</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>);
<a name="l87"></a> </span><span class=cF6>&quot;$BLUE$Caw$FG$\n&quot;</span><span class=cF0>;
<a name="l88"></a> </span><span class=cF5>PressAKey</span><span class=cF0>;
<a name="l89"></a> dc-&gt;color = </span><span class=cF3>GREEN</span><span class=cF0>;
<a name="l90"></a> FunDraw2(dc, &amp;</span><span class=cF5>FullCaw</span><span class=cF0>, </span><span class=cFE>1</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>);
<a name="l91"></a> </span><span class=cF6>&quot;$GREEN$FullCaw$FG$\n&quot;</span><span class=cF0>;
<a name="l92"></a> </span><span class=cF5>PressAKey</span><span class=cF0>;
<a name="l93"></a>
<a name="l94"></a> Init(dc);
<a name="l95"></a> dc-&gt;color = </span><span class=cF3>RED</span><span class=cF0>;
<a name="l96"></a> FunDraw1(dc, &amp;MySin);
<a name="l97"></a> </span><span class=cF6>&quot;$RED$Sin$FG$\n&quot;</span><span class=cF0>;
<a name="l98"></a> </span><span class=cF5>PressAKey</span><span class=cF0>;
<a name="l99"></a> dc-&gt;color = </span><span class=cF3>BLUE</span><span class=cF0>;
<a name="l100"></a> FunDraw2(dc, &amp;</span><span class=cF5>Tri</span><span class=cF0>, </span><span class=cFE>1</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>);
<a name="l101"></a> </span><span class=cF6>&quot;$BLUE$Tri$FG$\n&quot;</span><span class=cF0>;
<a name="l102"></a> </span><span class=cF5>PressAKey</span><span class=cF0>;
<a name="l103"></a> dc-&gt;color = </span><span class=cF3>GREEN</span><span class=cF0>;
<a name="l104"></a> FunDraw2(dc, &amp;</span><span class=cF5>FullTri</span><span class=cF0>, </span><span class=cFE>1</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>);
<a name="l105"></a> </span><span class=cF6>&quot;$GREEN$FullTri$FG$\n&quot;</span><span class=cF0>;
<a name="l106"></a> </span><span class=cF5>PressAKey</span><span class=cF0>;
<a name="l107"></a>
<a name="l108"></a> </span><span class=cF5>DCFill</span><span class=cF0>(dc);
<a name="l109"></a> </span><span class=cF5>DCDel</span><span class=cF0>(dc);
<a name="l110"></a>}
<a name="l111"></a>
<a name="l112"></a>SoundMathDemo;
</span></pre></body>
</html>