docs
[mirrors/Programs.git] / php / skripty / sinus_curve.php
CommitLineData
8de51304
H
1<?php\r
2//This will draw the ASCII neverending sinus curve.\r
3//Writen by (c) Harvie in 2oo6\r
4//This is script for PHP CLI (Not WebPage).\r
5//You can port it to web by replacing "/n" by "<br>/n"\r
6\r
7//Settings:\r
8$start = 0; //0 //First X\r
9$step = 0.1; //0.1 //Increase X on every line by this number\r
10$reset = (2*PI()); //When X >= reset, then it will be reseted to zero\r
11$zoom = 1; //1 //This will repeat every line few times\r
12$offset = 1.1; //1.1 //1 //0 -> Zero offset will draw only half of sin curve.\r
13$width = 35; //20 //35 //40 //This will stretch every line.\r
14$sleep = "15000"; //15000 - Wait between lines in microseconds\r
15$line = (" "); // " " // ":" //chr ( 176 ) //This is the string, that will be repeated from display start to the curve (curve inlay).\r
16$endline = ("+\n"); // "#\n" // ".\n" //chr ( 219 )."\n" //This is the string, that will be printed at end of every line (curve outline).\r
17\r
18//Code:\r
19echo ("[SinusCurve]-[c][Harvie][2oo6]\n\n");\r
20echo ("0| y\n");\r
21echo ("-|--------------------------------------------->\n");\r
22echo ("x|\n");\r
23echo (" V\n\n");\r
24\r
25sleep(2);\r
26\r
27$pos = $start;\r
28while(1) {\r
29\r
30 usleep($sleep); //Wait in microseconds\r
31 \r
32 $znaku = ((sin($pos) + $offset) * $width);\r
33 \r
34 $zoom2 = $zoom;\r
35 while ($zoom2 > 0) {\r
36 \r
37 $znaku2 = round($znaku); //It looks better after round ;)\r
38 while ($znaku2 > 0) {\r
39 echo $line;\r
40 $znaku2 = ($znaku2 - 1);\r
41 }\r
42 //echo(" ".$pos." "); //Debug\r
43 echo ($endline);\r
44 \r
45 $zoom2 = ($zoom2 - 1);\r
46 }\r
47 \r
48 //echo(" ".$pos." "); //Debug\r
49 $pos = ($pos + $step);\r
50 if ($pos >= $reset) {\r
51 $pos = 0;\r
52 }\r
53\r
54}\r
55?>\r
This page took 0.187631 seconds and 4 git commands to generate.