3v4l.org

run code in 300+ PHP versions simultaneously
<?php class DrawConnector { var $x0, $y0; var $R1; var $recx, $recy; //var $img; function __construct($img, $x0, $y0, $R1, $recx, $recy) { //$this -> img = $img; $this -> x0 = $x0; $this -> y0 = $y0; $this -> R1 = $R1; $this -> recx = $recx; $this -> recy = $recy; } function __draw($alpha1, $alpha2, $color) { $img = @ImageCreate (400, 400); $color = ImageColorAllocate ($img, 233, 0, 0); $blue = imagecolorallocate($img, 0, 0, 255); $alpha_delta = $alpha2 - $alpha1; $x1_0 = sin($alpha1) * $this -> R1; $y1_0 = cos($alpha1) * $this -> R1; $x2_0 = sin($alpha2) * $this -> R1; $y2_0 = cos($alpha2) * $this -> R1; $l = sqrt(($x2_0 - $x1_0) ^ 2 + ($y2_0 -$y1_0) ^ 2); If ($alpha_delta == pi()) { imageline($img, ($this -> x0 + ('1' - $this -> recx / $this -> R1 * '1.2') * $x1_0), ($this -> y0 + ('1' - $this -> recx / $this -> R1 * '1.2') * $y1_0), ($this -> x0 + ('1' - $this -> recx / $this -> R1 * '1.2') * $x2_0), ($this -> y0 + ('1' - $this -> recx / $this -> R1 * '1.2') * $y2_0), $color); } Else { $beta = ($alpha1 + $alpha2) / 2; $R1_kurz = $this -> R1 - $this -> recx * 1.2; $cx = sin($alpha1 + ($alpha2 - $alpha1) / 2) * $R1_kurz / cos(($alpha2 - $alpha1) / 2) + $this -> x0; $cy = cos($alpha1 + ($alpha2 - $alpha1) / 2) * $R1_kurz / cos(($alpha2 - $alpha1) / 2) + $this -> y0; $R2 = tan(($alpha2 - $alpha1) / 2) * $this -> R1; $R2_kurz = tan(($alpha2 - $alpha1) / 2) * $R1_kurz; $gamma = asin(($l / 2) / $R2); imagearc($img, '100', '100', '50', '50', '20', '60', $color); $cxx=$cx - $R2_kurz; $cyy=$cy - $R2_kurz; $R2_arc=$R2_kurz * '2'; $alpha_start=(-$gamma - $beta) / pi() * 180 - 90; $alpha_ende=($gamma - $beta) / pi() * 180; echo $cxx; echo $cyy; echo $R2; echo $alpha_start; echo $alpha_ende; //imagearc($img, $cxx, $cyy, $R2_arc, $R2_arc, $alpha_start, $alpha_ende, $color); header( "Content-type: image/png" ); imagepng($img); imagedestroy($img); } return null; } } $img = @ImageCreate (400, 400); $color = ImageColorAllocate ($img, 233, 0, 0); $blue = imagecolorallocate($img, 0, 0, 255); imagearc($img, '100', '100', '50', '50', '20', '60', $blue); //$DrawCon = new DrawConnector($img,'200','200','100','20','20'); //$DrawCon -> __draw($img, '0.1','0.2',$blue); header( "Content-type: image/png" ); imagepng($img); imagedestroy($img); ?>

preferences:
39.36 ms | 402 KiB | 5 Q