当前位置: 首页>>代码示例>>PHP>>正文


PHP Color::getGreen方法代码示例

本文整理汇总了PHP中Color::getGreen方法的典型用法代码示例。如果您正苦于以下问题:PHP Color::getGreen方法的具体用法?PHP Color::getGreen怎么用?PHP Color::getGreen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Color的用法示例。


在下文中一共展示了Color::getGreen方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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());
 }
开发者ID:nimetu,项目名称:ryzom_bmaker,代码行数:10,代码来源:ColorTest.php

示例2: testShouldSetColorToWhite

 /**
  * @cover Imagine\Image\Color::__construct
  * @cover Imagine\Image\Color::getRed
  * @cover Imagine\Image\Color::getGreen
  * @cover Imagine\Image\Color::getAlpha
  * @cover Imagine\Image\Color::__toString
  */
 public function testShouldSetColorToWhite()
 {
     $color = new Color('fff');
     $this->assertEquals(255, $color->getRed());
     $this->assertEquals(255, $color->getGreen());
     $this->assertEquals(255, $color->getBlue());
     $this->assertEquals(0, $color->getAlpha());
     $this->assertEquals('#ffffff', (string) $color);
     $this->assertEquals('#00ff00', (string) new Color('00ff00'));
 }
开发者ID:nicodmf,项目名称:Imagine,代码行数:17,代码来源:ColorTest.php

示例3: getColorIndex

 /**
  * @param \DarkLuk42\Color $color
  * @param bool             $forceAllocation
  *
  * @return int
  */
 public function getColorIndex(Color $color, $forceAllocation = true)
 {
     if ($color->hasAlpha()) {
         $index = imagecolorexactalpha($this->image, $color->getRed(), $color->getGreen(), $color->getBlue(), intval($color->getAlpha() / 2));
     } else {
         $index = imagecolorexact($this->image, $color->getRed(), $color->getGreen(), $color->getBlue());
     }
     if ($index == -1 && $forceAllocation) {
         $index = $this->colorAllocate($color);
     }
     return $index;
 }
开发者ID:darkluk42,项目名称:image,代码行数:18,代码来源:Image.php

示例4: test

 /**
  * The whole test.
  */
 public function test()
 {
     $tests = ['#000000', '#000', '000000', 0, [0, 0, 0], new Color('#000000')];
     foreach ($tests as $test) {
         $color = new Color($test);
         $this->assertEquals(0, $color->getRed());
         $this->assertEquals(0, $color->getGreen());
         $this->assertEquals(0, $color->getBlue());
         $this->assertEquals('000000', $color->getHex());
         $this->assertEquals([0, 0, 0], $color->getRgb());
         $this->assertEquals(0, $color->getBinary());
         ob_start();
         echo $color;
         $output = ob_get_clean();
         $this->assertEquals('#000000', $output);
         $this->assertEquals('000000', $color->toGrayScale()->getHex());
         $this->assertEquals('ffffff', $color->toInverse()->getHex());
     }
     $color = new Color();
     $color->setRed('00')->setGreen('00')->setBlue('00');
     $this->assertEquals('000000', $color->getHex());
     $tests = ['#ffffff', '#FfFFffF', '#fff', 'ffffff', 0xffffff, [255, 255, 255], [260, 320, 1024], new Color('#ffffff')];
     foreach ($tests as $test) {
         $color = new Color($test);
         $this->assertEquals(255, $color->getRed());
         $this->assertEquals(255, $color->getGreen());
         $this->assertEquals(255, $color->getBlue());
         $this->assertEquals('ffffff', $color->getHex());
         $this->assertEquals([255, 255, 255], $color->getRgb());
         $this->assertEquals(1, $color->getBinary());
         ob_start();
         echo $color;
         $output = ob_get_clean();
         $this->assertEquals('#ffffff', $output);
         $this->assertEquals('ffffff', $color->toGrayScale()->getHex());
         $this->assertEquals('000000', $color->toInverse()->getHex());
     }
     $color = new Color();
     $color->setRed('FF')->setGreen('FF')->setBlue('FF');
     $this->assertEquals('ffffff', $color->getHex());
     $tests = ['#239416', '239416', 0x239416, [35, 148, 22], new Color('#239416')];
     foreach ($tests as $test) {
         $color = new Color($test);
         $this->assertEquals(35, $color->getRed());
         $this->assertEquals(148, $color->getGreen());
         $this->assertEquals(22, $color->getBlue());
         $this->assertEquals('239416', $color->getHex());
         $this->assertEquals([35, 148, 22], $color->getRgb());
         $this->assertEquals(0, $color->getBinary());
         ob_start();
         echo $color;
         $output = ob_get_clean();
         $this->assertEquals('#239416', $output);
         $this->assertEquals('616161', $color->toGrayScale()->getHex());
         $this->assertEquals('dc6be9', $color->toInverse()->getHex());
     }
     $tests = ['#22FF66', '#22Ff66', '#2f6', '2F6', '22FF66', '22fF66', 0x22ff66, [34, 255, 102], new Color('#22FF66')];
     foreach ($tests as $test) {
         $color = new Color($test);
         $this->assertEquals(34, $color->getRed());
         $this->assertEquals(255, $color->getGreen());
         $this->assertEquals(102, $color->getBlue());
         $this->assertEquals('22ff66', $color->getHex());
         $this->assertEquals([34, 255, 102], $color->getRgb());
         $this->assertEquals(1, $color->getBinary());
         ob_start();
         echo $color;
         $output = ob_get_clean();
         $this->assertEquals('#22ff66', $output);
         $this->assertEquals('b8b8b8', $color->toGrayScale()->getHex());
         $this->assertEquals('dd0099', $color->toInverse()->getHex());
     }
     $color = new Color();
     $color->setRed('23')->setGreen('94')->setBlue('16');
     $this->assertEquals('239416', $color->getHex());
     $invalids = ['#FFBBC', '#FBCA', '0000', '0', 'AB'];
     foreach ($invalids as $invalid) {
         try {
             $color = new Color($invalid);
             $this->fail(sprintf('%s expected for value %s', \InvalidArgumentException::class, $invalid));
         } catch (\PHPUnit_Framework_AssertionFailedError $e) {
             throw $e;
         } catch (\Exception $e) {
             // Correctly thrown exception
             $this->assertInstanceOf(\InvalidArgumentException::class, $e);
         }
     }
 }
开发者ID:jyxo,项目名称:php,代码行数:91,代码来源:ColorTest.php

示例5: blendTo

 /**
  * @param Color $color
  * @param float $position
  *
  * @return Color
  */
 public function blendTo(Color $color, $position)
 {
     // 2. Calculate colour based on fractional position
     $red = (int) ($this->red - ($this->red - $color->getRed()) * $position);
     $green = (int) ($this->green - ($this->green - $color->getGreen()) * $position);
     $blue = (int) ($this->blue - ($this->blue - $color->getBlue()) * $position);
     return new self($red, $green, $blue);
 }
开发者ID:nochso,项目名称:benchmark,代码行数:14,代码来源:Color.php

示例6: getColorIdentifier

 public function getColorIdentifier(Color $color)
 {
     $colorId = imagecolorexact($this->imageId, $color->getRed(), $color->getGreen(), $color->getBlue());
     if ($colorId === -1) {
         $colorId = imagecolorallocate($this->imageId, $color->getRed(), $color->getGreen(), $color->getBlue());
     }
     return $colorId;
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:8,代码来源:TuringImage.class.php


注:本文中的Color::getGreen方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。