Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.72 KB | None | 0 0
  1.         $canvas = $this->canvas;
  2.         $canvas->size = [300, 300];
  3.         $canvas->position = [0, 0];
  4.        
  5.         $gc = $canvas->getGraphicsContext();
  6.        
  7.         $x = $canvas->width / 2;
  8.         $y = $canvas->height / 2;
  9.        
  10.        
  11.         $size = 50;
  12.        
  13.         // точки ограничения рабочей области
  14.         // delete
  15.         $gc->fillRect(10, 10, 10, 10);
  16.         $gc->fillRect($x * 2 - 10, $y * 2 - 10, 10, 10);
  17.        
  18.        
  19.         $th = new Thread(function () use ($gc, $x, $y, $size, $canvas) {
  20.             $gc->strokeColor = UXColor::rgb(25, 75, 100);
  21.             for($i = -90; $i < 280; $i++) {
  22.            
  23.                 $rad = deg2rad($i);
  24.                
  25.                 // это чтобы ты понял что тут происходит
  26.                 if($i === 0) {
  27.                     $gc->strokeColor = UXColor::rgb(200, 0, 0);
  28.                 }
  29.                
  30.                 uiLater(function () use ($gc, $rad, $x, $y, $size, $canvas) {
  31.                     $gc->beginPath(); // забыл добавить
  32.                     $gc->moveTo(cos($rad) + $x, sin($rad) + $y);
  33.                     $gc->lineTo(cos($rad) * $size + $x, sin($rad) * $size + $y);
  34.                     $gc->stroke();
  35.                     $gc->closePath();
  36.                    
  37.  
  38.                     /* $gc->strokeColor = UXColor::rgb(155, 155, 155);
  39.                     $gc->moveTo(cos($rad) + $x, sin($rad) + $y);
  40.                     $gc->lineTo(cos($rad) * ($size - 25) + $x, sin($rad) * ($size - 25) + $y);
  41.                     $gc->stroke(); */
  42.                 });
  43.                
  44.                 wait(10);
  45.             }
  46.         });
  47.        
  48.         $th->start();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement