Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Rgb.php
Go to the documentation of this file.
1 <?php
24 #require_once 'Zend/Pdf/Element/Numeric.php';
25 
26 
28 #require_once 'Zend/Pdf/Color.php';
29 
39 {
46  private $_r;
47 
54  private $_g;
55 
62  private $_b;
63 
64 
72  public function __construct($r, $g, $b)
73  {
75  if ($r < 0) { $r = 0; }
76  if ($r > 1) { $r = 1; }
77 
78  if ($g < 0) { $g = 0; }
79  if ($g > 1) { $g = 1; }
80 
81  if ($b < 0) { $b = 0; }
82  if ($b > 1) { $b = 1; }
83 
84  $this->_r = new Zend_Pdf_Element_Numeric($r);
85  $this->_g = new Zend_Pdf_Element_Numeric($g);
86  $this->_b = new Zend_Pdf_Element_Numeric($b);
87  }
88 
97  public function instructions($stroking)
98  {
99  return $this->_r->toString() . ' '
100  . $this->_g->toString() . ' '
101  . $this->_b->toString() . ($stroking? " RG\n" : " rg\n");
102  }
103 
109  public function getComponents()
110  {
111  return array($this->_r->value, $this->_g->value, $this->_b->value);
112  }
113 }
114 
__construct($r, $g, $b)
Definition: Rgb.php:72
instructions($stroking)
Definition: Rgb.php:97