mirror of
https://github.com/php/doc-es.git
synced 2026-03-26 08:22:08 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/es/trunk@338596 c90b9560-bf6c-de11-be94-00142212c4b1
202 lines
5.7 KiB
XML
202 lines
5.7 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: 7050d96265255c11615116e462e3eec0c068e2a6 Maintainer: seros Status: ready -->
|
|
<!-- Reviewed: no -->
|
|
|
|
<refentry xml:id="imagickkernel.frommatrix" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
<refnamediv>
|
|
<refname>ImagickKernel::fromMatrix</refname>
|
|
<refpurpose>Description</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<modifier>public</modifier> <modifier>static</modifier> <type>ImagickKernel</type><methodname>ImagickKernel::fromMatrix</methodname>
|
|
<methodparam><type>array</type><parameter>matrix</parameter></methodparam>
|
|
<methodparam choice="opt"><type>array</type><parameter>origin</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Crea un núcleo («kernel») desde una matriz 2D de valore. Cada balor debería ser o bien de tipo float
|
|
(si el elemento debería utilizarse) o bien 'false' si el elemento debería saltarse. Para
|
|
matrices que son de tamaño impar en ambas dimensiones, el píxel de origen será
|
|
el centro del núcleo. Para todos los demás tamaños de núcleos, el píxel de origen será especificado.
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>array</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Una matriz (esto es, un array 2D) de valores que definen el núlceo. Cada elemento debería ser o bien un valor de tipo float o FALSE si el elemento no debería ser empleado por el núcleo.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>array</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
El elemento del núcleo que debería utilizarse como píxel de origen. P.ej., para una matriz de 3x3, indicar el origen como [2, 2] especificaría que el elemento inferior derecho sería el píxel de origen.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
El objeto ImagickKernel generado.
|
|
</para>
|
|
</refsect1>
|
|
|
|
|
|
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title> <function>ImagickKernel::fromMatrix</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
function renderKernel(ImagickKernel $imagickKernel) {
|
|
$matrix = $imagickKernel->getMatrix();
|
|
|
|
$imageMargin = 20;
|
|
|
|
$tileSize = 20;
|
|
$tileSpace = 4;
|
|
$shadowSigma = 4;
|
|
$shadowDropX = 20;
|
|
$shadowDropY = 0;
|
|
|
|
$radius = ($tileSize / 2) * 0.9;
|
|
|
|
$rows = count($matrix);
|
|
$columns = count($matrix[0]);
|
|
|
|
$imagickDraw = new \ImagickDraw();
|
|
|
|
$imagickDraw->setFillColor('#afafaf');
|
|
$imagickDraw->setStrokeColor('none');
|
|
|
|
$imagickDraw->translate($imageMargin, $imageMargin);
|
|
$imagickDraw->push();
|
|
|
|
ksort($matrix);
|
|
|
|
foreach ($matrix as $row) {
|
|
ksort($row);
|
|
$imagickDraw->push();
|
|
foreach ($row as $cell) {
|
|
if ($cell !== false) {
|
|
$color = intval(255 * $cell);
|
|
$colorString = sprintf("rgb(%f, %f, %f)", $color, $color, $color);
|
|
$imagickDraw->setFillColor($colorString);
|
|
$imagickDraw->rectangle(0, 0, $tileSize, $tileSize);
|
|
}
|
|
$imagickDraw->translate(($tileSize + $tileSpace), 0);
|
|
}
|
|
$imagickDraw->pop();
|
|
$imagickDraw->translate(0, ($tileSize + $tileSpace));
|
|
}
|
|
|
|
$imagickDraw->pop();
|
|
|
|
$width = ($columns * $tileSize) + (($columns - 1) * $tileSpace);
|
|
$height = ($rows * $tileSize) + (($rows - 1) * $tileSpace);
|
|
|
|
$imagickDraw->push();
|
|
$imagickDraw->translate($width/2 , $height/2);
|
|
$imagickDraw->setFillColor('rgba(0, 0, 0, 0)');
|
|
$imagickDraw->setStrokeColor('white');
|
|
$imagickDraw->circle(0, 0, $radius - 1, 0);
|
|
$imagickDraw->setStrokeColor('black');
|
|
$imagickDraw->circle(0, 0, $radius, 0);
|
|
$imagickDraw->pop();
|
|
|
|
$canvasWidth = $width + (2 * $imageMargin);
|
|
$canvasHeight = $height + (2 * $imageMargin);
|
|
|
|
$kernel = new \Imagick();
|
|
$kernel->newPseudoImage(
|
|
$canvasWidth,
|
|
$canvasHeight,
|
|
'canvas:none'
|
|
);
|
|
|
|
$kernel->setImageFormat('png');
|
|
$kernel->drawImage($imagickDraw);
|
|
|
|
/* crear una sombra paralela en su misma capa */
|
|
$canvas = $kernel->clone();
|
|
$canvas->setImageBackgroundColor(new \ImagickPixel('rgb(0, 0, 0)'));
|
|
$canvas->shadowImage(100, $shadowSigma, $shadowDropX, $shadowDropY);
|
|
|
|
$canvas->setImagePage($canvasWidth, $canvasHeight, -5, -5);
|
|
$canvas->cropImage($canvasWidth, $canvasHeight, 0, 0);
|
|
|
|
/* componer la capa de texto original con shadow_layer */
|
|
$canvas->compositeImage($kernel, \Imagick::COMPOSITE_OVER, 0, 0);
|
|
$canvas->setImageFormat('png');
|
|
|
|
return $canvas;
|
|
}
|
|
|
|
function createFromMatrix() {
|
|
$matrix = [
|
|
[0.5, 0, 0.2],
|
|
[0, 1, 0],
|
|
[0.9, 0, false],
|
|
];
|
|
|
|
$kernel = \ImagickKernel::fromMatrix($matrix);
|
|
|
|
return $kernel;
|
|
}
|
|
|
|
function fromMatrix() {
|
|
$kernel = createFromMatrix();
|
|
$imagick = renderKernel($kernel);
|
|
|
|
header("Content-Type: image/png");
|
|
echo $imagick->getImageBlob();
|
|
}
|
|
|
|
?>
|
|
]]>
|
|
</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
|
|
-->
|