Пример #1
0
 /**
  * @param Window $window
  * @return Object
  */
 private function demoWindow(Window $window)
 {
     $window->addObject(new Object\Border($window->getWidth(), $window->getHeight()));
     $window->setStyle(new OutputFormatterStyle('white', 'red'));
     $object = new Object();
     $object->setX(10);
     $object->setY(14);
     $object->setDepth(2);
     $window->addObject($object);
     $point = new Point('Q');
     $point->setX(-1);
     $point->setY(-1);
     //        $point->setDepth(-1);
     $point->setStyle(new OutputFormatterStyle('red', 'yellow', array('bold', 'blink')));
     $object->addPoint($point);
     $point = new Point('D');
     $point->setX(1);
     $point->setY(0);
     $point->setStyle(new OutputFormatterStyle('red', 'black', array('underscore')));
     $object->addPoint($point);
     $point = new Point('Z');
     $point->setX(-1);
     $point->setY(1);
     $point->setStyle(new OutputFormatterStyle('red', 'yellow', array('bold')));
     $object->addPoint($point);
     $childWindow = new Window();
     $childWindow->setX(40);
     $childWindow->setY(20);
     $childWindow->setDepth(10);
     $childWindow->setWidth(15);
     $childWindow->setHeight(15);
     $childWindow->addObject(new Object\Border($childWindow->getWidth(), $childWindow->getHeight()), '*');
     $childWindow->addObject($object);
     $window->addChild($childWindow);
     return $object;
 }
Пример #2
0
 public function __construct($width = 0, $height = 0, $symbol = '#')
 {
     parent::__construct();
     for ($i = 0; $i < $width; $i++) {
         $point = new Point($symbol);
         $point->setX($i);
         $point->setY(0);
         $this->addPoint($point);
         $point = new Point($symbol);
         $point->setX($i);
         $point->setY($height - 1);
         $this->addPoint($point);
     }
     for ($i = 0; $i < $height; $i++) {
         $point = new Point($symbol);
         $point->setX(0);
         $point->setY($i);
         $this->addPoint($point);
         $point = new Point($symbol);
         $point->setX($width - 1);
         $point->setY($i);
         $this->addPoint($point);
     }
 }
Пример #3
0
 /**
  * @param Point $point
  * @param OutputFormatterStyleInterface $style
  * @param int $depth
  * @param int $x
  * @param int $y
  * @param WindowBounds $windowBounds
  */
 private function deeperToDrawPoint(Point $point, OutputFormatterStyleInterface $style = null, $depth = 0, $x = 0, $y = 0, WindowBounds $windowBounds)
 {
     if ($this->outOfBoundsCheck($x, $y, $this->drawTable, $windowBounds)) {
         return;
     }
     $registeredDepth = $this->depthRegister->getDepthFor($x, $y);
     if ($registeredDepth !== null && $depth < $registeredDepth) {
         return;
     }
     if ($style = $newStyle = $point->getStyleOrParent($style)) {
         $symbol = $style->apply($point->getStyledSymbol());
     } else {
         $symbol = $point->getStyledSymbol();
     }
     $this->drawTable->setSymbol($symbol, $x, $y);
     $this->depthRegister->registerDepth($x, $y, $depth);
 }