php-doc-en/reference/image/functions/imagefilltoborder.xml
2021-01-13 16:07:34 +01:00

144 lines
4 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="function.imagefilltoborder" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>imagefilltoborder</refname>
<refpurpose>Flood fill to specific color</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>bool</type><methodname>imagefilltoborder</methodname>
<methodparam><type>resource</type><parameter>image</parameter></methodparam>
<methodparam><type>int</type><parameter>x</parameter></methodparam>
<methodparam><type>int</type><parameter>y</parameter></methodparam>
<methodparam><type>int</type><parameter>border</parameter></methodparam>
<methodparam><type>int</type><parameter>color</parameter></methodparam>
</methodsynopsis>
<para>
<function>imagefilltoborder</function> performs a flood fill
whose border color is defined by <parameter>border</parameter>.
The starting point for the fill is <parameter>x</parameter>,
<parameter>y</parameter> (top left is 0, 0) and the region is
filled with color <parameter>color</parameter>.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
&gd.image.description;
<varlistentry>
<term><parameter>x</parameter></term>
<listitem>
<para>
x-coordinate of start.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>y</parameter></term>
<listitem>
<para>
y-coordinate of start.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>border</parameter></term>
<listitem>
<para>
The border color. &gd.identifier.color;
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>color</parameter></term>
<listitem>
<para>
The fill color. &gd.identifier.color;
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
&return.success;
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Filling an ellipse with a color</title>
<programlisting role="php">
<![CDATA[
<?php
// Create the image handle, set the background to white
$im = imagecreatetruecolor(100, 100);
imagefilledrectangle($im, 0, 0, 100, 100, imagecolorallocate($im, 255, 255, 255));
// Draw an ellipse to fill with a black border
imageellipse($im, 50, 50, 50, 50, imagecolorallocate($im, 0, 0, 0));
// Set the border and fill colors
$border = imagecolorallocate($im, 0, 0, 0);
$fill = imagecolorallocate($im, 255, 0, 0);
// Fill the selection
imagefilltoborder($im, 50, 50, $border, $fill);
// Output and free memory
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
?>
]]>
</programlisting>
&example.outputs.similar;
<mediaobject>
<alt>Output of example : Filling an ellipse with a color</alt>
<imageobject>
<imagedata fileref="en/reference/image/figures/imagefilltoborder.png" />
</imageobject>
</mediaobject>
</example>
</para>
</refsect1>
<refsect1 role="notes">
&reftitle.notes;
<simpara>
The algorithm does not explicitly remember which pixels have
already been set, but rather infers that from the color of the
pixel, so it cannot distinguish between freshly set pixels and
pixels that are already there. That means chosing any fill color
that is already used in the image may yield undesired results.
</simpara>
</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
-->