Example #1
0
 public function getStops()
 {
     if (empty($this->stops)) {
         foreach ($this->children as $_child) {
             if ($_child->tagName != "stop") {
                 continue;
             }
             $_stop = new Stop();
             $_attributes = $_child->attributes;
             // Style
             if (isset($_attributes["style"])) {
                 $_style = Style::parseCssStyle($_attributes["style"]);
                 if (isset($_style["stop-color"])) {
                     $_stop->color = Style::parseColor($_style["stop-color"]);
                 }
                 if (isset($_style["stop-opacity"])) {
                     $_stop->opacity = max(0, min(1.0, $_style["stop-opacity"]));
                 }
             }
             // Attributes
             if (isset($_attributes["offset"])) {
                 $_stop->offset = $_attributes["offset"];
             }
             if (isset($_attributes["stop-color"])) {
                 $_stop->color = Style::parseColor($_attributes["stop-color"]);
             }
             if (isset($_attributes["stop-opacity"])) {
                 $_stop->opacity = max(0, min(1.0, $_attributes["stop-opacity"]));
             }
             $this->stops[] = $_stop;
         }
     }
     return $this->stops;
 }
Example #2
0
 public function test_parseColor()
 {
     $this->assertEquals("none", Style::parseColor("none"));
     $this->assertEquals(array(255, 0, 0), Style::parseColor("RED"));
     $this->assertEquals(array(0, 0, 255), Style::parseColor("blue"));
     $this->assertEquals(null, Style::parseColor("foo"));
 }