本文整理汇总了PHP中Color::getColor方法的典型用法代码示例。如果您正苦于以下问题:PHP Color::getColor方法的具体用法?PHP Color::getColor怎么用?PHP Color::getColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Color
的用法示例。
在下文中一共展示了Color::getColor方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testInvalidColor
public function testInvalidColor()
{
$strColor = '-invalid-';
$color = new Color($strColor);
$this->assertEquals($strColor, $color->getColor());
$this->assertEquals(255, $color->getRed());
$this->assertEquals(255, $color->getGreen());
$this->assertEquals(255, $color->getBlue());
$this->assertEquals(0, $color->getAlpha());
}
示例2: _displayPagina
public static function _displayPagina($accion)
{
$colorCookie = new Color();
if ($accion == "probarColor") {
$colorCookie->probarColor();
self::$_estilo = $colorCookie->getEstilo();
} else {
$colorCookie->ponerColor();
self::$_enlacesColores = "Cambio de color: <a href='./index.php?color=rojo'>Rojo</a>\n<a href='./index.php?color=azul'>Azul</a>\n<a href='./index.php?color=verde'>Verde</a>\n<a href='./index.php?color=ninguno'>Ninguno</a>";
self::$_enlace = "<a href='./index.php?accion=probarColor'>Comprobar la cookie</a>";
}
self::$_color = $colorCookie->getColor();
if (isset($_COOKIE["cookieColor"]) && self::$_color != "ninguno") {
self::$_mensaje = "Se ha elegido el color " . self::$_color;
} else {
self::$_mensaje = "No se ha elegido color";
}
self::$_operacion = $colorCookie->getOperacion();
self::_retornarVista();
}
示例3: resize
/**
* @brief Resize the image to the specified width and height
*
* optionally keeping the aspect ratio and pads or crops the resulting
* image to the desired dimensions.
*
* @param Integer $width The desired width
* @param Integer $height The desired height
* @param Integer $keepaspect One of KEEP_NONE, KEEP_CROP, and KEEP_FILL
* @param Color $fillcolor The color to fill with (if KEEP_FILL)
*/
function resize($width, $height, $keepaspect = Canvas::KEEP_NONE, Color $fillcolor = null)
{
$this->checkImage();
$this->checkMeta();
$cw = imageSX($this->himage);
$ch = imageSY($this->himage);
$nr = (double) ($width / $height);
// Get new aspect ratio
$cr = (double) ($cw / $ch);
// Get current aspect ratio
switch ($keepaspect) {
case Canvas::KEEP_NONE:
$n = imagecreatetruecolor($width, $height);
imagecopyresampled($n, $this->himage, 0, 0, 0, 0, $width, $height, $cw, $ch);
break;
case Canvas::KEEP_CROP:
$ratio = $cw / $ch;
if ($width / $height > $ratio) {
$nh = round($width / $ratio);
$nw = $width;
} else {
$nw = round($height * $ratio);
$nh = $height;
}
$m = imagecreatetruecolor($nw, $nh);
imagecopyresampled($m, $this->himage, 0, 0, 0, 0, $nw, $nh, $cw, $ch);
$n = imagecreatetruecolor($width, $height);
imagecopyresampled($n, $m, 0, 0, ($nw - $width) / 2, ($nh - $height) / 2, $width, $height, $width, $height);
imagedestroy($m);
break;
case Canvas::KEEP_FILL:
$ratio = $cw / $ch;
$cw <= $width ? $nw = $cw : ($nw = $width);
$nh = round($ch * $nw / $cw);
if ($nh > $height) {
$nw = $cw * $height / $ch;
$nh = $height;
}
$n = imagecreatetruecolor($width, $height);
imagefilledrectangle($n, 0, 0, $width, $height, $fillcolor->getColor($this->himage));
imagecopyresampled($n, $this->himage, round(($width - $nw) / 2), round(($height - $nh) / 2), 0, 0, $nw, $nh, $cw, $ch);
break;
}
imagedestroy($this->himage);
$this->himage = $n;
$this->width = imageSX($this->himage);
$this->height = imageSY($this->himage);
}
示例4: testAddingHash
public function testAddingHash()
{
$color = new Color('000000');
$this->assertEquals('#000000', $color->getColor());
$this->assertEquals('000000', $color->getColor(false));
}
示例5: drawCircle
function drawCircle($x, $y, $radius, Color $fillcolor, Color $linecolor = null)
{
$cf = $fillcolor->getColor($this->himage);
imagefilledarc($this->himage, $x, $y, $radius * 2, $radius * 2, 0, 360, $cf, IMG_ARC_PIE);
if ($linecolor) {
$cl = $linecolor->getColor($this->himage);
imagefilledarc($this->himage, $x, $y, $radius * 2, $radius * 2, 0, 360, $cl, IMG_ARC_PIE | IMG_ARC_NOFILL);
}
}