PHP Velho Oeste 2024

SWFDisplayItem::multColor

(PHP 5 < 5.3.0, PECL ming SVN)

SWFDisplayItem::multColorアイテムの色変換を乗算する

説明

SWFDisplayItem::multColor ( float $red , float $green , float $blue [, float $a ] ) : void
警告

この関数は、 実験的 なものです。この関数の動作・ 名前・その他ドキュメントに書かれている事項は、予告なく、将来的な PHP のリリースにおいて変更される可能性があります。 この関数は自己責任で使用してください。

swfdisplayitem::multcolor() は、指定した値で アイテムの色変換を乗算します。

オブジェクトは swfshape()swfbutton()swftext() あるいは swfsprite() となります。オブジェクトは swfmovie::add() を使用して追加されていなければ なりません。

パラメータ

これらのパラメータは、0.0 から 1.0 までの float 値です。

red

赤コンポーネントの値。

green

緑コンポーネントの値。

blue

青コンポーネントの値。

a

アルファコンポーネントの値。

返り値

値を返しません。

この単純な例では、あなたの写真をハロウィン風に変更しています (風景写真あるいは明るい写真を使用します)。

例1 swfdisplayitem::multcolor() の例

<?php

$b 
= new SWFBitmap(file_get_contents("backyard.jpg"));
// 自分の写真を使用してください (^o^)
$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/101.01.0);
  
$i->addColor(0xff*$n/2000);
  
$m->nextFrame();
}

header('Content-type: application/x-shockwave-flash');
$m->output();
?>

add a note add a note

User Contributed Notes 1 note

up
0
Anonymous
14 years ago
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.
To Top