function mathimage($text, $size) { $nameimg = md5(trim($text) . $size) . '.png'; $v = detectimg($nameimg); if ($v == 0) { global $symboles, $fontesmath; import('content/math/mathpublisher'); $formula = new expression_math(tableau_expression(trim($text))); $formula->dessine($size); $v = 1000 - imagesy($formula->image) + $formula->base_verticale + 3; imagepng($formula->image, DIR_IMG . '/math_' . $v . '_' . $nameimg); } $valign = $v - 1000; $text = htmlentities(strip_tags($text), ENT_COMPAT, 'ISO-8859-1'); return '<img src="/images/maths/math_' . $v . '_' . $nameimg . '" style="vertical-align:' . $valign . 'px;display:inline-block;background-color:#FFFFFF;" alt="' . $text . '" title="' . $text . '"/>'; }
function mathimage($text, $size, $pathtoimg) { /* Creates the formula image (if the image is not in the cache) and returns the <img src=...></img> html code. */ global $dirimg; $nameimg = md5(trim($text) . $size) . '.png'; $v = detectimg($nameimg); if ($v == 0) { //the image doesn't exist in the cache directory. we create it. $formula = new expression_math(tableau_expression(trim($text))); $formula->dessine($size); $v = 1000 - imagesy($formula->image) + $formula->base_verticale + 3; //1000+baseline ($v) is recorded in the name of the image ImagePNG($formula->image, $dirimg . "/math_" . $v . "_" . $nameimg); } $valign = $v - 1000; return '<img src="' . $pathtoimg . "math_" . $v . "_" . $nameimg . '" style="vertical-align:' . $valign . 'px;' . ' display: inline-block ;" alt="' . $text . '" title="' . $text . '"/>'; }
function mathimage($text, $size, $pathtoimg, $color = '#000000', $bg_color = '#ffffff') { /* Creates the formula image (if the image is not in the cache) and returns the <img src=...></img> html code. */ global $dirimg, $dirfonts, $mp_debug, $mpfont_red, $mpfont_green, $mpfont_blue, $mpbg_red, $mpbg_green, $mpbg_blue; global $_VERSION; list($mpfont_red, $mpfont_green, $mpfont_blue) = html2rgb($color); list($mpbg_red, $mpbg_green, $mpbg_blue) = html2rgb($bg_color); $text = stripslashes($text); $size = max($size, 10); $size = min($size, 24); $nameimg = md5(trim($text) . $size . $color . $bg_color) . '.png'; $v = detectimg($nameimg); if ($v == 0) { //the image doesn't exist in the cache directory. we create it. $formula = new expression_math(tableau_expression(trim($text))); $formula->dessine($size); $v = 1000 - imagesy($formula->image) + $formula->base_verticale + 3; //1000+baseline ($v) is recorded in the name of the image imagepng($formula->image, $dirimg . "/math_" . $v . "_" . $nameimg); } $valign = $v - 1000; $label_text = htmlentities(str_replace('{prime}', "'", $text), ENT_COMPAT, 'UTF-8'); # encode so html stays valid #$label_text = htmlentities(str_replace('{prime}',"'",$text)); # encode so html stays valid $text = str_replace("€", '[euro80]', $text); $text = str_replace("â82ac", '[euroU]', $text); return '<!-- ' . $text . ' --><img src="' . $pathtoimg . "math_" . $v . "_" . $nameimg . '" style="vertical-align:' . $valign . 'px;' . ' display: inline-block ;" alt="' . $label_text . '" title="' . $label_text . '"/>'; }