Added lot of junk laying around on harvie.cz
[mirrors/Programs.git] / php / skripty / nadruhou.php
diff --git a/php/skripty/nadruhou.php b/php/skripty/nadruhou.php
new file mode 100644 (file)
index 0000000..2e018bd
--- /dev/null
@@ -0,0 +1,84 @@
+<?php\r
+//This will draw the ASCII neverending sinus curve.\r
+//Writen by (c) Harvie in 2oo6\r
+//This is script for PHP CLI (Not WebPage).\r
+//You can port it to web by replacing "/n" by "<br>/n"\r
+\r
+//Settings:\r
+$start = -6;     //0 //First X\r
+$zero = 0;      //Zero line\r
+$stop = 6;      //Last X\r
+$step = 0.5;    //0.1 //Increase X on every line by this number\r
+$reset = 50; //When X >= reset, then it will be reseted to zero\r
+$zoom = 1;      //1 //This will repeat every line few times\r
+$sleep = "15000";   //15000 - Wait between lines in microseconds\r
+$line = (" ");     // " " // ":" //chr ( 176 ) //This is the string, that will be repeated from display start to the curve (curve inlay).\r
+$endline = ("+\n"); // "#\n" // ".\n" //chr ( 219 )."\n" //This is the string, that will be printed at end of every line (curve outline).\r
+\r
+//Function:\r
+//You can specify your function here:\r
+function func($x) {\r
+\r
+$offset = 1.1;    //1.1 //1 //0 -> Zero offset will draw only half of sin curve.\r
+$width = 2;     //20 //35 //40 //This will stretch every line.\r
+\r
+$y = ( ( ($x * $x) + $offset) * $width );\r
+//echo("Debug: ".$x." ".$y." "); //Debug\r
+return ($y);\r
+\r
+}\r
+\r
+//Code:\r
+echo ("[SinusCurve]-[c][Harvie][2oo6]\n\n");\r
+echo (" |                                           y\n");\r
+echo ("-|--------------------------------------------->\n");\r
+echo ("x|\n");\r
+echo (" V\n\n");\r
+\r
+sleep(2);\r
+\r
+//Set x to $start:\r
+$pos = $start;\r
+\r
+//Drawing:\r
+while(1) {\r
+\r
+  //usleep($sleep); //Wait in microseconds\r
+  \r
+  $znaku = func($pos);\r
+  \r
+  $zoom2 = $zoom;\r
+  while ($zoom2 > 0) {\r
+  \r
+    $znaku2 = round($znaku); //It looks better after round ;)\r
+    while ($znaku2 > 0) {\r
+      echo $line;\r
+      $znaku2 = ($znaku2 - 1);\r
+    }\r
+    //echo(" ".$pos); //Debug\r
+    echo ($endline);\r
+    \r
+    $zoom2 = ($zoom2 - 1);\r
+  }\r
+  \r
+  //Draw: Y axis:\r
+  //echo(" ".$pos."\n"); //Debug\r
+  if ($pos == $zero) {\r
+    echo("-+--------------------------------------------------------------------------->\n");\r
+  }\r
+  \r
+  //Increase X:\r
+  $pos = ($pos + $step);\r
+  \r
+  //Reset (for neverending curves, etc...):\r
+  if ($pos >= $reset) {\r
+    $pos = 0;\r
+  }\r
+  \r
+  //Stop if $stop is reached:\r
+  if ($pos > $stop) {\r
+    break;\r
+  }\r
+\r
+}\r
+?>\r
This page took 0.15822 seconds and 4 git commands to generate.