3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Funkcja dokonuje normalizacji danych (oś Y) na podstawie współczynnika $max * * @param array $tab - tablica, której dane podlegają normalizacji, * @param float $max - maksymalna dopuszczalna wartość, * @return nowy współczynnik, który przez który należy podzielić wszystkie wartości funkcji zapisanej w tablicy * aby dokonać normalizacji, jeśli wartości mieszczą się w podanym zakresie, to wartości nie * są poddawane normalizacji */ function normalize($tab,$max) { $wsp=0.0; for ($a=0,$b=count($tab);$a<$b;$a++) { if (abs($tab[$a][1])>abs($wsp)) $wsp==abs($tab[$a][1]); } if ($wsp>$max) return $max/$wsp; else return 1.0; } /** * Funkcja dokonuje normalizacji * * @param $tab - tablica z danymi * @param $wsp - współczynnik normalizacji * @param $new_x - przesunięcie początku osi współrzędnych X do pozycji new_x * @param $new_y - przesunięcie początku osi współrzędnych Y do pozycji new_y * @return $tab - tablica z nowymi danymi */ function calculate($tab,$wsp,$new_x,$new_y) { for ($a=0,$b=count($tab);$a<b;$a++) { $tab[$a][0]+=$new_x; $tab[$a][1]=(float)$tab[$a][0]/(float)$wsp+$new_y; } return $tab; } function draw($tab) { $img = imagecreate(800,400); imagecolorallocate($img,230,230,230); $col2 = imagecolorallocate($img,0,255,0); $col3 = imagecolorallocate($img,0,0,0); for ($a=0,$b==count($tab);$a<$b;$a++) { for ($a2=0,$b2==count($tab[$a]);$a2<$b2;$a2+=2) { $x=$tab[$a][$a2]; $y=$tab[$a][$a2+1]; echo 'X:' . $x; echo 'Y:' . $y; echo PHP_EOL; //imagesetpixel($img,$x,$y,$col2); } //header('Content-type: image/jpeg'); //echo imagejpeg($img); } } for ($pos=0;$pos<3600;$pos++) $tab2[] = array($pos,200*sin(pi()*$pos / 180)); $tab2 = calculate($tab2,normalize($tab2,100),80,200); draw($tab2); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 2
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 2
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 2
Branch analysis from position: 17
Branch analysis from position: 2
filename:       /in/usj1n
function name:  (null)
number of ops:  32
compiled vars:  !0 = $pos, !1 = $tab2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   71     0  E >   ASSIGN                                                   !0, 0
          1      > JMP                                                      ->15
   72     2    >   INIT_ARRAY                                       ~4      !0
          3        INIT_FCALL                                               'sin'
          4        INIT_FCALL                                               'pi'
          5        DO_ICALL                                         $5      
          6        MUL                                              ~6      !0, $5
          7        DIV                                              ~7      ~6, 180
          8        SEND_VAL                                                 ~7
          9        DO_ICALL                                         $8      
         10        MUL                                              ~9      $8, 200
         11        ADD_ARRAY_ELEMENT                                ~4      ~9
         12        ASSIGN_DIM                                               !1
         13        OP_DATA                                                  ~4
   71    14        PRE_INC                                                  !0
         15    >   IS_SMALLER                                               !0, 3600
         16      > JMPNZ                                                    ~11, ->2
   74    17    >   INIT_FCALL                                               'calculate'
         18        SEND_VAR                                                 !1
         19        INIT_FCALL                                               'normalize'
         20        SEND_VAR                                                 !1
         21        SEND_VAL                                                 100
         22        DO_FCALL                                      0  $12     
         23        SEND_VAR                                                 $12
         24        SEND_VAL                                                 80
         25        SEND_VAL                                                 200
         26        DO_FCALL                                      0  $13     
         27        ASSIGN                                                   !1, $13
   76    28        INIT_FCALL                                               'draw'
         29        SEND_VAR                                                 !1
         30        DO_FCALL                                      0          
   77    31      > RETURN                                                   1

Function normalize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
2 jumps found. (Code = 44) Position 1 = 27, Position 2 = 7
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 32
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 24
Branch analysis from position: 17
2 jumps found. (Code = 44) Position 1 = 27, Position 2 = 7
Branch analysis from position: 27
Branch analysis from position: 7
Branch analysis from position: 24
filename:       /in/usj1n
function name:  normalize
number of ops:  34
compiled vars:  !0 = $tab, !1 = $max, !2 = $wsp, !3 = $a, !4 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   15     2        ASSIGN                                                   !2, 0
   16     3        ASSIGN                                                   !3, 0
          4        COUNT                                            ~7      !0
          5        ASSIGN                                                   !4, ~7
          6      > JMP                                                      ->25
   18     7    >   INIT_FCALL                                               'abs'
          8        FETCH_DIM_R                                      ~9      !0, !3
          9        FETCH_DIM_R                                      ~10     ~9, 1
         10        SEND_VAL                                                 ~10
         11        DO_ICALL                                         $11     
         12        INIT_FCALL                                               'abs'
         13        SEND_VAR                                                 !2
         14        DO_ICALL                                         $12     
         15        IS_SMALLER                                               $12, $11
         16      > JMPZ                                                     ~13, ->24
         17    >   INIT_FCALL                                               'abs'
         18        FETCH_DIM_R                                      ~14     !0, !3
         19        FETCH_DIM_R                                      ~15     ~14, 1
         20        SEND_VAL                                                 ~15
         21        DO_ICALL                                         $16     
         22        IS_EQUAL                                         ~17     !2, $16
         23        FREE                                                     ~17
   16    24    >   PRE_INC                                                  !3
         25    >   IS_SMALLER                                               !3, !4
         26      > JMPNZ                                                    ~19, ->7
   21    27    >   IS_SMALLER                                               !1, !2
         28      > JMPZ                                                     ~20, ->32
         29    >   DIV                                              ~21     !1, !2
         30      > RETURN                                                   ~21
         31*       JMP                                                      ->33
         32    > > RETURN                                                   1
   23    33*     > RETURN                                                   null

End of function normalize

Function calculate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 8
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 8
Branch analysis from position: 24
Branch analysis from position: 8
filename:       /in/usj1n
function name:  calculate
number of ops:  26
compiled vars:  !0 = $tab, !1 = $wsp, !2 = $new_x, !3 = $new_y, !4 = $a, !5 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
   37     4        ASSIGN                                                   !4, 0
          5        COUNT                                            ~7      !0
          6        ASSIGN                                                   !5, ~7
          7      > JMP                                                      ->21
   39     8    >   FETCH_DIM_RW                                     $9      !0, !4
          9        ASSIGN_DIM_OP                +=               1          $9, 0
         10        OP_DATA                                                  !2
   40    11        FETCH_DIM_R                                      ~13     !0, !4
         12        FETCH_DIM_R                                      ~14     ~13, 0
         13        CAST                                          5  ~15     ~14
         14        CAST                                          5  ~16     !1
         15        DIV                                              ~17     ~15, ~16
         16        ADD                                              ~18     ~17, !3
         17        FETCH_DIM_W                                      $11     !0, !4
         18        ASSIGN_DIM                                               $11, 1
         19        OP_DATA                                                  ~18
   37    20        PRE_INC                                                  !4
         21    >   FETCH_CONSTANT                                   ~20     'b'
         22        IS_SMALLER                                               !4, ~20
         23      > JMPNZ                                                    ~21, ->8
   44    24    > > RETURN                                                   !0
   45    25*     > RETURN                                                   null

End of function calculate

Function draw:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 53
Branch analysis from position: 53
2 jumps found. (Code = 44) Position 1 = 55, Position 2 = 31
Branch analysis from position: 55
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 50
Branch analysis from position: 50
2 jumps found. (Code = 44) Position 1 = 52, Position 2 = 37
Branch analysis from position: 52
2 jumps found. (Code = 44) Position 1 = 55, Position 2 = 31
Branch analysis from position: 55
Branch analysis from position: 31
Branch analysis from position: 37
2 jumps found. (Code = 44) Position 1 = 52, Position 2 = 37
Branch analysis from position: 52
Branch analysis from position: 37
filename:       /in/usj1n
function name:  draw
number of ops:  56
compiled vars:  !0 = $tab, !1 = $img, !2 = $col2, !3 = $col3, !4 = $a, !5 = $b, !6 = $a2, !7 = $b2, !8 = $x, !9 = $y
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   47     0  E >   RECV                                             !0      
   50     1        INIT_FCALL_BY_NAME                                       'imagecreate'
          2        SEND_VAL_EX                                              800
          3        SEND_VAL_EX                                              400
          4        DO_FCALL                                      0  $10     
          5        ASSIGN                                                   !1, $10
   51     6        INIT_FCALL_BY_NAME                                       'imagecolorallocate'
          7        SEND_VAR_EX                                              !1
          8        SEND_VAL_EX                                              230
          9        SEND_VAL_EX                                              230
         10        SEND_VAL_EX                                              230
         11        DO_FCALL                                      0          
   52    12        INIT_FCALL_BY_NAME                                       'imagecolorallocate'
         13        SEND_VAR_EX                                              !1
         14        SEND_VAL_EX                                              0
         15        SEND_VAL_EX                                              255
         16        SEND_VAL_EX                                              0
         17        DO_FCALL                                      0  $13     
         18        ASSIGN                                                   !2, $13
   53    19        INIT_FCALL_BY_NAME                                       'imagecolorallocate'
         20        SEND_VAR_EX                                              !1
         21        SEND_VAL_EX                                              0
         22        SEND_VAL_EX                                              0
         23        SEND_VAL_EX                                              0
         24        DO_FCALL                                      0  $15     
         25        ASSIGN                                                   !3, $15
   55    26        ASSIGN                                                   !4, 0
         27        COUNT                                            ~18     !0
         28        IS_EQUAL                                         ~19     !5, ~18
         29        FREE                                                     ~19
         30      > JMP                                                      ->53
   56    31    >   ASSIGN                                                   !6, 0
         32        FETCH_DIM_R                                      ~21     !0, !4
         33        COUNT                                            ~22     ~21
         34        IS_EQUAL                                         ~23     !7, ~22
         35        FREE                                                     ~23
         36      > JMP                                                      ->50
   58    37    >   FETCH_DIM_R                                      ~24     !0, !4
         38        FETCH_DIM_R                                      ~25     ~24, !6
         39        ASSIGN                                                   !8, ~25
   59    40        ADD                                              ~28     !6, 1
         41        FETCH_DIM_R                                      ~27     !0, !4
         42        FETCH_DIM_R                                      ~29     ~27, ~28
         43        ASSIGN                                                   !9, ~29
   60    44        CONCAT                                           ~31     'X%3A', !8
         45        ECHO                                                     ~31
   61    46        CONCAT                                           ~32     'Y%3A', !9
         47        ECHO                                                     ~32
   62    48        ECHO                                                     '%0A'
   56    49        ASSIGN_OP                                     1          !6, 2
         50    >   IS_SMALLER                                               !6, !7
         51      > JMPNZ                                                    ~34, ->37
   55    52    >   PRE_INC                                                  !4
         53    >   IS_SMALLER                                               !4, !5
         54      > JMPNZ                                                    ~36, ->31
   68    55    > > RETURN                                                   null

End of function draw

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173.87 ms | 1411 KiB | 22 Q