SWFDisplayItem->multColor
(PHP 4 >= 4.0.5)
SWFDisplayItem->multColor — Multiplies the item's color transform
Описание
Эта функция является ЭКСПЕРИМЕНТАЛЬНОЙ. Поведение этой функции, ее имя и относящаяся к ней документация могут измениться в последующих версиях PHP без уведомления. Используйте эту функцию на свой страх и риск.
swfdisplayitem->multcolor() multiplies the item's color transform by the given values.
The object may be a swfshape(), a swfbutton(), a swftext() or a swfsprite() object. It must have been added using the swfmovie->add().
Список параметров
These parameters are floats between 0.0 and 1.0:
- red
-
Value of red component
- green
-
Value of green component
- blue
-
Value of blue component
- a
-
Value of alpha component
Возвращаемые значения
Эта функция не возвращает значения после выполнения.
Примеры
This simple example will modify your picture's atmosphere to Halloween (use a landscape or bright picture).
Пример #1 swfdisplayitem->multcolor() example
<?php
$b = new SWFBitmap(file_get_contents("backyard.jpg"));
// note use your own picture :-)
$s = new SWFShape();
$s->setRightFill($s->addFill($b));
$s->drawLine($b->getWidth(), 0);
$s->drawLine(0, $b->getHeight());
$s->drawLine(-$b->getWidth(), 0);
$s->drawLine(0, -$b->getHeight());
$m = new SWFMovie();
$m->setDimension($b->getWidth(), $b->getHeight());
$i = $m->add($s);
for ($n=0; $n<=20; ++$n) {
$i->multColor(1.0-$n/10, 1.0, 1.0);
$i->addColor(0xff*$n/20, 0, 0);
$m->nextFrame();
}
header('Content-type: application/x-shockwave-flash');
$m->output();
?>
- PHP Руководство
- Функции по категориям
- Индекс функций
- Справочник функций
- Генерация нетекстовых MIME форматов
- Ming (flash)
- Функция SWFDisplayItem::addAction() - Adds this SWFAction to the given SWFSprite instance
- Функция SWFDisplayItem::addColor() - Adds the given color to this item's color transform
- Функция SWFDisplayItem::endMask() - Another way of defining a MASK layer
- Функция SWFDisplayItem::getRot() - Описание
- Функция SWFDisplayItem::getX() - Описание
- Функция SWFDisplayItem::getXScale() - Описание
- Функция SWFDisplayItem::getXSkew() - Описание
- Функция SWFDisplayItem::getY() - Описание
- Функция SWFDisplayItem::getYScale() - Описание
- Функция SWFDisplayItem::getYSkew() - Описание
- Функция SWFDisplayItem::move() - Moves object in relative coordinates
- Функция SWFDisplayItem::moveTo() - Moves object in global coordinates
- Функция SWFDisplayItem::multColor() - Multiplies the item's color transform
- Функция SWFDisplayItem::remove() - Removes the object from the movie
- Функция SWFDisplayItem::rotate() - Rotates in relative coordinates
- Функция SWFDisplayItem::rotateTo() - Rotates the object in global coordinates
- Функция SWFDisplayItem::scale() - Scales the object in relative coordinates
- Функция SWFDisplayItem::scaleTo() - Scales the object in global coordinates
- Функция SWFDisplayItem::setDepth() - Sets z-order
- Функция SWFDisplayItem::setMaskLevel() - Defines a MASK layer at level
- Функция SWFDisplayItem::setMatrix() - Sets the item's transform matrix
- Функция SWFDisplayItem::setName() - Sets the object's name
- Функция SWFDisplayItem::setRatio() - Sets the object's ratio
- Функция SWFDisplayItem::skewX() - Sets the X-skew
- Функция SWFDisplayItem::skewXTo() - Sets the X-skew
- Функция SWFDisplayItem::skewY() - Sets the Y-skew
- Функция SWFDisplayItem::skewYTo() - Sets the Y-skew
Коментарии
Hey, this is a great function that I spent a lot of time looking for.
What is it great for? Fading. It gives you the ability to fade any supported object (including images) totally or even specific color channels.
The project I am working on requires a series of images and backgrounds to fade into each other. As a bit of a noob, I found the doc here and it's example a little confusing.
I thought that to provide a value for a color channel would change it, but it doesn't.
To say, just change the alpha channel value, you can write it like this
<?php
$movie=new SWFMovie();
$movie->setDimension(700,150);
$movie->setBackground(0,255,255);
// image to add to movie
$img="images/example.jpg";
// add it image to movie and fade its alpha channel
$png = new SWFBitmap(fopen($img,"rb"));
$f1 = $movie->add($png);
$f1->multColor(1,1,1,0.5);
?>
This code will load the image and give it s 50% transperancy.
Similarly, one can fade a single color channel by reducing the value for that specific channel.
<?php
$ft->multColor(0.5,1,1);
?>
This makes the red channel (remember rgb) 50% transparent. You can put a 0 there to completely remove the red channel.
Hope this helps any fellow noobs trying to figure out ming out there.