Exemplo n.º 1
0
$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) . ' ';
        $fswcm .= bsw2utf($ubsw, 1);
        $fswpm .= bsw2utf($ubsw, 1);
        $fbswml .= '&lt;punc&gt;' . bsw2key($ubsw) . '&lt;/punc&gt;<br>';
    } else {
        $unit = new Sign($ubsw);
        $ubsw = moveBSW($unit->getBSW(), $unit->getCenterX(), $unit->getCenterY());
        $fbsw .= $ubsw . ' ';
        $fupua .= bsw2utf($ubsw) . ' ';
        $first = substr($ubsw, 0, 3);
        $cluster = bsw2cluster($ubsw);
        $seq = bsw2seq($ubsw);
        $chars = str_split($cluster, 3);
        $fswcm .= char2token($first);
Exemplo n.º 2
0
function moveBSW($bsw, $mx, $my)
{
    if (isPunc($bsw)) {
        return $bsw;
    }
    $first = substr($bsw, 0, 3);
    $cluster = bsw2cluster($bsw);
    $seq = bsw2seq($bsw);
    $chars = str_split($cluster, 3);
    $bsw = $first;
    for ($i = 0; $i < count($chars); $i++) {
        //sym as base,fill,rot
        $bsw .= $chars[$i++];
        $bsw .= $chars[$i++];
        $bsw .= $chars[$i++];
        //move x and y
        $x = $chars[$i++];
        $bsw .= num2hex(hex2num($x) - $mx);
        $y = $chars[$i];
        $bsw .= num2hex(hex2num($y) - $my);
    }
    if ($seq) {
        $bsw .= '0fd' . $seq;
    }
    return $bsw;
}
Exemplo n.º 3
0
        $extra .= '&pad=' . $pad;
    }
    if ($bound != "t") {
        $extra .= '&bound=' . $bound;
    }
    if ($colorize) {
        $extra .= '&colorize=1';
    } else {
        $extra .= '&line=' . $line;
    }
    $extra .= '&fill=' . $fill;
    $extra .= '&back=' . $back;
    if ($view) {
        $units = bsw2unit($bsw);
        $units = array_unique($units);
        sort($units, SORT_STRING);
        foreach ($units as $bsw) {
            $base = substr($bsw, 0, 3);
            if (isPunc($base)) {
                echo '<p><img src="glyph.php?bsw=' . $bsw . $extra . '&name=' . $bsw . '">';
            } else {
                echo '<p><img src="glyphogram.php?bsw=' . $bsw . $extra . '&name=' . $bsw . '">';
            }
        }
    }
}
?>
</div>
</body>
</html>
Exemplo n.º 4
0
 *   
 */
$st = new SignText($bsw, $size, $height - $top_pad, $spacing, $offset);
$cols = $st->getCols();
$posX = $st->getPosX();
$posY = $st->getPosY();
$bsw = $cols[$col];
$units = bsw2unit($bsw);
$xpos = $posX[$col];
$ypos = $posY[$col];
$data = '';
foreach ($units as $u => $unit) {
    $xadj = $xpos[$u];
    $yadj = $ypos[$u];
    $first = substr($unit, 0, 3);
    if (isPunc($first)) {
        $data .= $unit . num2hex(-$xadj) . num2hex($yadj);
    } else {
        $bsw = bsw2cluster($unit);
        $chars = str_split($bsw, 3);
        $cnt = count($chars);
        if ($bsw == "") {
            $cnt = 0;
        }
        for ($i = 0; $i < $cnt; $i++) {
            $char = $chars[$i];
            $i++;
            $cfill = $chars[$i];
            $i++;
            $crot = $chars[$i];
            $i++;
Exemplo n.º 5
0
 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;
     }
 }