Esempio n. 1
0
function locationsplit($bsw, $iPunc, $iSign)
{
    //needs cleaned up and simplified
    $bsw_array = array();
    $preLoc = '';
    $unitLoc = '';
    $postLoc = '';
    $segs = bsw2segment($bsw);
    foreach ($segs as $i => $seg) {
        if ($i < $iPunc) {
            if ($i == $iPunc - 1 and $iSign == 0) {
                //special case to return punc
                $units = bsw2unit($seg);
                foreach ($units as $j => $unit) {
                    if ($j + 1 < count($units)) {
                        $preLoc .= $unit;
                    } else {
                        $unitLoc = $unit;
                    }
                }
            } else {
                $preLoc .= $seg;
            }
        } else {
            if ($i > $iPunc) {
                $postLoc .= $seg;
            } else {
                //i == iPunc
                $units = bsw2unit($seg);
                foreach ($units as $j => $unit) {
                    if ($j + 1 < $iSign) {
                        $preLoc .= $unit;
                    } else {
                        if ($j + 1 > $iSign) {
                            $postLoc .= $unit;
                        } else {
                            //(j+1) == iSign
                            $unitLoc = $unit;
                        }
                    }
                }
            }
        }
    }
    $bsw_array[] = $preLoc;
    $bsw_array[] = $unitLoc;
    $bsw_array[] = $postLoc;
    return $bsw_array;
}
Esempio n. 2
0
echo '<body>';
include 'command.php';
echo '<div class="detail">';
$subhead = $msg['swis_format'];
include 'header.php';
//page header
echo '<center>' . "\n";
echo '<FORM name="bswform" onSubmit="return OnSubmitForm();" method="GET">' . "\n";
include 'intab.php';
echo '</center>';
//remove white space
$bsw = str_replace(" ", "", $bsw);
$bsw = str_replace("\n", "", $bsw);
$bsw = str_replace("\r", "", $bsw);
$bsw = str_replace("\t", "", $bsw);
$units = bsw2unit($bsw);
//4 formats...
$fbsw = '';
//binary signwriting
$fupua = '';
//unicode private use area
$fswcm = '';
//signwriting cartesian markup
$fswpm = '';
//signwriting polar markup
$fbswml = '';
//binary signwriting markup
foreach ($units as $ubsw) {
    if (isPunc($ubsw)) {
        $fbsw .= $ubsw . ' ';
        $fupua .= bsw2utf($ubsw) . ' ';
 public function __construct($bsw, $size = 1, $height = 1919, $spacing = 10, $offset = 50)
 {
     //set variables//
     $this->bsw = $bsw;
     $this->size = $size;
     $this->height = $height / $size;
     $this->spacing = $spacing;
     $this->offset = $offset;
     $this->units = bsw2unit($bsw);
     //init variables
     $curH = $this->padding;
     $prev = '';
     $col = '';
     $posX = array();
     $posY = array();
     //punc vs sign, spacing and lanes
     $prev = '';
     $cnt = count($this->units);
     for ($i = 0; $i < $cnt; $i++) {
         $unitbsw = $this->units[$i];
         $chars = str_split($unitbsw, 3);
         $first = $chars[0];
         //unit type for spacing test later
         if (isPunc($first)) {
             $cur = "P";
             //punctuation
             $lane = 0;
         } else {
             $cur = "S";
             //sign
             $lane = char2lane($first);
         }
         //adjust padding based on punc/sign order
         switch ($prev . $cur) {
             case 'SS':
                 //sign sign
                 $padding = $this->spacing * 2;
                 break;
             case 'SP':
                 //sign punctuation
             //sign punctuation
             case 'PP':
                 //punctuation punctuation
                 $padding = $this->spacing;
                 break;
             case 'PS':
                 //punctuation sign
                 $padding = $this->spacing * 3;
                 break;
             default:
                 $padding = 0;
         }
         $prev = $cur;
         if ($cur == "P") {
             $unit = new Symbol($unitbsw);
         } else {
             $unit = new Sign($first . bsw2cluster($unitbsw));
             $unitbsw = $unit->getBSW();
         }
         if ($curH + $padding + $unit->getHeight() < $this->height) {
             //go ahead and add
             $col .= $unitbsw;
             //this is the value to center
             $posX[] = $unit->getCenterX() - $this->offset * $lane;
             $posY[] = $curH + $padding;
             $curH += $padding + $unit->getHeight();
         } else {
             //finalize column list
             $this->cols[] = $col;
             $this->posX[] = $posX;
             $this->posY[] = $posY;
             $col = '';
             $posX = array();
             $posY = array();
             $curH = $this->padding;
             $prev = '';
             $i--;
         }
     }
     if ($col) {
         $this->cols[] = $col;
         $this->posX[] = $posX;
         $this->posY[] = $posY;
     }
 }