Esempio n. 1
0
function start()
{
    global $stopTime, $iterations, $T, $res, $n, $m;
    $stopTime = microtime(true) + $T;
    // NOW + T seconds
    while (microtime(true) < $stopTime) {
        reinit();
        calc();
        $iterations++;
    }
    $iterations--;
    // last iteration started before time was up but finished after time was up
    // required '>' mark for automatic benchmark
    print "> {$iterations} iterations\n";
    print "Resulting F(W, S) = {$res[0]}\n";
    outputText();
}
Esempio n. 2
0
        $output = algebra2tex($algebra);
    }
    if (strpos($query, 'TeXStage2')) {
        $output = algebra2tex($algebra);
        $output = refineTeX($output);
    }
    if (strpos($query, 'ShowImage') || strpos($query, 'SlashArguments')) {
        $output = algebra2tex($algebra);
        $output = refineTeX($output);
        if (strpos($query, 'ShowImage')) {
            tex2image($output, $md5);
        } else {
            slasharguments($output, $md5);
        }
    } else {
        outputText($output);
    }
    exit;
}
function algebra2tex($algebra)
{
    global $CFG;
    $algebra = str_replace('&lt;', '<', $algebra);
    $algebra = str_replace('&gt;', '>', $algebra);
    $algebra = str_replace('<>', '#', $algebra);
    $algebra = str_replace('<=', '%', $algebra);
    $algebra = str_replace('>=', '!', $algebra);
    $algebra = preg_replace('/([=><%!#] *)-/', "\$1 zeroplace -", $algebra);
    $algebra = str_replace('delta', 'zdelta', $algebra);
    $algebra = str_replace('beta', 'bita', $algebra);
    $algebra = str_replace('theta', 'thita', $algebra);
Esempio n. 3
0
         $stmt = $db->prepare($sql);
         $stmt->bindParam(':id', $ID);
     }
     $stmt->execute();
     $row = $stmt->fetch();
     if ($row['ID'] == null) {
         die("105");
     }
     global $downloads;
     $downloads = $row['downloads'] + 1;
     switch ($Type) {
         case "JSON":
             echo outputJSON($row);
             break;
         case "TEXT":
             echo outputText($row);
             break;
         case "YAML":
             echo outputYaml($row);
             break;
         case "ID":
             echo outputID($row);
             break;
         case "DUMP":
             echo outputDump($row);
             break;
         default:
             echo outputJSON($row);
             break;
     }
 }
foreach ($outputColors as $outputColorCode => $outputColorParam) {
    outputText("Generating icon color of '{$outputColorCode}px'... ");
    foreach ($outputSizes as $outputSize) {
        $htmlBuffer = sprintf('<h1>%s</h1><p>Generated by <a href="%s">%s</a> on %s</p>', $CONFIGS['font'], "https://github.com/exiang/php-font-awesome-to-png", "php-font-awesome-to-png", date("r")) . "\n\n";
        outputText("Generating icon size of '{$outputSize}px'... ");
        $size = $width = $height = $outputSize * 3;
        $fontSize = $outputSize;
        $padding = (int) ceil($outputSize / 25);
        // The text to draw
        foreach ($icons as $iKey => $iParam) {
            outputText("Generating icon '{$iKey}'... ");
            $text = $iParam['code'];
            $fileName = sprintf("%s/%s/%s/%s.png", $outputDir, $outputColorCode, $outputSize, $iKey);
            $dirPath = dirname($fileName);
            if (!is_dir($dirPath) || !file_exists($dirPath)) {
                outputText("Try to create '{$dirPath}'... ");
                mkdir_recursive($dirPath, 0777);
            }
            // Create the image
            $im = imagecreatetruecolor($width, $height);
            imagealphablending($im, false);
            // Create some colors
            $fontC = imagecolorallocate($im, $outputColorParam['r'], $outputColorParam['g'], $outputColorParam['b']);
            $bgc = imagecolorallocatealpha($im, 255, 0, 255, 127);
            imagefilledrectangle($im, 0, 0, $width, $height, $bgc);
            imagealphablending($im, true);
            // Add the text
            list($fontX, $fontY) = ImageTTFCenter($im, $text, $font, $fontSize);
            imagettftext($im, $fontSize, 0, $fontX, $fontY, $fontC, $font, $text);
            // Using imagepng() results in clearer text compared with imagejpeg()
            imagealphablending($im, false);
Esempio n. 5
0
/**
 * Shortcut for {@link outputText}
 *
 * @param string $text Text to display
 * @param int $cat Category of text, such as PECHO_WARN, PECHO_NORMAL
 * @param string $func
 * @link outputText
 * @return void
 */
function pecho($text, $cat = 0, $func = 'echo')
{
    global $pgWebOutput;
    if ($pgWebOutput) {
        $text = str_replace("\n", "<br>", $text);
    }
    outputText($text, $cat, $func);
}