Files
doc-fr/reference/imagick/imagickpixel/issimilar.xml
George Peter Banyard 3e4f012ef1 Apply SVN revision 351855
git-svn-id: https://svn.php.net/repository/phpdoc/fr/trunk@351881 c90b9560-bf6c-de11-be94-00142212c4b1
2020-12-04 18:52:55 +00:00

177 lines
5.6 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: fa0c88f1e36a3f28b4fcee0b2d1e188b54e0c44b Maintainer: yannick Status: ready -->
<!-- Reviewed: yes -->
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="imagickpixel.issimilar">
<refnamediv>
<refname>ImagickPixel::isSimilar</refname>
<refpurpose>Vérifie la distance entre 2 couleurs</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>bool</type><methodname>ImagickPixel::isSimilar</methodname>
<methodparam><type>ImagickPixel</type><parameter>color</parameter></methodparam>
<methodparam><type>float</type><parameter>fuzz</parameter></methodparam>
</methodsynopsis>
&warn.undocumented.func;
<para>
Vérifie la distance entre la couleur décrite par l'objet ImagickPixel
et celle de l'objet fourni, en plaçant leurs valeurs RGB sur le cube
de couleur. Si la distance entre les 2 points est inférieure à la valeur
du paramètre <parameter>fuzz</parameter>, la couleur est similaire.
Obsolète en faveur de la méthode
<link linkend="imagickpixel.ispixelsimilar">ImagickPixel::isPixelSimilar()</link>.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>color</parameter></term>
<listitem>
<para>
L'objet ImagickPixel utilisé pour la comparaison.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>fuzz</parameter></term>
<listitem>
<para>
La distance maximale utilisée pour considérer que les couleurs
sont similaires. La valeur maximale théorique est la racine carré
de 3 (1.732).
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
&imagick.return.success;
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Exemple avec <function>ImagickPixel::isSimilar</function></title>
<programlisting role="php">
<![CDATA[
<?php
// Le test ci-dessous a été écrit avec une distance maximale de 255,
// aussi, nous devons le mettre à l'échelle avec une racine carrée de 3 -
// la longueur de la diagonale d'un cube.
$root3 = 1.732050807568877;
$tests = array(
['rgb(245, 0, 0)', 'rgb(255, 0, 0)', 9 / $root3, false,],
['rgb(245, 0, 0)', 'rgb(255, 0, 0)', 10 / $root3, true,],
['rgb(0, 0, 0)', 'rgb(7, 7, 0)', 9 / $root3, false,],
['rgb(0, 0, 0)', 'rgb(7, 7, 0)', 10 / $root3, true,],
['rgba(0, 0, 0, 1)', 'rgba(7, 7, 0, 1)', 9 / $root3, false,],
['rgba(0, 0, 0, 1)', 'rgba(7, 7, 0, 1)', 10 / $root3, true,],
['rgb(128, 128, 128)', 'rgb(128, 128, 120)', 7 / $root3, false,],
['rgb(128, 128, 128)', 'rgb(128, 128, 120)', 8 / $root3, true,],
['rgb(0, 0, 0)', 'rgb(255, 255, 255)', 254.9, false,],
['rgb(0, 0, 0)', 'rgb(255, 255, 255)', 255, true,],
['rgb(255, 0, 0)', 'rgb(0, 255, 255)', 254.9, false,],
['rgb(255, 0, 0)', 'rgb(0, 255, 255)', 255, true,],
['black', 'rgba(0, 0, 0)', 0.0, true],
['black', 'rgba(10, 0, 0, 1.0)', 10.0 / $root3, true],);
$output = "<table width='100%' class='infoTable'><thead>
<tr>
<th>
Color 1
</th>
<th>
Color 2
</th>
<th>
Test distance * 255
</th>
<th>
Is within distance
</th>
</tr>
</thead>";
$output .= "<tbody>";
foreach ($tests as $testInfo) {
$color1 = $testInfo[0];
$color2 = $testInfo[1];
$distance = $testInfo[2];
$expectation = $testInfo[3];
$testDistance = ($distance / 255.0);
$color1Pixel = new \ImagickPixel($color1);
$color2Pixel = new \ImagickPixel($color2);
$isSimilar = $color1Pixel->isPixelSimilar($color2Pixel, $testDistance);
if ($isSimilar !== $expectation) {
echo "Test distance failed. Color [$color1] compared to color [$color2] is not within distance $testDistance FAILED.".NL;
}
$layout = "<tr>
<td>%s</td>
<td>%s</td>
<td>%s</td>
<td style='text-align: center;'>%s</td>
</tr>";
$output .= sprintf(
$layout,
$color1,
$color2,
$distance,
$isSimilar ? 'yes' : 'no'
);
}
$output .= "</tbody></table>";
return $output;
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->