Added lot of junk laying around on harvie.cz
[mirrors/Programs.git] / php / skripty / nadruhou.php
1 <?php
2 //This will draw the ASCII neverending sinus curve.
3 //Writen by (c) Harvie in 2oo6
4 //This is script for PHP CLI (Not WebPage).
5 //You can port it to web by replacing "/n" by "<br>/n"
6
7 //Settings:
8 $start = -6; //0 //First X
9 $zero = 0; //Zero line
10 $stop = 6; //Last X
11 $step = 0.5; //0.1 //Increase X on every line by this number
12 $reset = 50; //When X >= reset, then it will be reseted to zero
13 $zoom = 1; //1 //This will repeat every line few times
14 $sleep = "15000"; //15000 - Wait between lines in microseconds
15 $line = (" "); // " " // ":" //chr ( 176 ) //This is the string, that will be repeated from display start to the curve (curve inlay).
16 $endline = ("+\n"); // "#\n" // ".\n" //chr ( 219 )."\n" //This is the string, that will be printed at end of every line (curve outline).
17
18 //Function:
19 //You can specify your function here:
20 function func($x) {
21
22 $offset = 1.1; //1.1 //1 //0 -> Zero offset will draw only half of sin curve.
23 $width = 2; //20 //35 //40 //This will stretch every line.
24
25 $y = ( ( ($x * $x) + $offset) * $width );
26 //echo("Debug: ".$x." ".$y." "); //Debug
27 return ($y);
28
29 }
30
31 //Code:
32 echo ("[SinusCurve]-[c][Harvie][2oo6]\n\n");
33 echo (" | y\n");
34 echo ("-|--------------------------------------------->\n");
35 echo ("x|\n");
36 echo (" V\n\n");
37
38 sleep(2);
39
40 //Set x to $start:
41 $pos = $start;
42
43 //Drawing:
44 while(1) {
45
46 //usleep($sleep); //Wait in microseconds
47
48 $znaku = func($pos);
49
50 $zoom2 = $zoom;
51 while ($zoom2 > 0) {
52
53 $znaku2 = round($znaku); //It looks better after round ;)
54 while ($znaku2 > 0) {
55 echo $line;
56 $znaku2 = ($znaku2 - 1);
57 }
58 //echo(" ".$pos); //Debug
59 echo ($endline);
60
61 $zoom2 = ($zoom2 - 1);
62 }
63
64 //Draw: Y axis:
65 //echo(" ".$pos."\n"); //Debug
66 if ($pos == $zero) {
67 echo("-+--------------------------------------------------------------------------->\n");
68 }
69
70 //Increase X:
71 $pos = ($pos + $step);
72
73 //Reset (for neverending curves, etc...):
74 if ($pos >= $reset) {
75 $pos = 0;
76 }
77
78 //Stop if $stop is reached:
79 if ($pos > $stop) {
80 break;
81 }
82
83 }
84 ?>
This page took 0.447257 seconds and 4 git commands to generate.