public function testGradient() { $width = 250; $height = 750; $startColor = 'ffffff'; $endColor = '000000'; $res = ImageGenerator::gradient($width, $height, 1, new Color($startColor), new Color($endColor)); $this->assertEquals($width, $res->getWidth()); $this->assertEquals($height, $res->getHeight()); $this->assertEquals($startColor, ColorUtil::getColorAt($res, Coordinate::create(0, 0))->getHexColor()); $this->assertEquals('7e7e7e', ColorUtil::getColorAt($res, Coordinate::create($width / 2, $height / 2))->getHexColor()); $this->assertEquals($endColor, ColorUtil::getColorAt($res, Coordinate::create($width - 1, $height - 1))->getHexColor()); }
<?php use imagemanipulation\generation\ImageGenerator; use imagemanipulation\ImageType; use imagemanipulation\color\Color; ImageGenerator::gradient(500, 200, 0, new Color('#6EC5E3'), new Color('#BF2074'))->render(ImageType::PNG, 80);