} else {
        $rf = 255;
        $gf = 255;
        $bf = 255;
    }
}
/**
 * Step 1: break apart
 */
$bases = array();
$fills = array();
$rots = array();
$xs = array();
$ys = array();
if ($bsw) {
    $bsw = bsw2cluster($bsw);
    $chars = str_split($bsw, 3);
    $cnt = count($chars);
    for ($i = 0; $i < $cnt; $i++) {
        $bases[] = $chars[$i];
        $i++;
        $fills[] = char2fill($chars[$i]);
        $i++;
        $rots[] = char2rot($chars[$i]);
        $i++;
        $xs[] = hex2num($chars[$i]);
        $i++;
        $ys[] = hex2num($chars[$i]);
    }
}
/**
Esempio n. 2
0
$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);
        $fswpm .= char2token($first);
        $fbswml .= '&lt;sign lane="' . char2lane($first) . '"&gt;<br>';
        for ($i = 0; $i < count($chars); $i++) {
            //first 3 are symbol
            $sbsw = $chars[$i];
            $i++;
            $sbsw .= $chars[$i];
            $i++;
            $sbsw .= $chars[$i];
            //next 2 are coordinates
            $i++;
            $sx = hex2num($chars[$i]);
$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++;
            $x = hex2num($chars[$i]);
            $i++;
            $y = hex2num($chars[$i]);
Esempio n. 4
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;
}
 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;
     }
 }