GradientsΒΆ

Let’s face it , gradient is a necessary feature in any graphic library , it is important to generate styles and some kind of advanced image effects like Reflection for example. for that Jaguar provides a simple gradient generator which supports four kind of gradients which are :

The following example deomnstrates generating the four kinds of gradients.

<?php

use Jaguar\Canvas,
        Jaguar\Color\RGBColor,
        Jaguar\Dimension,
        Jaguar\Gradient\LinearGradient,
        Jaguar\Gradient\RectangleGradient,
        Jaguar\Gradient\CircleGradient,
        Jaguar\Gradient\DiamondGradient;

$canvas = new Canvas();

$start = RGBColor::fromHex('#000');
$end = RGBColor::fromHex('#fff');

$gradients = array(
        'linear-h' => new LinearGradient(LinearGradient::GRADIENT_HORIZONTAL, $start, $end),
        'linear-v' => new LinearGradient(LinearGradient::GRADIENT_VERTICAL, $start, $end),
        'diamond' => new DiamondGradient($start, $end),
        'rectangle' => new RectangleGradient($start, $end),
        'circle' => new CircleGradient($start, $end),
);


foreach ($gradients as $name => $gradient) {
        $canvas = $canvas->create(new Dimension(100, 100));
        $gradient->generate($canvas);
        $canvas->save(sprintf('images/%s.png', $name));
}

Output :

../_images/linear-h.png ../_images/linear-v.png ../_images/diamond.png ../_images/rectangle.png ../_images/circle.png
Read the Docs v: latest
Versions
latest
Downloads
PDF
HTML
Epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.