par
Bernard_2102 » 21 oct. 2016, 18:44
Bonjour,
pour info je suis en plein dedans (création devis, facture), j'utilise une fonction trouvé sur le web.
tu compte ta chaine de caractère x caractères par ligne:
<?php
$str = 'abcdef';
echo strlen($str); // 6
$str = ' ab cd ';
echo strlen($str); // 7
?>
et tu passes les valeurs en variable $w, $h
Fonction à utiliser:
function RoundedRect($x, $y, $w, $h, $r, $corners = '1234', $style = '')
//x, y : coin supérieur gauche du rectangle.
//w, h : largeur et hauteur.
//r : rayon des coins arrondis.
//corners : numéro du ou des angles à arrondir : 1, 2, 3, 4 ou toute combinaison (1=haut gauche, 2=haut droite, 3=bas droite, 4=bas gauche).
//style : comme celui de Rect() : F, D (défaut), FD ou DF.
{
$k = $this->k;
$hp = $this->h;
if($style=='F')
$op='f';
elseif($style=='FD' || $style=='DF')
$op='B';
else
$op='S';
$MyArc = 4/3 * (sqrt(2) - 1);
$this->_out(sprintf('%.2F %.2F m',($x+$r)*$k,($hp-$y)*$k ));
$xc = $x+$w-$r;
$yc = $y+$r;
$this->_out(sprintf('%.2F %.2F l', $xc*$k,($hp-$y)*$k ));
if (strpos($corners, '2')===false)
$this->_out(sprintf('%.2F %.2F l', ($x+$w)*$k,($hp-$y)*$k ));
else
$this->_Arc($xc + $r*$MyArc, $yc - $r, $xc + $r, $yc - $r*$MyArc, $xc + $r, $yc);
$xc = $x+$w-$r;
$yc = $y+$h-$r;
$this->_out(sprintf('%.2F %.2F l',($x+$w)*$k,($hp-$yc)*$k));
if (strpos($corners, '3')===false)
$this->_out(sprintf('%.2F %.2F l',($x+$w)*$k,($hp-($y+$h))*$k));
else
$this->_Arc($xc + $r, $yc + $r*$MyArc, $xc + $r*$MyArc, $yc + $r, $xc, $yc + $r);
$xc = $x+$r;
$yc = $y+$h-$r;
$this->_out(sprintf('%.2F %.2F l',$xc*$k,($hp-($y+$h))*$k));
if (strpos($corners, '4')===false)
$this->_out(sprintf('%.2F %.2F l',($x)*$k,($hp-($y+$h))*$k));
else
$this->_Arc($xc - $r*$MyArc, $yc + $r, $xc - $r, $yc + $r*$MyArc, $xc - $r, $yc);
$xc = $x+$r ;
$yc = $y+$r;
$this->_out(sprintf('%.2F %.2F l',($x)*$k,($hp-$yc)*$k ));
if (strpos($corners, '1')===false)
{
$this->_out(sprintf('%.2F %.2F l',($x)*$k,($hp-$y)*$k ));
$this->_out(sprintf('%.2F %.2F l',($x+$r)*$k,($hp-$y)*$k ));
}
else
$this->_Arc($xc - $r, $yc - $r*$MyArc, $xc - $r*$MyArc, $yc - $r, $xc, $yc - $r);
$this->_out($op);
}
Bonjour,
pour info je suis en plein dedans (création devis, facture), j'utilise une fonction trouvé sur le web.
tu compte ta chaine de caractère x caractères par ligne:
<?php
$str = 'abcdef';
echo strlen($str); // 6
$str = ' ab cd ';
echo strlen($str); // 7
?>
et tu passes les valeurs en variable $w, $h
Fonction à utiliser:
function RoundedRect($x, $y, $w, $h, $r, $corners = '1234', $style = '')
//x, y : coin supérieur gauche du rectangle.
//w, h : largeur et hauteur.
//r : rayon des coins arrondis.
//corners : numéro du ou des angles à arrondir : 1, 2, 3, 4 ou toute combinaison (1=haut gauche, 2=haut droite, 3=bas droite, 4=bas gauche).
//style : comme celui de Rect() : F, D (défaut), FD ou DF.
{
$k = $this->k;
$hp = $this->h;
if($style=='F')
$op='f';
elseif($style=='FD' || $style=='DF')
$op='B';
else
$op='S';
$MyArc = 4/3 * (sqrt(2) - 1);
$this->_out(sprintf('%.2F %.2F m',($x+$r)*$k,($hp-$y)*$k ));
$xc = $x+$w-$r;
$yc = $y+$r;
$this->_out(sprintf('%.2F %.2F l', $xc*$k,($hp-$y)*$k ));
if (strpos($corners, '2')===false)
$this->_out(sprintf('%.2F %.2F l', ($x+$w)*$k,($hp-$y)*$k ));
else
$this->_Arc($xc + $r*$MyArc, $yc - $r, $xc + $r, $yc - $r*$MyArc, $xc + $r, $yc);
$xc = $x+$w-$r;
$yc = $y+$h-$r;
$this->_out(sprintf('%.2F %.2F l',($x+$w)*$k,($hp-$yc)*$k));
if (strpos($corners, '3')===false)
$this->_out(sprintf('%.2F %.2F l',($x+$w)*$k,($hp-($y+$h))*$k));
else
$this->_Arc($xc + $r, $yc + $r*$MyArc, $xc + $r*$MyArc, $yc + $r, $xc, $yc + $r);
$xc = $x+$r;
$yc = $y+$h-$r;
$this->_out(sprintf('%.2F %.2F l',$xc*$k,($hp-($y+$h))*$k));
if (strpos($corners, '4')===false)
$this->_out(sprintf('%.2F %.2F l',($x)*$k,($hp-($y+$h))*$k));
else
$this->_Arc($xc - $r*$MyArc, $yc + $r, $xc - $r, $yc + $r*$MyArc, $xc - $r, $yc);
$xc = $x+$r ;
$yc = $y+$r;
$this->_out(sprintf('%.2F %.2F l',($x)*$k,($hp-$yc)*$k ));
if (strpos($corners, '1')===false)
{
$this->_out(sprintf('%.2F %.2F l',($x)*$k,($hp-$y)*$k ));
$this->_out(sprintf('%.2F %.2F l',($x+$r)*$k,($hp-$y)*$k ));
}
else
$this->_Arc($xc - $r, $yc - $r*$MyArc, $xc - $r*$MyArc, $yc - $r, $xc, $yc - $r);
$this->_out($op);
}