3v4l.org

run code in 300+ PHP versions simultaneously
<?php $width = 150; $height = 100; // create new image $img = imagecreatetruecolor($width, $height); // transparent background $background = imagecolorallocate($img, 0xFF, 0xFF, 0xFF); imagefilledrectangle ($img, 0,0, $width,$height, $background); imagecolortransparent($img, $background); // helper function, draws pixel and mirrors it function setpixel4($img, $centerX, $centerY, $deltaX, $deltaY, $color) { imagesetpixel($img, $centerX + $deltaX, $centerY + $deltaY, $color); imagesetpixel($img, $centerX - $deltaX, $centerY + $deltaY, $color); imagesetpixel($img, $centerX + $deltaX, $centerY - $deltaY, $color); imagesetpixel($img, $centerX - $deltaX, $centerY - $deltaY, $color); } // red ellipse, 2*10px border $color = imagecolorallocate($img, 0xFF, 0x00, 0x00); $centerX = $width /2; $radiusX = ($width -20) / 2; $centerY = $height/2; $radiusY = ($height-20) / 2; static $maxTransparency = 0x7F; // 127 $radiusX2 = $radiusX * $radiusX; $radiusY2 = $radiusY * $radiusY; // upper and lower halves $quarter = round($radiusX2 / sqrt($radiusX2 + $radiusY2)); for ($x = 0; $x <= $quarter; $x++) { $y = $radiusY * sqrt(1-$x*$x/$radiusX2); $error = $y - floor($y); $transparency = round($error * $maxTransparency); $alpha = $color | ($transparency << 24); $alpha2 = $color | (($maxTransparency - $transparency) << 24); setpixel4($img, $centerX, $centerY, $x, floor($y), $alpha); setpixel4($img, $centerX, $centerY, $x, floor($y)+1, $alpha2); } // right and left halves $quarter = round($radiusY2 / sqrt($radiusX2 + $radiusY2)); for ($y = 0; $y <= $quarter; $y++) { $x = $radiusX * sqrt(1-$y*$y/$radiusY2); $error = $x - floor($x); $transparency = round($error * $maxTransparency); $alpha = $color | ($transparency << 24); $alpha2 = $color | (($maxTransparency - $transparency) << 24); setpixel4($img, $centerX, $centerY, floor($x), $y, $alpha); setpixel4($img, $centerX, $centerY, floor($x)+1, $y, $alpha2); } // send PNG to browser header("Content-type: image/png"); imagepng($img, "", 9, PNG_ALL_FILTERS); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 108
Branch analysis from position: 108
2 jumps found. (Code = 44) Position 1 = 110, Position 2 = 59
Branch analysis from position: 110
1 jumps found. (Code = 42) Position 1 = 170
Branch analysis from position: 170
2 jumps found. (Code = 44) Position 1 = 172, Position 2 = 121
Branch analysis from position: 172
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 121
2 jumps found. (Code = 44) Position 1 = 172, Position 2 = 121
Branch analysis from position: 172
Branch analysis from position: 121
Branch analysis from position: 59
2 jumps found. (Code = 44) Position 1 = 110, Position 2 = 59
Branch analysis from position: 110
Branch analysis from position: 59
filename:       /in/B3WE9
function name:  (null)
number of ops:  183
compiled vars:  !0 = $width, !1 = $height, !2 = $img, !3 = $background, !4 = $color, !5 = $centerX, !6 = $radiusX, !7 = $centerY, !8 = $radiusY, !9 = $maxTransparency, !10 = $radiusX2, !11 = $radiusY2, !12 = $quarter, !13 = $x, !14 = $y, !15 = $error, !16 = $transparency, !17 = $alpha, !18 = $alpha2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 150
    3     1        ASSIGN                                                   !1, 100
    6     2        INIT_FCALL_BY_NAME                                       'imagecreatetruecolor'
          3        SEND_VAR_EX                                              !0
          4        SEND_VAR_EX                                              !1
          5        DO_FCALL                                      0  $21     
          6        ASSIGN                                                   !2, $21
    8     7        INIT_FCALL_BY_NAME                                       'imagecolorallocate'
          8        SEND_VAR_EX                                              !2
          9        SEND_VAL_EX                                              255
         10        SEND_VAL_EX                                              255
         11        SEND_VAL_EX                                              255
         12        DO_FCALL                                      0  $23     
         13        ASSIGN                                                   !3, $23
    9    14        INIT_FCALL_BY_NAME                                       'imagefilledrectangle'
         15        SEND_VAR_EX                                              !2
         16        SEND_VAL_EX                                              0
         17        SEND_VAL_EX                                              0
         18        SEND_VAR_EX                                              !0
         19        SEND_VAR_EX                                              !1
         20        SEND_VAR_EX                                              !3
         21        DO_FCALL                                      0          
   10    22        INIT_FCALL_BY_NAME                                       'imagecolortransparent'
         23        SEND_VAR_EX                                              !2
         24        SEND_VAR_EX                                              !3
         25        DO_FCALL                                      0          
   22    26        INIT_FCALL_BY_NAME                                       'imagecolorallocate'
         27        SEND_VAR_EX                                              !2
         28        SEND_VAL_EX                                              255
         29        SEND_VAL_EX                                              0
         30        SEND_VAL_EX                                              0
         31        DO_FCALL                                      0  $27     
         32        ASSIGN                                                   !4, $27
   24    33        DIV                                              ~29     !0, 2
         34        ASSIGN                                                   !5, ~29
   25    35        SUB                                              ~31     !0, 20
         36        DIV                                              ~32     ~31, 2
         37        ASSIGN                                                   !6, ~32
   26    38        DIV                                              ~34     !1, 2
         39        ASSIGN                                                   !7, ~34
   27    40        SUB                                              ~36     !1, 20
         41        DIV                                              ~37     ~36, 2
         42        ASSIGN                                                   !8, ~37
   28    43        BIND_STATIC                                              !9
   30    44        MUL                                              ~39     !6, !6
         45        ASSIGN                                                   !10, ~39
   31    46        MUL                                              ~41     !8, !8
         47        ASSIGN                                                   !11, ~41
   34    48        INIT_FCALL                                               'round'
         49        INIT_FCALL                                               'sqrt'
         50        ADD                                              ~43     !10, !11
         51        SEND_VAL                                                 ~43
         52        DO_ICALL                                         $44     
         53        DIV                                              ~45     !10, $44
         54        SEND_VAL                                                 ~45
         55        DO_ICALL                                         $46     
         56        ASSIGN                                                   !12, $46
   35    57        ASSIGN                                                   !13, 0
         58      > JMP                                                      ->108
   37    59    >   INIT_FCALL                                               'sqrt'
         60        MUL                                              ~49     !13, !13
         61        DIV                                              ~50     ~49, !10
         62        SUB                                              ~51     1, ~50
         63        SEND_VAL                                                 ~51
         64        DO_ICALL                                         $52     
         65        MUL                                              ~53     !8, $52
         66        ASSIGN                                                   !14, ~53
   38    67        INIT_FCALL                                               'floor'
         68        SEND_VAR                                                 !14
         69        DO_ICALL                                         $55     
         70        SUB                                              ~56     !14, $55
         71        ASSIGN                                                   !15, ~56
   39    72        INIT_FCALL                                               'round'
         73        MUL                                              ~58     !15, !9
         74        SEND_VAL                                                 ~58
         75        DO_ICALL                                         $59     
         76        ASSIGN                                                   !16, $59
   40    77        SL                                               ~61     !16, 24
         78        BW_OR                                            ~62     !4, ~61
         79        ASSIGN                                                   !17, ~62
   41    80        SUB                                              ~64     !9, !16
         81        SL                                               ~65     ~64, 24
         82        BW_OR                                            ~66     !4, ~65
         83        ASSIGN                                                   !18, ~66
   42    84        INIT_FCALL                                               'setpixel4'
         85        SEND_VAR                                                 !2
         86        SEND_VAR                                                 !5
         87        SEND_VAR                                                 !7
         88        SEND_VAR                                                 !13
         89        INIT_FCALL                                               'floor'
         90        SEND_VAR                                                 !14
         91        DO_ICALL                                         $68     
         92        SEND_VAR                                                 $68
         93        SEND_VAR                                                 !17
         94        DO_FCALL                                      0          
   43    95        INIT_FCALL                                               'setpixel4'
         96        SEND_VAR                                                 !2
         97        SEND_VAR                                                 !5
         98        SEND_VAR                                                 !7
         99        SEND_VAR                                                 !13
        100        INIT_FCALL                                               'floor'
        101        SEND_VAR                                                 !14
        102        DO_ICALL                                         $70     
        103        ADD                                              ~71     $70, 1
        104        SEND_VAL                                                 ~71
        105        SEND_VAR                                                 !18
        106        DO_FCALL                                      0          
   35   107        PRE_INC                                                  !13
        108    >   IS_SMALLER_OR_EQUAL                                      !13, !12
        109      > JMPNZ                                                    ~74, ->59
   47   110    >   INIT_FCALL                                               'round'
        111        INIT_FCALL                                               'sqrt'
        112        ADD                                              ~75     !10, !11
        113        SEND_VAL                                                 ~75
        114        DO_ICALL                                         $76     
        115        DIV                                              ~77     !11, $76
        116        SEND_VAL                                                 ~77
        117        DO_ICALL                                         $78     
        118        ASSIGN                                                   !12, $78
   48   119        ASSIGN                                                   !14, 0
        120      > JMP                                                      ->170
   50   121    >   INIT_FCALL                                               'sqrt'
        122        MUL                                              ~81     !14, !14
        123        DIV                                              ~82     ~81, !11
        124        SUB                                              ~83     1, ~82
        125        SEND_VAL                                                 ~83
        126        DO_ICALL                                         $84     
        127        MUL                                              ~85     !6, $84
        128        ASSIGN                                                   !13, ~85
   51   129        INIT_FCALL                                               'floor'
        130        SEND_VAR                                                 !13
        131        DO_ICALL                                         $87     
        132        SUB                                              ~88     !13, $87
        133        ASSIGN                                                   !15, ~88
   52   134        INIT_FCALL                                               'round'
        135        MUL                                              ~90     !15, !9
        136        SEND_VAL                                                 ~90
        137        DO_ICALL                                         $91     
        138        ASSIGN                                                   !16, $91
   53   139        SL                                               ~93     !16, 24
        140        BW_OR                                            ~94     !4, ~93
        141        ASSIGN                                                   !17, ~94
   54   142        SUB                                              ~96     !9, !16
        143        SL                                               ~97     ~96, 24
        144        BW_OR                                            ~98     !4, ~97
        145        ASSIGN                                                   !18, ~98
   55   146        INIT_FCALL                                               'setpixel4'
        147        SEND_VAR                                                 !2
        148        SEND_VAR                                                 !5
        149        SEND_VAR                                                 !7
        150        INIT_FCALL                                               'floor'
        151        SEND_VAR                                                 !13
        152        DO_ICALL                                         $100    
        153        SEND_VAR                                                 $100
        154        SEND_VAR                                                 !14
        155        SEND_VAR                                                 !17
        156        DO_FCALL                                      0          
   56   157        INIT_FCALL                                               'setpixel4'
        158        SEND_VAR                                                 !2
        159        SEND_VAR                                                 !5
        160        SEND_VAR                                                 !7
        161        INIT_FCALL                                               'floor'
        162        SEND_VAR                                                 !13
        163        DO_ICALL                                         $102    
        164        ADD                                              ~103    $102, 1
        165        SEND_VAL                                                 ~103
        166        SEND_VAR                                                 !14
        167        SEND_VAR                                                 !18
        168        DO_FCALL                                      0          
   48   169        PRE_INC                                                  !14
        170    >   IS_SMALLER_OR_EQUAL                                      !14, !12
        171      > JMPNZ                                                    ~106, ->121
   60   172    >   INIT_FCALL                                               'header'
        173        SEND_VAL                                                 'Content-type%3A+image%2Fpng'
        174        DO_ICALL                                                 
   61   175        INIT_FCALL_BY_NAME                                       'imagepng'
        176        SEND_VAR_EX                                              !2
        177        SEND_VAL_EX                                              ''
        178        SEND_VAL_EX                                              9
        179        FETCH_CONSTANT                                   ~108    'PNG_ALL_FILTERS'
        180        SEND_VAL_EX                                              ~108
        181        DO_FCALL                                      0          
   62   182      > RETURN                                                   1

Function setpixel4:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/B3WE9
function name:  setpixel4
number of ops:  39
compiled vars:  !0 = $img, !1 = $centerX, !2 = $centerY, !3 = $deltaX, !4 = $deltaY, !5 = $color
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
          4        RECV                                             !4      
          5        RECV                                             !5      
   15     6        INIT_FCALL_BY_NAME                                       'imagesetpixel'
          7        SEND_VAR_EX                                              !0
          8        ADD                                              ~6      !1, !3
          9        SEND_VAL_EX                                              ~6
         10        ADD                                              ~7      !2, !4
         11        SEND_VAL_EX                                              ~7
         12        SEND_VAR_EX                                              !5
         13        DO_FCALL                                      0          
   16    14        INIT_FCALL_BY_NAME                                       'imagesetpixel'
         15        SEND_VAR_EX                                              !0
         16        SUB                                              ~9      !1, !3
         17        SEND_VAL_EX                                              ~9
         18        ADD                                              ~10     !2, !4
         19        SEND_VAL_EX                                              ~10
         20        SEND_VAR_EX                                              !5
         21        DO_FCALL                                      0          
   17    22        INIT_FCALL_BY_NAME                                       'imagesetpixel'
         23        SEND_VAR_EX                                              !0
         24        ADD                                              ~12     !1, !3
         25        SEND_VAL_EX                                              ~12
         26        SUB                                              ~13     !2, !4
         27        SEND_VAL_EX                                              ~13
         28        SEND_VAR_EX                                              !5
         29        DO_FCALL                                      0          
   18    30        INIT_FCALL_BY_NAME                                       'imagesetpixel'
         31        SEND_VAR_EX                                              !0
         32        SUB                                              ~15     !1, !3
         33        SEND_VAL_EX                                              ~15
         34        SUB                                              ~16     !2, !4
         35        SEND_VAL_EX                                              ~16
         36        SEND_VAR_EX                                              !5
         37        DO_FCALL                                      0          
   19    38      > RETURN                                                   null

End of function setpixel4

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
176.15 ms | 1415 KiB | 25 Q