PHPMathPublisher

Description of a bug in preparation of images where the root expression is larger than a single character.

current version with error

after applying patch

root{n}{root{m}{a}}=root{n*m}{a}=a^{{1/n}*m}

root{n*m}{a}

patch code

Replace the dessine_root() function in path/to/dokuwiki/lib/plugin/math/phpmathpublisher/mathpublisher.php with the code below.

lib/plugin/math/phpmathpublisher/mathpublisher.php

function dessine_root($taille) 
{
$this->noeuds[1]->dessine($taille*0.6);
$imgroot=$this->noeuds[1]->image;
$baseroot=$this->noeuds[1]->base_verticale;
$largeurroot=imagesx($imgroot);
$hauteurroot=imagesy($imgroot);
 
$this->noeuds[2]->dessine($taille);
$imgexp=$this->noeuds[2]->image;
$baseexp=$this->noeuds[2]->base_verticale;
$largeurexp=imagesx($imgexp);
$hauteurexp=imagesy($imgexp);
 
$imgrac=affiche_symbol("_racine",$hauteurexp+2);
$largeurrac=imagesx($imgrac);
$hauteurrac=imagesy($imgrac);
$baserac=$hauteurrac/2;
 
//$largeur=$largeurrac+$largeurexp;
$netwidthroot = max($largeurroot-0.3*$hauteurrac,0);
$largeur=$largeurrac+$largeurexp+$netwidthroot;
$hauteur=max($hauteurexp,$hauteurrac);
$result = ImageCreate(max($largeur,1), max($hauteur,1));
$noir=ImageColorAllocate($result,0,0,0);
$blanc=ImageColorAllocate($result,255,255,255);
$blanc=imagecolortransparent($result,$blanc);
ImageFilledRectangle($result,0,0,$largeur-1,$hauteur-1,$blanc);
ImageCopy($result, $imgrac,$netwidthroot,0, 0, 0,$largeurrac,$hauteurrac);
ImageCopy($result, $imgexp,$largeurrac+$netwidthroot,$hauteur-$hauteurexp, 0, 0,$largeurexp,$hauteurexp);
imagesetthickness($result,1);
imageline($result, $largeurrac+$netwidthroot-2,2, $largeurrac+$netwidthroot+$largeurexp+2,2, $noir);
ImageCopy($result, $imgroot,0,0, 0, 0,$largeurroot,$hauteurroot); 
$this->base_verticale=$hauteur-$hauteurexp+$baseexp;
$this->image=$result;	
}

 
test/math.txt · Last modified: 2007/10/30 16:30 by 192.168.0.101
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki