Ejemplo n.º 1
0
 /**
  * @expectedException InvalidArgumentException
  * @expectedExceptionMessage The array color count expected 3 or 4 value
  */
 public function testStaticMethodFromArrayWithWrongParams()
 {
     $color = Color::fromArray([255, 255]);
 }
Ejemplo n.º 2
0
<?php

require_once __DIR__ . '/../vendor/autoload.php';
use PhpColor\Color;
$green = Color::fromInt(Color::GREEN);
$blue = Color::fromInt(Color::BLUE);
$red = Color::fromInt(Color::RED);
$orange = Color::fromInt(Color::ORANGE);
$yellow = Color::fromInt(Color::YELLOW);
$lightGreen = Color::fromArray([100, 0, 255, 0]);
?>
<svg width="1280">
<rect x="10" y="10" width="100" height="100" fill="<?php 
echo $red;
?>
" />
<rect x="120" y="10" width="100" height="100" fill="<?php 
echo $green;
?>
" />
<rect x="230" y="10" width="100" height="100" fill="<?php 
echo $blue;
?>
" />
<rect x="340" y="10" width="100" height="100" fill="<?php 
echo $orange;
?>
" />
<rect x="450" y="10" width="100" height="100" fill="<?php 
echo $yellow;
?>
Ejemplo n.º 3
0
<?php

require_once __DIR__ . '/../vendor/autoload.php';
use PhpColor\Color;
$green = Color::fromInt(Color::GREEN);
$blue = Color::fromInt(Color::BLUE);
$red = Color::fromInt(Color::RED);
$orange = Color::fromInt(Color::ORANGE);
$yellow = Color::fromInt(Color::YELLOW);
$alphaGreen = Color::fromArray([120, 0, 255, 0]);
$opaqueGreen = $alphaGreen->toHex(true);
?>
<!doctype html>
<html>
<head>
<style type="text/css">
div {
display: inline-block;
width: 100px;
height: 100px;
}
.blue {
background-color : <?php 
echo $blue;
?>
;
}
.green {
background-color : <?php 
echo $green;
?>