Commits

Wez Furlong  committed 9bbd110 Merge

merge

  • Participants
  • Parent commits 9681803, 0dff1b9

Comments (0)

Files changed (2)

File ASCIIToSVG.php

        * Should return exactly what was given to the $storCacheFn when it was
        * last called, or null if nothing can be loaded.
        */
-      self::$objects = self::$loadCacheFn();
+      $fn = self::$loadCacheFn;
+      self::$objects = $fn();
       return;
     } else {
       if (is_readable($cacheFile)) {
        *   ),
        * );
        */
-      $objs = self::$loadObjsFn();
+      $fn = self::$loadObjsFn;
+      $objs = $fn();
+
       $i = 0;
       foreach ($objs as $obj) {
         foreach ($obj['paths'] as $path) {
     }
 
     if (is_callable(self::$storCacheFn)) {
-      self::$storCacheFn(self::$objects);
+      $fn = self::$storCacheFn;
+      $fn(self::$objects);
     } else {
       file_put_contents($cacheFile, serialize(self::$objects));
     }
          * basically guaranteed to represent the start of the line.
          */
         case '<':
-          if ($this->isEdge($this->getChar($r, $c + 1), self::DIR_RIGHT)) {
+          $e = $this->getChar($r, $c + 1);
+          if ($this->isEdge($e, self::DIR_RIGHT) || $this->isCorner($e)) {
             $line->addMarker($c, $r, Point::IMARKER);
             $dir = self::DIR_RIGHT;
           }
           break;
         case '^':
-          if ($this->isEdge($this->getChar($r + 1, $c), self::DIR_DOWN)) {
+          $s = $this->getChar($r + 1, $c);
+          if ($this->isEdge($s, self::DIR_DOWN) || $this->isCorner($s)) { 
             $line->addMarker($c, $r, Point::IMARKER);
             $dir = self::DIR_DOWN;
           }
           break;
         case '>':
-          if ($this->isEdge($this->getChar($r, $c - 1), self::DIR_LEFT)) {
+          $w = $this->getChar($r, $c - 1);
+          if ($this->isEdge($w, self::DIR_LEFT) || $this->isCorner($w)) {
             $line->addMarker($c, $r, Point::IMARKER);
             $dir = self::DIR_LEFT;
           }
           break;
         case 'v':
-          if ($this->isEdge($this->getChar($r - 1, $c), self::DIR_UP)) {
+          $n = $this->getChar($r - 1, $c);
+          if ($this->isEdge($n, self::DIR_UP) || $this->isCorner($n)) {
             $line->addMarker($c, $r, Point::IMARKER);
             $dir = self::DIR_UP;
           }
           $n = $this->getChar($r-1, $c);
           $s = $this->getChar($r+1, $c);
           if (($s == '|' || $s == ':' || $this->isCorner($s)) &&
-              $n != '|' && $n != ':' && !$this->isCorner($n)) {
+              $n != '|' && $n != ':' && !$this->isCorner($n) &&
+              $n != '^') {
             $dir = self::DIR_DOWN;
           } elseif (($n == '|' || $n == ':' || $this->isCorner($n)) &&
-                    $s != '|' && $s != ':' && !$this->isCorner($s)) {
+                    $s != '|' && $s != ':' && !$this->isCorner($s) &&
+                    $s != 'v') {
             $dir = self::DIR_UP;
           }
           break;
           $w = $this->getChar($r, $c-1);
           $e = $this->getChar($r, $c+1);
           if (($w == '-' || $w == '=' || $this->isCorner($w)) &&
-              $e != '=' && $e != '-' && !$this->isCorner($e)) {
+              $e != '=' && $e != '-' && !$this->isCorner($e) &&
+              $e != '>') {
             $dir = self::DIR_LEFT;
           } elseif (($e == '-' || $e == '=' || $this->isCorner($e)) &&
-                    $w != '=' && $w != '-' && !$this->isCorner($w)) {
+                    $w != '=' && $w != '-' && !$this->isCorner($w) &&
+                    $w != '<') {
             $dir = self::DIR_RIGHT;
           }
           break;
           while ($i < count($line) && $this->grid[$row][$i] != ' ') {
             $str .= $this->grid[$row][$i++];
             /* Eat up to 1 space */
-            if ($this->grid[$row][$i] == ' ') {
+            if ($this->getChar($row, $i) == ' ') {
               $str .= ' ';
               $i++;
             }
        * Should return exactly what was given to the $storCacheFn when it was
        * last called, or null if nothing can be loaded.
        */
-      self::$objects = self::$loadCacheFn();
+      $fn = self::$loadCacheFn;
+      self::$objects = $fn();
       return;
     } else {
       if (is_readable($cacheFile)) {
        *   ),
        * );
        */
-      $objs = self::$loadObjsFn();
+      $fn = self::$loadObjsFn;
+      $objs = $fn();
+
       $i = 0;
       foreach ($objs as $obj) {
         foreach ($obj['paths'] as $path) {
     }
 
     if (is_callable(self::$storCacheFn)) {
-      self::$storCacheFn(self::$objects);
+      $fn = self::$storCacheFn;
+      $fn(self::$objects);
     } else {
       file_put_contents($cacheFile, serialize(self::$objects));
     }
          * basically guaranteed to represent the start of the line.
          */
         case '<':
-          if ($this->isEdge($this->getChar($r, $c + 1), self::DIR_RIGHT)) {
+          $e = $this->getChar($r, $c + 1);
+          if ($this->isEdge($e, self::DIR_RIGHT) || $this->isCorner($e)) {
             $line->addMarker($c, $r, A2S_Point::IMARKER);
             $dir = self::DIR_RIGHT;
           }
           break;
         case '^':
-          if ($this->isEdge($this->getChar($r + 1, $c), self::DIR_DOWN)) {
+          $s = $this->getChar($r + 1, $c);
+          if ($this->isEdge($s, self::DIR_DOWN) || $this->isCorner($s)) { 
             $line->addMarker($c, $r, A2S_Point::IMARKER);
             $dir = self::DIR_DOWN;
           }
           break;
         case '>':
-          if ($this->isEdge($this->getChar($r, $c - 1), self::DIR_LEFT)) {
+          $w = $this->getChar($r, $c - 1);
+          if ($this->isEdge($w, self::DIR_LEFT) || $this->isCorner($w)) {
             $line->addMarker($c, $r, A2S_Point::IMARKER);
             $dir = self::DIR_LEFT;
           }
           break;
         case 'v':
-          if ($this->isEdge($this->getChar($r - 1, $c), self::DIR_UP)) {
+          $n = $this->getChar($r - 1, $c);
+          if ($this->isEdge($n, self::DIR_UP) || $this->isCorner($n)) {
             $line->addMarker($c, $r, A2S_Point::IMARKER);
             $dir = self::DIR_UP;
           }
           $n = $this->getChar($r-1, $c);
           $s = $this->getChar($r+1, $c);
           if (($s == '|' || $s == ':' || $this->isCorner($s)) &&
-              $n != '|' && $n != ':' && !$this->isCorner($n)) {
+              $n != '|' && $n != ':' && !$this->isCorner($n) &&
+              $n != '^') {
             $dir = self::DIR_DOWN;
           } elseif (($n == '|' || $n == ':' || $this->isCorner($n)) &&
-                    $s != '|' && $s != ':' && !$this->isCorner($s)) {
+                    $s != '|' && $s != ':' && !$this->isCorner($s) &&
+                    $s != 'v') {
             $dir = self::DIR_UP;
           }
           break;
           $w = $this->getChar($r, $c-1);
           $e = $this->getChar($r, $c+1);
           if (($w == '-' || $w == '=' || $this->isCorner($w)) &&
-              $e != '=' && $e != '-' && !$this->isCorner($e)) {
+              $e != '=' && $e != '-' && !$this->isCorner($e) &&
+              $e != '>') {
             $dir = self::DIR_LEFT;
           } elseif (($e == '-' || $e == '=' || $this->isCorner($e)) &&
-                    $w != '=' && $w != '-' && !$this->isCorner($w)) {
+                    $w != '=' && $w != '-' && !$this->isCorner($w) &&
+                    $w != '<') {
             $dir = self::DIR_RIGHT;
           }
           break;
           while ($i < count($line) && $this->grid[$row][$i] != ' ') {
             $str .= $this->grid[$row][$i++];
             /* Eat up to 1 space */
-            if ($this->grid[$row][$i] == ' ') {
+            if ($this->getChar($row, $i) == ' ') {
               $str .= ' ';
               $i++;
             }