$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 .= '<punc>' . bsw2key($ubsw) . '</punc><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 .= '<sign lane="' . char2lane($first) . '"><br>'; for ($i = 0; $i < count($chars); $i++) { //first 3 are symbol $sbsw = $chars[$i]; $i++; $sbsw .= $chars[$i]; $i++;
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; } }