1<?php 2 3require_once(HTML2PS_DIR.'value.generic.php'); 4 5class Color extends CSSValue { 6 function Color($rgb = array(0,0,0), $transparent = true) { 7 // We need this 'max' hack, as somethimes we can get values below zero due 8 // the rounding errors... it will cause PDFLIB to die with error message 9 // that is not what we want 10 $this->r = max($rgb[0] / 255.0, 0); 11 $this->g = max($rgb[1] / 255.0, 0); 12 $this->b = max($rgb[2] / 255.0, 0); 13 14 $this->transparent = $transparent; 15 } 16 17 function apply(&$viewport) { 18 $viewport->setrgbcolor($this->r, $this->g, $this->b); 19 } 20 21 function blend($color, $alpha) { 22 $this->r += ($color->r - $this->r)*$alpha; 23 $this->g += ($color->g - $this->g)*$alpha; 24 $this->b += ($color->b - $this->b)*$alpha; 25 } 26 27 function ©() { 28 $color =& new Color(); 29 30 $color->r = $this->r; 31 $color->g = $this->g; 32 $color->b = $this->b; 33 $color->transparent = $this->transparent; 34 35 return $color; 36 } 37 38 function equals($rgb) { 39 return 40 $this->r == $rgb->r && 41 $this->g == $rgb->g && 42 $this->b == $rgb->b; 43 } 44 45 function isTransparent() { 46 return $this->transparent; 47 } 48} 49 50?>