おしゃれなかんじを演出したい気持ちになったので、さくっとそれっぽいコードを書いてみました。
これで作った画像を background に指定すると、こういう感じになります。
https://burberryplaid-php.herokuapp.com/
この index.html
では background: url(image.php) fixed
という指定をしてあります。
で、その image.php
の中身はこんなかんじです。
image.php
<?php
require __DIR__ . '/../vendor/autoload.php';
$colors = [
'#CBFF8C',
'#E3E36A',
'#C16200',
'#881600',
'#4E0110',
];
shuffle($colors);
use BurberryPlaid\Image;
$generator = new Image();
try {
$image = $generator->generate(100, 100, array_slice($colors, 0 , 3));
header('Content-type: image/png');
echo $image;
$image->destroy();
} catch (Exception $e) {
echo $e->getMessage();
}
で、実際に画像を生成しているのはこんなんです。 GitHub に置いておきました。
https://github.com/riaf/burberryplaid-php
参考記事: http://colorburned.com/2008/11/create_a_burberry_style_plaid.html