From 192245fbbc6633d6bbfa43940892721bd939d92e Mon Sep 17 00:00:00 2001 From: Adam Laycock Date: Wed, 13 Jul 2016 21:30:54 +0100 Subject: [PATCH 1/2] Allow user to get HSL values for generated base colour --- src/GeoPattern/GeoPattern.php | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/GeoPattern/GeoPattern.php b/src/GeoPattern/GeoPattern.php index 12e6225..deeeaae 100644 --- a/src/GeoPattern/GeoPattern.php +++ b/src/GeoPattern/GeoPattern.php @@ -142,20 +142,26 @@ public function __toString() { } // Generators - protected function generateBackground() - { - $hueOffset = $this->map($this->hexVal(14, 3), 0, 4095, 0, 359); - $satOffset = $this->hexVal(17, 1); - $baseColor = $this->hexToHSL($this->baseColor); - $color = $this->color; + public function generateColors(){ + $hueOffset = $this->map($this->hexVal(14, 3), 0, 4095, 0, 359); + $satOffset = $this->hexVal(17, 1); + $baseColor = $this->hexToHSL($this->baseColor); - $baseColor['h'] = $baseColor['h'] - $hueOffset; + $baseColor['h'] = $baseColor['h'] - $hueOffset; - if ($satOffset % 2 == 0) - $baseColor['s'] = $baseColor['s'] + $satOffset/100; - else - $baseColor['s'] = $baseColor['s'] - $satOffset/100; + if ($satOffset % 2 == 0) + $baseColor['s'] = $baseColor['s'] + $satOffset/100; + else + $baseColor['s'] = $baseColor['s'] - $satOffset/100; + + return $baseColor; + } + + protected function generateBackground() + { + $baseColor = $this->generateColors(); + $color = $this->color; if (isset($color)) $rgb = $this->hexToRGB($color); From 6e178180c9b3f7751d330c334de88c7a89d6c318 Mon Sep 17 00:00:00 2001 From: Adam Laycock Date: Wed, 13 Jul 2016 21:57:24 +0100 Subject: [PATCH 2/2] Add RGB values to baseColor array --- src/GeoPattern/GeoPattern.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/GeoPattern/GeoPattern.php b/src/GeoPattern/GeoPattern.php index deeeaae..e07db6e 100644 --- a/src/GeoPattern/GeoPattern.php +++ b/src/GeoPattern/GeoPattern.php @@ -155,6 +155,8 @@ public function generateColors(){ else $baseColor['s'] = $baseColor['s'] - $satOffset/100; + $baseColor['rgb'] = $this->hslToRGB($baseColor['h'], $baseColor['s'], $baseColor['l']); + return $baseColor; }