Example #1
0
 public function chunk($start, $size, $filter = null, $format = null)
 {
     $files = array();
     // On s'assure que le chunk ne déborde pas de l'arborescence
     if ($this->size() < $start) {
         throw new Exception('End of the tree');
     }
     $size = constrain($size, 0, $this->size());
     // On fetch en maaasse
     for ($i = $start; $i < $start + $size; $i++) {
         $file = $this->getFile($i);
         if ($filter ? $filter($file) : true) {
             if ($file !== false) {
                 $files[] = $format ? $format($file) : $file;
             }
         }
     }
     // Puis on envoie le tout
     return $files;
 }
Example #2
0
function validate_form_data(array $data) : array
{
    //Team Information validation
    $data['teamnum'] = mb_strtoupper($data['teamnum'], "UTF-8");
    $data['teamnum'] = htmlspecialchars($data['teamnum']);
    $data['teamname'] = htmlspecialchars($data['teamname']);
    $data['teamschool'] = htmlspecialchars($data['teamschool']);
    if ($data['robottype'] !== "preload" && $data['robottype'] !== "field") {
        throw new PDOException();
    }
    //Shooter data validation
    $data['shootertype'] = substr($data['shootertype'], 0, 4);
    $data['shooterdist'] = constrain($data['shooterdist'], 0, 15);
    $data['shooterspeed'] = nonneg($data['shooterspeed']);
    $data['shooterpositions'] = constrain($data['shooterpositions'], 0, 5);
    $data['shooterballsshot'] = nonneg($data['shooterballsshot']);
    $data['shooterballshit'] = nonneg($data['shooterballshit']);
    //Drive data validation
    $data['drivespeed'] = nonneg($data['drivespeed']);
    $data['drivepushingpower'] = nonneg($data['drivepushingpower']);
    $data['drivemaneuverability'] = nonneg($data['drivemaneuverability']);
    //Intake data validation
    $data['intakespeed'] = nonneg($data['intakespeed']);
    $data['intakeconsistency'] = constrain($data['intakeconsistency'], 0, 10);
    $data['intakecapacity'] = constrain($data['intakecapacity'], 0, 4);
    //Lift data validation
    if (isset($data['liftlow']) && $data['liftlow'] === "yes") {
        $data['liftlow'] = true;
    } else {
        $data['liftlow'] = false;
    }
    if (isset($data['lifthigh']) && $data['lifthigh'] === "yes") {
        $data['lifthigh'] = true;
    } else {
        $data['lifthigh'] = false;
    }
    $data['liftmaxweight'] = nonneg($data['liftmaxweight']);
    $data['liftspeed'] = constrain($data['liftspeed'], 0, 10);
    $data['liftreliability'] = constrain($data['liftreliability'], 0, 10);
    //Robot Build data validation
    $data['robotheight'] = constrain($data['robotheight'], 0, 18);
    $data['robotshooterheight'] = constrain($data['robotshooterheight'], 0, 18);
    $data['robotweight'] = nonneg($data['robotweight']);
    $data['robotbuildquality'] = constrain($data['robotbuildquality'], 0, 10);
    //Auton data validation
    $data['autonpointsscored'] = nonneg($data['autonpointsscored']);
    $data['autonpointsattempted'] = nonneg($data['autonpointsattempted']);
    $data['autonreliability'] = constrain($data['autonreliability'], 0, 10);
    //Driver Ability data validation
    $data['driverskill'] = constrain($data['driverskill'], 0, 10);
    $data['driverstrategy'] = constrain($data['driverstrategy'], 0, 10);
    $data['driverruleknowledge'] = constrain($data['driverruleknowledge'], 0, 10);
    //Qualifiers data validation
    $data['qualifiersmatchesplayed'] = nonneg($data['qualifiersmatchesplayed']);
    $data['qualifierswp'] = nonneg($data['qualifierswp']);
    $data['qualifierssp'] = nonneg($data['qualifierssp']);
    //Skills data validation
    $data['skillsdriver'] = nonneg($data['skillsdriver']);
    $data['skillsprog'] = nonneg($data['skillsprog']);
    //Notes data validation
    $data['message'] = htmlspecialchars($data['message']);
    //Return validated form data
    return $data;
}
function _writeSentence($image, $fg, $english, $sentenceRadius, $type)
{
    global $semirandom;
    global $count;
    $width = imagesx($image);
    $height = imagesy($image);
    $wordRadius = array();
    $float1 = 0;
    $float2 = 0;
    $english = trim($english);
    $charCount = 0;
    $Sentence = array();
    $Sentence = explode(" ", $english);
    $sentence = array();
    $punctuation = array();
    $apostrophes = array();
    for ($j = 0; $j < count($Sentence); $j++) {
        $word = array();
        $Sentence[$j] = implode("", explode(" ", $Sentence[$j]));
        $vowel = true;
        for ($i = 0; $i < strlen($Sentence[$j]); $i++) {
            $punctuation[$j] = '';
            $apostrophes[$j][$i] = false;
            if ($i != 0) {
                if ($Sentence[$j][$i] == $Sentence[$j][$i - 1]) {
                    $word[count($word) - 1] = $word[count($word) - 1] . '@';
                    continue;
                }
            }
            if ($Sentence[$j][$i] == 'a' || $Sentence[$j][$i] == 'e' || $Sentence[$j][$i] == 'i' || $Sentence[$j][$i] == 'o' || $Sentence[$j][$i] == 'u') {
                if ($vowel) {
                    $word[] = str($Sentence[$j][$i]);
                } else {
                    $word[count($word) - 1] = $word[count($word) - 1] . $Sentence[$j][$i];
                }
                $vowel = true;
            } else {
                if ($Sentence[$j][$i] == '.' || $Sentence[$j][$i] == '?' || $Sentence[$j][$i] == '!' || $Sentence[$j][$i] == '"' || $Sentence[$j][$i] == "'" || $Sentence[$j][$i] == '-' || $Sentence[$j][$i] == ',' || $Sentence[$j][$i] == ';' || $Sentence[$j][$i] == ':') {
                    if ($Sentence[$j][$i] == "'") {
                        $apostrophes[$j][$i] = true;
                    } else {
                        $punctuation[$j] = $Sentence[$j][$i];
                    }
                } else {
                    $word[] = str($Sentence[$j][$i]);
                    if ($Sentence[$j][$i] == 't' || $Sentence[$j][$i] == '$' || $Sentence[$j][$i] == 'r' || $Sentence[$j][$i] == 's' || $Sentence[$j][$i] == 'v' || $Sentence[$j][$i] == 'w') {
                        $vowel = true;
                    } else {
                        $vowel = false;
                    }
                }
            }
        }
        $sentence[$j] = $word;
        $charCount += count($word);
    }
    //stroke($fg);
    if ($type > 0) {
        //imagesetthickness($image, 3);
        imageellipse($image, $width / 2, $height / 2, $sentenceRadius * 2, $sentenceRadius * 2, $fg);
    }
    //imagesetthickness($image, 4);
    imageellipse($image, $width / 2, $height / 2, $sentenceRadius * 2 + 40, $sentenceRadius * 2 + 40, $fg);
    $pos = PI / 2;
    $maxRadius = 0;
    for ($i = 0; $i < count($sentence); $i++) {
        $wordRadius[] = constrain($sentenceRadius * count($sentence[$i]) / $charCount * 1.2, 0, $sentenceRadius / 2);
        if ($wordRadius[$i] > $maxRadius) {
            $maxRadius = $wordRadius[$i];
        }
    }
    $scaleFactor = $sentenceRadius / ($maxRadius + $sentenceRadius / 2);
    $distance = $scaleFactor * $sentenceRadius / 2;
    for ($i = 0; $i < count($wordRadius); $i++) {
        $wordRadius[$i] *= $scaleFactor;
    }
    $x = array();
    $y = array();
    //stroke($fg);
    for ($i = 0; $i < count($sentence); $i++) {
        $x[] = $width / 2 + $distance * cos($pos);
        $y[] = $height / 2 + $distance * sin($pos);
        $nextIndex = 0;
        if ($i != count($sentence) - 1) {
            $nextIndex = $i + 1;
        }
        $pos -= (double) (count($sentence[$i]) + count($sentence[$nextIndex])) / (2 * $charCount) * TWO_PI;
        $pX = $width / 2 + cos($pos + (double) (count($sentence[$i]) + count($sentence[$nextIndex])) / (2 * $charCount) * PI) * $sentenceRadius;
        $pY = $height / 2 + sin($pos + (double) (count($sentence[$i]) + count($sentence[$nextIndex])) / (2 * $charCount) * PI) * $sentenceRadius;
        switch ($punctuation[$i]) {
            case '.':
                imageellipse($image, $pX, $pY, 20, 20, $fg);
                break;
            case '?':
                _makeDots($image, $fg, $width / 2, $height / 2, $sentenceRadius * 1.4, 2, -1.2, 0.1);
                break;
            case '!':
                _makeDots($image, $fg, $width / 2, $height / 2, $sentenceRadius * 1.4, 3, -1.2, 0.1);
                break;
            case '"':
                imageline($image, $width / 2 + cos($pos + (double) (count($sentence[$i]) + count($sentence[$nextIndex])) / (2 * $charCount) * PI) * $sentenceRadius, $height / 2 + sin($pos + (double) (count($sentence[$i]) + count($sentence[$nextIndex])) / (2 * $charCount) * PI) * $sentenceRadius, $width / 2 + cos($pos + (double) (count($sentence[$i]) + count($sentence[$nextIndex])) / (2 * $charCount) * PI) * ($sentenceRadius + 20), $height / 2 + sin($pos + (double) (count($sentence[$i]) + count($sentence[$nextIndex])) / (2 * $charCount) * PI) * ($sentenceRadius + 20), $fg);
                break;
            case '-':
                imageline($image, $width / 2 + cos($pos + (double) (count($sentence[$i]) + count($sentence[$nextIndex])) / (2 * $charCount) * PI) * $sentenceRadius, $height / 2 + sin($pos + (double) (count($sentence[$i]) + count($sentence[$nextIndex])) / (2 * $charCount) * PI) * $sentenceRadius, $width / 2 + cos($pos + (double) (count($sentence[$i]) + count($sentence[$nextIndex])) / (2 * $charCount) * PI) * ($sentenceRadius + 20), $height / 2 + sin($pos + (double) (count($sentence[$i]) + count($sentence[$nextIndex])) / (2 * $charCount) * PI) * ($sentenceRadius + 20), $fg);
                imageline($image, $width / 2 + cos($pos + (count($sentence[$i]) + count($sentence[$nextIndex]) + 0.3) / (2 * $charCount) * PI) * $sentenceRadius, $height / 2 + sin($pos + (count($sentence[$i]) + count($sentence[$nextIndex]) + 0.2) / (2 * $charCount) * PI) * $sentenceRadius, $width / 2 + cos($pos + (count($sentence[$i]) + count($sentence[$nextIndex]) + 0.2) / (2 * $charCount) * PI) * ($sentenceRadius + 20), $height / 2 + sin($pos + (count($sentence[$i]) + count($sentence[$nextIndex]) + 0.3) / (2 * $charCount) * PI) * ($sentenceRadius + 20), $fg);
                imageline($image, $width / 2 + cos($pos + (count($sentence[$i]) + count($sentence[$nextIndex]) - 0.3) / (2 * $charCount) * PI) * $sentenceRadius, $height / 2 + sin($pos + (count($sentence[$i]) + count($sentence[$nextIndex]) - 0.2) / (2 * $charCount) * PI) * $sentenceRadius, $width / 2 + cos($pos + (count($sentence[$i]) + count($sentence[$nextIndex]) - 0.2) / (2 * $charCount) * PI) * ($sentenceRadius + 20), $height / 2 + sin($pos + (count($sentence[$i]) + count($sentence[$nextIndex]) - 0.3) / (2 * $charCount) * PI) * ($sentenceRadius + 20), $fg);
                break;
            case ',':
                //fill($fg);
                imagefilledellipse($image, $pX, $pY, 20, 20, $fg);
                //noFill();
                break;
            case ';':
                //fill($fg);
                imagefilledellipse($image, $width / 2 + cos($pos + (double) (count($sentence[$i]) + count($sentence[$nextIndex])) / (2 * $charCount) * PI) * $sentenceRadius - 10, $height / 2 + sin($pos + (double) (count($sentence[$i]) + count($sentence[$nextIndex])) / (2 * $charCount) * PI) * $sentenceRadius - 10, 10, 10, $fg);
                //noFill();
                break;
            case ':':
                imageellipse($image, $pX, $pY, 25, 25, $fg);
                //imagesetthickness($image, 2);
                imageellipse($image, $pX, $pY, 15, 15, $fg);
                //imagesetthickness($image, 4);
                break;
            default:
                break;
        }
    }
    $otherIndex = 0;
    $nested = array();
    for ($i = 0; $i < count($sentence); $i++) {
        $angle1 = 0;
        //angle facing onwards
        $angle2 = 0;
        //backwards
        if ($i == count($sentence) - 1) {
            $otherIndex = 0;
        } else {
            $otherIndex = $i + 1;
        }
        $angle1 = atan_wrapper($y[$i] - $y[$otherIndex], $x[$i] - $x[$otherIndex]);
        if (dist($x[$i] + cos($angle1) * 20, $y[$i] + sin($angle1) * 20, $x[$otherIndex], $y[$otherIndex]) > dist($x[$i], $y[$i], $x[$otherIndex], $y[$otherIndex])) {
            $angle1 -= PI;
        }
        if ($angle1 < 0) {
            $angle1 += TWO_PI;
        }
        if ($angle1 < 0) {
            $angle1 += TWO_PI;
        }
        $angle1 -= PI / 2;
        if ($angle1 < 0) {
            $angle1 += TWO_PI;
        }
        $angle1 = TWO_PI - $angle1;
        $index = round(map($angle1, 0, TWO_PI, 0, (double) count($sentence[$i])));
        if ($index == count($sentence[$i])) {
            $index = 0;
        }
        $tempChar = $sentence[$i][$index][0];
        if (($tempChar == 't' || $tempChar == '$' || $tempChar == 'r' || $tempChar == 's' || $tempChar == 'v' || $tempChar == 'w') && $type > 0) {
            $nested[$i][$index] = true;
            $wordRadius[$i] = constrain($wordRadius[$i] * 1.2, 0, $maxRadius * $scaleFactor);
            while (dist($x[$i], $y[$i], $x[$otherIndex], $y[$otherIndex]) > $wordRadius[$i] + $wordRadius[$otherIndex]) {
                $x[$i] = lerp($x[$i], $x[$otherIndex], 0.05);
                $y[$i] = lerp($y[$i], $y[$otherIndex], 0.05);
            }
        }
    }
    $lineX = array();
    $lineY = array();
    $arcBegin = array();
    $arcEnd = array();
    $lineRad = array();
    //imagesetthickness($image, 2);
    if ($type == 0) {
        $wordRadius[0] = $sentenceRadius * 0.9;
        $x[0] = $width / 2;
        $y[0] = $height / 2;
    }
    for ($i = 0; $i < count($sentence); $i++) {
        $pos = PI / 2;
        $letterRadius = $wordRadius[$i] / (count($sentence[$i]) + 1) * 1.5;
        for ($j = 0; $j < count($sentence[$i]); $j++) {
            if ($apostrophes[$i][$j]) {
                $a = $pos + PI / count($sentence[$i]) - 0.1;
                $d = 0;
                $tempX = $x[$i];
                $tempY = $y[$i];
                while (pow($tempX - $width / 2, 2) + pow($tempY - $height / 2, 2) < pow($sentenceRadius + 20, 2)) {
                    $tempX = $x[$i] + cos($a) * $d;
                    $tempY = $y[$i] + sin($a) * $d;
                    $d += 1;
                }
                imageline($image, $x[$i] + cos($a) * $wordRadius[$i], $y[$i] + sin($a) * $wordRadius[$i], $tempX, $tempY, $fg);
                $a = $pos + PI / count($sentence[$i]) + 0.1;
                $d = 0;
                $tempX = $x[$i];
                $tempY = $y[$i];
                while (pow($tempX - $width / 2, 2) + pow($tempY - $height / 2, 2) < pow($sentenceRadius + 20, 2)) {
                    $tempX = $x[$i] + cos($a) * $d;
                    $tempY = $y[$i] + sin($a) * $d;
                    $d += 1;
                }
                imageline($image, $x[$i] + cos($a) * $wordRadius[$i], $y[$i] + sin($a) * $wordRadius[$i], $tempX, $tempY, $fg);
            }
            $vowel = true;
            $tempX = 0;
            $tempY = 0;
            //single vowels
            if ($sentence[$i][$j][0] == 'a') {
                $tempX = $x[$i] + cos($pos) * ($wordRadius[$i] + $letterRadius / 2);
                $tempY = $y[$i] + sin($pos) * ($wordRadius[$i] + $letterRadius / 2);
                imageellipse($image, $tempX, $tempY, $letterRadius, $letterRadius, $fg);
            } else {
                if ($sentence[$i][$j][0] == 'e') {
                    $tempX = $x[$i] + cos($pos) * $wordRadius[$i];
                    $tempY = $y[$i] + sin($pos) * $wordRadius[$i];
                    imageellipse($image, $tempX, $tempY, $letterRadius, $letterRadius, $fg);
                } else {
                    if ($sentence[$i][$j][0] == 'i') {
                        $tempX = $x[$i] + cos($pos) * $wordRadius[$i];
                        $tempY = $y[$i] + sin($pos) * $wordRadius[$i];
                        imageellipse($image, $tempX, $tempY, $letterRadius, $letterRadius, $fg);
                        $lineX[] = $tempX;
                        $lineY[] = $tempY;
                        $arcBegin[] = $pos + PI / 2;
                        $arcEnd[] = $pos + 3 * PI / 2;
                        $lineRad[] = $letterRadius;
                    } else {
                        if ($sentence[$i][$j][0] == 'o') {
                            $tempX = $x[$i] + cos($pos) * ($wordRadius[$i] - $letterRadius / 1.6);
                            $tempY = $y[$i] + sin($pos) * ($wordRadius[$i] - $letterRadius / 1.6);
                            imageellipse($image, $tempX, $tempY, $letterRadius, $letterRadius, $fg);
                        } else {
                            if ($sentence[$i][$j][0] == 'u') {
                                $tempX = $x[$i] + cos($pos) * $wordRadius[$i];
                                $tempY = $y[$i] + sin($pos) * $wordRadius[$i];
                                imageellipse($image, $tempX, $tempY, $letterRadius, $letterRadius, $fg);
                                $lineX[] = $tempX;
                                $lineY[] = $tempY;
                                $arcBegin[] = $pos - PI / 2;
                                $arcEnd[] = $pos + PI / 2;
                                $lineRad[] = $letterRadius;
                            } else {
                                $vowel = false;
                            }
                        }
                    }
                }
            }
            if ($vowel) {
                imagearc_radians($image, $x[$i], $y[$i], $wordRadius[$i] * 2, $wordRadius[$i] * 2, $pos - PI / count($sentence[$i]), $pos + PI / count($sentence[$i]), $fg);
                if (strlen($sentence[$i][$j]) == 1) {
                } else {
                    //double vowels
                    if ($sentence[$i][$j][1] == '@') {
                        imageellipse($image, $tempX, $tempY, $letterRadius * 1.3, $letterRadius * 1.3, $fg);
                    }
                }
            } else {
                // consonants
                if ($sentence[$i][$j][0] == 'b' || $sentence[$i][$j][0] == '#' || $sentence[$i][$j][0] == 'd' || $sentence[$i][$j][0] == 'f' || $sentence[$i][$j][0] == 'g' || $sentence[$i][$j][0] == 'h') {
                    $tempX = $x[$i] + cos($pos) * ($wordRadius[$i] - $letterRadius * 0.95);
                    $tempY = $y[$i] + sin($pos) * ($wordRadius[$i] - $letterRadius * 0.95);
                    _makeArcs($image, $fg, $tempX, $tempY, $x[$i], $y[$i], $wordRadius[$i], $letterRadius, $pos - PI / count($sentence[$i]), $pos + PI / count($sentence[$i]), $float1, $float2);
                    $lines = 0;
                    if ($sentence[$i][$j][0] == '#') {
                        _makeDots($image, $fg, $tempX, $tempY, $letterRadius, 2, $pos, 1);
                    } else {
                        if ($sentence[$i][$j][0] == 'd') {
                            _makeDots($image, $fg, $tempX, $tempY, $letterRadius, 3, $pos, 1);
                        } else {
                            if ($sentence[$i][$j][0] == 'f') {
                                $lines = 3;
                            } else {
                                if ($sentence[$i][$j][0] == 'g') {
                                    $lines = 1;
                                } else {
                                    if ($sentence[$i][$j][0] == 'h') {
                                        $lines = 2;
                                    }
                                }
                            }
                        }
                    }
                    for ($k = 0; $k < $lines; $k++) {
                        $lineX[] = $tempX;
                        $lineY[] = $tempY;
                        $arcBegin[] = $pos + 0.5;
                        $arcEnd[] = $pos + TWO_PI - 0.5;
                        $lineRad[] = $letterRadius * 2;
                    }
                    if (strlen($sentence[$i][$j]) > 1) {
                        $vowelIndex = 1;
                        if ($sentence[$i][$j][1] == '@') {
                            _makeArcs($image, $fg, $tempX, $tempY, $x[$i], $y[$i], $wordRadius[$i], $letterRadius * 1.3, $pos + TWO_PI, $pos - TWO_PI, $float1, $float2);
                            $vowelIndex = 2;
                        }
                        if (strlen($sentence[$i][$j]) == $vowelIndex) {
                            $pos -= TWO_PI / count($sentence[$i]);
                            continue;
                        }
                        if ($sentence[$i][$j][$vowelIndex] == 'a') {
                            $tempX = $x[$i] + cos($pos) * ($wordRadius[$i] + $letterRadius / 2);
                            $tempY = $y[$i] + sin($pos) * ($wordRadius[$i] + $letterRadius / 2);
                            imageellipse($image, $tempX, $tempY, $letterRadius, $letterRadius, $fg);
                        } else {
                            if ($sentence[$i][$j][$vowelIndex] == 'e') {
                                imageellipse($image, $tempX, $tempY, $letterRadius, $letterRadius, $fg);
                            } else {
                                if ($sentence[$i][$j][$vowelIndex] == 'i') {
                                    imageellipse($image, $tempX, $tempY, $letterRadius, $letterRadius, $fg);
                                    $lineX[] = $tempX;
                                    $lineY[] = $tempY;
                                    $arcBegin[] = $pos + PI / 2;
                                    $arcEnd[] = $pos + 3 * PI / 2;
                                    $lineRad[] = $letterRadius;
                                } else {
                                    if ($sentence[$i][$j][$vowelIndex] == 'o') {
                                        $tempX = $x[$i] + cos($pos) * ($wordRadius[$i] - $letterRadius * 2);
                                        $tempY = $y[$i] + sin($pos) * ($wordRadius[$i] - $letterRadius * 2);
                                        imageellipse($image, $tempX, $tempY, $letterRadius, $letterRadius, $fg);
                                    } else {
                                        if ($sentence[$i][$j][$vowelIndex] == 'u') {
                                            imageellipse($image, $tempX, $tempY, $letterRadius, $letterRadius, $fg);
                                            $lineX[] = $tempX;
                                            $lineY[] = $tempY;
                                            $arcBegin[] = $pos - PI / 2;
                                            $arcEnd[] = $pos + PI / 2;
                                            $lineRad[] = $letterRadius;
                                        }
                                    }
                                }
                            }
                        }
                        if (strlen($sentence[$i][$j]) == $vowelIndex + 2) {
                            if ($sentence[$i][$j][$vowelIndex + 1] == '@') {
                                imageellipse($image, $tempX, $tempY, $letterRadius * 1.3, $letterRadius * 1.3, $fg);
                            }
                        }
                    }
                }
                if ($sentence[$i][$j][0] == 'j' || $sentence[$i][$j][0] == 'k' || $sentence[$i][$j][0] == 'l' || $sentence[$i][$j][0] == 'm' || $sentence[$i][$j][0] == 'n' || $sentence[$i][$j][0] == 'p') {
                    $tempX = $x[$i] + cos($pos) * ($wordRadius[$i] - $letterRadius);
                    $tempY = $y[$i] + sin($pos) * ($wordRadius[$i] - $letterRadius);
                    imageellipse($image, $tempX, $tempY, $letterRadius * 1.9, $letterRadius * 1.9, $fg);
                    imagearc_radians($image, $x[$i], $y[$i], $wordRadius[$i] * 2, $wordRadius[$i] * 2, $pos - PI / count($sentence[$i]), $pos + PI / count($sentence[$i]), $fg);
                    $lines = 0;
                    if ($sentence[$i][$j][0] == 'k') {
                        _makeDots($image, $fg, $tempX, $tempY, $letterRadius, 2, $pos, 1);
                    } else {
                        if ($sentence[$i][$j][0] == 'l') {
                            _makeDots($image, $fg, $tempX, $tempY, $letterRadius, 3, $pos, 1);
                        } else {
                            if ($sentence[$i][$j][0] == 'm') {
                                $lines = 3;
                            } else {
                                if ($sentence[$i][$j][0] == 'n') {
                                    $lines = 1;
                                } else {
                                    if ($sentence[$i][$j][0] == 'p') {
                                        $lines = 2;
                                    }
                                }
                            }
                        }
                    }
                    for ($k = 0; $k < $lines; $k++) {
                        $lineX[] = $tempX;
                        $lineY[] = $tempY;
                        $arcBegin[] = 0;
                        $arcEnd[] = TWO_PI;
                        $lineRad[] = $letterRadius * 1.9;
                    }
                    if (strlen($sentence[$i][$j]) > 1) {
                        $vowelIndex = 1;
                        if ($sentence[$i][$j][1] == '@') {
                            imageellipse($image, $tempX, $tempY, $letterRadius * 2.3, $letterRadius * 2.3, $fg);
                            $vowelIndex = 2;
                        }
                        if (strlen($sentence[$i][$j]) == $vowelIndex) {
                            $pos -= TWO_PI / count($sentence[$i]);
                            continue;
                        }
                        if ($sentence[$i][$j][$vowelIndex] == 'a') {
                            $tempX = $x[$i] + cos($pos) * ($wordRadius[$i] + $letterRadius / 2);
                            $tempY = $y[$i] + sin($pos) * ($wordRadius[$i] + $letterRadius / 2);
                            imageellipse($image, $tempX, $tempY, $letterRadius, $letterRadius, $fg);
                        } else {
                            if ($sentence[$i][$j][$vowelIndex] == 'e') {
                                imageellipse($image, $tempX, $tempY, $letterRadius, $letterRadius, $fg);
                            } else {
                                if ($sentence[$i][$j][$vowelIndex] == 'i') {
                                    imageellipse($image, $tempX, $tempY, $letterRadius, $letterRadius, $fg);
                                    $lineX[] = $tempX;
                                    $lineY[] = $tempY;
                                    $arcBegin[] = $pos + PI / 2;
                                    $arcEnd[] = $pos + 3 * PI / 2;
                                    $lineRad[] = $letterRadius;
                                } else {
                                    if ($sentence[$i][$j][$vowelIndex] == 'o') {
                                        $tempX = $x[$i] + cos($pos) * ($wordRadius[$i] - $letterRadius * 2);
                                        $tempY = $y[$i] + sin($pos) * ($wordRadius[$i] - $letterRadius * 2);
                                        imageellipse($image, $tempX, $tempY, $letterRadius, $letterRadius, $fg);
                                    } else {
                                        if ($sentence[$i][$j][$vowelIndex] == 'u') {
                                            imageellipse($image, $tempX, $tempY, $letterRadius, $letterRadius, $fg);
                                            $lineX[] = $tempX;
                                            $lineY[] = $tempY;
                                            $arcBegin[] = $pos - PI / 2;
                                            $arcEnd[] = $pos + PI / 2;
                                            $lineRad[] = $letterRadius;
                                        }
                                    }
                                }
                            }
                        }
                        if (strlen($sentence[$i][$j]) == $vowelIndex + 2) {
                            if ($sentence[$i][$j][$vowelIndex + 1] == '@') {
                                imageellipse($image, $tempX, $tempY, $letterRadius * 1.3, $letterRadius * 1.3, $fg);
                            }
                        }
                    }
                }
                if ($sentence[$i][$j][0] == 't' || $sentence[$i][$j][0] == '$' || $sentence[$i][$j][0] == 'r' || $sentence[$i][$j][0] == 's' || $sentence[$i][$j][0] == 'v' || $sentence[$i][$j][0] == 'w') {
                    $tempX = $x[$i] + cos($pos) * $wordRadius[$i];
                    $tempY = $y[$i] + sin($pos) * $wordRadius[$i];
                    $nextIndex;
                    if ($i == count($sentence) - 1) {
                        $nextIndex = 0;
                    } else {
                        $nextIndex = $i + 1;
                    }
                    $angle1 = atan_wrapper($y[$i] - $y[$nextIndex], $x[$i] - $x[$nextIndex]);
                    if (dist($x[$i] + cos($angle1) * 20, $y[$i] + sin($angle1) * 20, $x[$nextIndex], $y[$nextIndex]) > dist($x[$i], $y[$i], $x[$nextIndex], $y[$nextIndex])) {
                        $angle1 -= PI;
                    }
                    if ($angle1 < 0) {
                        $angle1 += TWO_PI;
                    }
                    if ($angle1 < 0) {
                        $angle1 += TWO_PI;
                    }
                    if (isset($nested[$i][$j])) {
                        _makeArcs($image, $fg, $x[$nextIndex], $y[$nextIndex], $x[$i], $y[$i], $wordRadius[$i], $wordRadius[$nextIndex] + 20, $pos - PI / count($sentence[$i]), $pos + PI / count($sentence[$i]), $float1, $float2);
                    } else {
                        _makeArcs($image, $fg, $tempX, $tempY, $x[$i], $y[$i], $wordRadius[$i], $letterRadius * 1.5, $pos - PI / count($sentence[$i]), $pos + PI / count($sentence[$i]), $float1, $float2);
                    }
                    $lines = 0;
                    if ($sentence[$i][$j][0] == '$') {
                        if (isset($nested[$i][$j])) {
                            _makeDots($image, $fg, $x[$nextIndex], $y[$nextIndex], $wordRadius[$nextIndex] * 1.4 + 14, 2, $angle1, $wordRadius[$nextIndex] / 500);
                        } else {
                            _makeDots($image, $fg, $tempX, $tempY, $letterRadius * 2.6, 2, $pos, 0.5);
                        }
                    } else {
                        if ($sentence[$i][$j][0] == 'r') {
                            if (isset($nested[$i][$j])) {
                                _makeDots($image, $fg, $x[$nextIndex], $y[$nextIndex], $wordRadius[$nextIndex] * 1.4 + 14, 3, $angle1, $wordRadius[$nextIndex] / 500);
                            } else {
                                _makeDots($image, $fg, $tempX, $tempY, $letterRadius * 2.6, 3, $pos, 0.5);
                            }
                        } else {
                            if ($sentence[$i][$j][0] == 's') {
                                $lines = 3;
                            } else {
                                if ($sentence[$i][$j][0] == 'v') {
                                    $lines = 1;
                                } else {
                                    if ($sentence[$i][$j][0] == 'w') {
                                        $lines = 2;
                                    }
                                }
                            }
                        }
                    }
                    if (isset($nested[$i][$j])) {
                        for ($k = 0; $k < $lines; $k++) {
                            $lineX[] = $x[$nextIndex];
                            $lineY[] = $y[$nextIndex];
                            $arcBegin[] = $float1;
                            $arcEnd[] = $float2;
                            $lineRad[] = $wordRadius[$nextIndex] * 2 + 40;
                        }
                    } else {
                        for ($k = 0; $k < $lines; $k++) {
                            $lineX[] = $tempX;
                            $lineY[] = $tempY;
                            $arcBegin[] = $float1;
                            $arcEnd[] = $float2;
                            $lineRad[] = $letterRadius * 3;
                        }
                    }
                    if (strlen($sentence[$i][$j]) > 1) {
                        if ($sentence[$i][$j][1] == '@') {
                            if (isset($nested[$i][$j])) {
                                _makeArcs($image, $fg, $x[$nextIndex], $y[$nextIndex], $x[$i], $y[$i], $wordRadius[$i], ($wordRadius[$nextIndex] + 20) * 1.2, $pos + TWO_PI, $pos - TWO_PI, $float1, $float2);
                            } else {
                                _makeArcs($image, $fg, $tempX, $tempY, $x[$i], $y[$i], $wordRadius[$i], $letterRadius * 1.8, $pos + TWO_PI, $pos - TWO_PI, $float1, $float2);
                            }
                        }
                    }
                }
                if ($sentence[$i][$j][0] == '%' || $sentence[$i][$j][0] == 'y' || $sentence[$i][$j][0] == 'z' || $sentence[$i][$j][0] == '&' || $sentence[$i][$j][0] == 'q' || $sentence[$i][$j][0] == 'x') {
                    $tempX = $x[$i] + cos($pos) * $wordRadius[$i];
                    $tempY = $y[$i] + sin($pos) * $wordRadius[$i];
                    imageellipse($image, $tempX, $tempY, $letterRadius * 2, $letterRadius * 2, $fg);
                    imagearc_radians($image, $x[$i], $y[$i], $wordRadius[$i] * 2, $wordRadius[$i] * 2, $pos - PI / count($sentence[$i]), $pos + PI / count($sentence[$i]), $fg);
                    $lines = 0;
                    if ($sentence[$i][$j][0] == 'y') {
                        _makeDots($image, $fg, $tempX, $tempY, $letterRadius, 2, $pos, 1);
                    } else {
                        if ($sentence[$i][$j][0] == 'z') {
                            _makeDots($image, $fg, $tempX, $tempY, $letterRadius, 3, $pos, 1);
                        } else {
                            if ($sentence[$i][$j][0] == '&') {
                                $lines = 3;
                            } else {
                                if ($sentence[$i][$j][0] == 'q') {
                                    $lines = 1;
                                } else {
                                    if ($sentence[$i][$j][0] == 'x') {
                                        $lines = 2;
                                    }
                                }
                            }
                        }
                    }
                    for ($k = 0; $k < $lines; $k++) {
                        $lineX[] = $tempX;
                        $lineY[] = $tempY;
                        $arcBegin[] = 0;
                        $arcEnd[] = TWO_PI;
                        $lineRad[] = $letterRadius * 2;
                    }
                    if (strlen($sentence[$i][$j]) > 1) {
                        $vowelIndex = 1;
                        if ($sentence[$i][$j][1] == '@') {
                            imageellipse($image, $tempX, $tempY, $letterRadius * 2.3, $letterRadius * 2.3, $fg);
                            $vowelIndex = 2;
                        }
                        if (strlen($sentence[$i][$j]) == $vowelIndex) {
                            $pos -= TWO_PI / count($sentence[$i]);
                            continue;
                        }
                        if ($sentence[$i][$j][$vowelIndex] == 'a') {
                            $tempX = $x[$i] + cos($pos) * ($wordRadius[$i] + $letterRadius / 2);
                            $tempY = $y[$i] + sin($pos) * ($wordRadius[$i] + $letterRadius / 2);
                            imageellipse($image, $tempX, $tempY, $letterRadius, $letterRadius, $fg);
                        } else {
                            if ($sentence[$i][$j][$vowelIndex] == 'e') {
                                imageellipse($image, $tempX, $tempY, $letterRadius, $letterRadius, $fg);
                            } else {
                                if ($sentence[$i][$j][$vowelIndex] == 'i') {
                                    imageellipse($image, $tempX, $tempY, $letterRadius, $letterRadius, $fg);
                                    $lineX[] = $tempX;
                                    $lineY[] = $tempY;
                                    $arcBegin[] = $pos + PI / 2;
                                    $arcEnd[] = $pos + 3 * PI / 2;
                                    $lineRad[] = $letterRadius;
                                } else {
                                    if ($sentence[$i][$j][$vowelIndex] == 'o') {
                                        $tempX = $x[$i] + cos($pos) * ($wordRadius[$i] - $letterRadius);
                                        $tempY = $y[$i] + sin($pos) * ($wordRadius[$i] - $letterRadius);
                                        imageellipse($image, $tempX, $tempY, $letterRadius, $letterRadius, $fg);
                                    } else {
                                        if ($sentence[$i][$j][$vowelIndex] == 'u') {
                                            imageellipse($image, $tempX, $tempY, $letterRadius, $letterRadius, $fg);
                                            $lineX[] = $tempX;
                                            $lineY[] = $tempY;
                                            $arcBegin[] = $pos - PI / 2;
                                            $arcEnd[] = $pos + PI / 2;
                                            $lineRad[] = $letterRadius;
                                        }
                                    }
                                }
                            }
                        }
                        if (strlen($sentence[$i][$j]) == $vowelIndex + 2) {
                            if ($sentence[$i][$j][$vowelIndex + 1] == '@') {
                                imageellipse($image, $tempX, $tempY, $letterRadius * 1.8, $letterRadius * 1.8, $fg);
                            }
                        }
                    }
                }
            }
            $pos -= TWO_PI / count($sentence[$i]);
        }
    }
    //imagesetthickness($image, 2);
    $lineLengths = array();
    //stroke($fg);
    $used = new UsedLines();
    for ($i = 0; $i < count($lineX); $i++) {
        $indexes = array();
        $angles = array();
        for ($j = 0; $j < count($lineX); $j++) {
            if (round($lineY[$i]) == round($lineY[$j]) && round($lineX[$i]) == round($lineX[$j])) {
                continue;
            }
            if ($used->exists($lineX[$i], $lineY[$i], $lineX[$j], $lineY[$j])) {
                continue;
            }
            $b = false;
            for ($k = 0; $k < count($lineLengths); $k++) {
                if ($lineLengths[$k] == dist($lineX[$i], $lineY[$i], $lineX[$j], $lineY[$j]) + $lineX[$i] + $lineY[$i] + $lineX[$j] + $lineY[$j]) {
                    $b = true;
                    break;
                }
            }
            if ($b) {
                continue;
            }
            $angle1 = atan_wrapper($lineY[$i] - $lineY[$j], $lineX[$i] - $lineX[$j]);
            if (dist($lineX[$i] + cos($angle1) * 20, $lineY[$i] + sin($angle1) * 20, $lineX[$j], $lineY[$j]) > dist($lineX[$i], $lineY[$i], $lineX[$j], $lineY[$j])) {
                $angle1 -= PI;
            }
            if ($angle1 < 0) {
                $angle1 += TWO_PI;
            }
            if ($angle1 < 0) {
                $angle1 += TWO_PI;
            }
            if ($angle1 < $arcEnd[$i] && $angle1 > $arcBegin[$i]) {
                $angle1 -= PI;
                if ($angle1 < 0) {
                    $angle1 += TWO_PI;
                }
                if ($angle1 < $arcEnd[$j] && $angle1 > $arcBegin[$j]) {
                    $indexes[] = $j;
                    $angles[] = $angle1;
                }
            }
        }
        if (count($indexes) == 0) {
            $a = 0;
            if ($semirandom) {
                $a = map(noise($count + $i * 5), 0, 1, $arcBegin[$i], $arcEnd[$i]);
            } else {
                $a = random($arcBegin[$i], $arcEnd[$i]);
            }
            $d = 0;
            $tempX = $lineX[$i] + cos($a) * $d;
            $tempY = $lineY[$i] + sin($a) * $d;
            while (pow($tempX - $width / 2, 2) + pow($tempY - $height / 2, 2) < pow($sentenceRadius + 20, 2)) {
                $tempX = $lineX[$i] + cos($a) * $d;
                $tempY = $lineY[$i] + sin($a) * $d;
                $d += 1;
            }
            imageline($image, $lineX[$i] + cos($a) * $lineRad[$i] / 2, $lineY[$i] + sin($a) * $lineRad[$i] / 2, $tempX, $tempY, $fg);
        } else {
            $r;
            if ($semirandom) {
                $r = 0;
            } else {
                $r = floor(random(count($indexes)));
            }
            $j = $indexes[$r];
            $a = $angles[$r] + PI;
            imageline($image, $lineX[$i] + cos($a) * $lineRad[$i] / 2, $lineY[$i] + sin($a) * $lineRad[$i] / 2, $lineX[$j] + cos($a + PI) * $lineRad[$j] / 2, $lineY[$j] + sin($a + PI) * $lineRad[$j] / 2, $fg);
            $lineLengths[] = dist($lineX[$i], $lineY[$i], $lineX[$j], $lineY[$j] + $lineX[$i] + $lineY[$i] + $lineX[$j] + $lineY[$j]);
            $used->add($lineX[$i], $lineY[$i], $lineX[$j], $lineY[$j]);
            $templineX = array();
            $templineY = array();
            $temparcBegin = array();
            $temparcEnd = array();
            $templineRad = array();
            for ($k = 0; $k < count($lineX); $k++) {
                if ($k != $j && $k != $i) {
                    $templineX[] = $lineX[$k];
                    $templineY[] = $lineY[$k];
                    $temparcBegin[] = $arcBegin[$k];
                    $temparcEnd[] = $arcEnd[$k];
                    $templineRad[] = $lineRad[$k];
                }
            }
            $lineX = $templineX;
            $lineY = $templineY;
            $arcBegin = $temparcBegin;
            $arcEnd = $temparcEnd;
            $lineRad = $templineRad;
            $i -= 1;
        }
    }
}