Skip to content

Commit 956f5a2

Browse files
authored
Merge pull request #11 from marijnvdwerf/typo
Fix dark vibrant swatch generation
2 parents b5cc631 + df2ab74 commit 956f5a2

File tree

2 files changed

+186
-1
lines changed

2 files changed

+186
-1
lines changed

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
}
3131
},
3232
"require": {
33-
"php": ">=5.3",
33+
"php": ">=5.4",
3434
"intervention/image": "~2.2"
3535
},
3636
"suggest": {
@@ -42,5 +42,8 @@
4242
"phpunit/phpunit": "^6.1",
4343
"symfony/debug": "~2.6",
4444
"symfony/var-dumper": "~2.6"
45+
},
46+
"scripts": {
47+
"test": "phpunit"
4548
}
4649
}

tests/SpecsTest.php

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
<?php
2+
3+
namespace marijnvdwerf\palette\Tests;
4+
5+
use Intervention\Image\ImageManager;
6+
use marijnvdwerf\palette\Palette;
7+
use PHPUnit\Framework\TestCase;
8+
9+
class SpecsTest extends TestCase
10+
{
11+
/**
12+
* @dataProvider specsProvider
13+
*/
14+
public function testSpecsImage($title, array $expected)
15+
{
16+
$manager = new ImageManager();
17+
$image = $manager->make(__DIR__ . '/../specs/artwork/' . $title . '.png');
18+
$palette = Palette::generate($image);
19+
20+
$funcs = [
21+
'vibrant' => 'getVibrantSwatch',
22+
'light_vibrant' => 'getLightVibrantSwatch',
23+
'dark_vibrant' => 'getDarkVibrantSwatch',
24+
'muted' => 'getMutedSwatch',
25+
'light_muted' => 'getLightMutedSwatch',
26+
'dark_muted' => 'getDarkMutedSwatch',
27+
];
28+
29+
$actual = [];
30+
foreach ($funcs as $field => $func) {
31+
$swatch = $palette->$func();
32+
if ($swatch !== null) {
33+
$actual[$field] = $swatch->getColor()->asRGBColor()->asHex();
34+
} else {
35+
$actual[$field] = null;
36+
}
37+
}
38+
39+
foreach ($expected as $key => $value) {
40+
$this->assertEquals($value, $actual[$key], $title . ' - ' . $key);
41+
}
42+
}
43+
44+
public function specsProvider()
45+
{
46+
return [
47+
[
48+
'Ellie Goulding - Halcyon Days',
49+
[
50+
'vibrant' => '#A21171',
51+
'light_vibrant' => '#65C6F1',
52+
'dark_vibrant' => '#0D1E4A',
53+
'muted' => '#A365A1',
54+
'light_muted' => '#E0C6D8',
55+
'dark_muted' => '#605A86',
56+
],
57+
],
58+
[
59+
'Fitz & The Tantrums - More Than Just A Dream',
60+
[
61+
'vibrant' => '#B32F7F',
62+
'light_vibrant' => '#E5A4CC',
63+
'dark_vibrant' => '#101226',
64+
'muted' => '#90507B',
65+
'light_muted' => '#90A1A6',
66+
'dark_muted' => '#1D2537',
67+
],
68+
],
69+
[
70+
'Foals - Holy Fire',
71+
[
72+
'vibrant' => '#D9CC80',
73+
'light_vibrant' => '#E9E0A7',
74+
'dark_vibrant' => '#665424',
75+
'muted' => '#B19F56',
76+
'light_muted' => null,
77+
'dark_muted' => '#2B2617',
78+
],
79+
],
80+
[
81+
'Foster The People - Supermodel',
82+
[
83+
'vibrant' => '#EAB040',
84+
'light_vibrant' => '#EDEAB9',
85+
'dark_vibrant' => '#184D66',
86+
'muted' => '#61929E',
87+
'light_muted' => '#A1C3B1',
88+
'dark_muted' => '#543B65',
89+
],
90+
],
91+
[
92+
'Jamie Lidell - Jamie Lidell',
93+
[
94+
'vibrant' => '#D92081',
95+
'light_vibrant' => '#DE9EBA',
96+
'dark_vibrant' => '#108B50',
97+
'muted' => '#60A552',
98+
'light_muted' => '#BDC2C4',
99+
'dark_muted' => '#292247',
100+
],
101+
],
102+
[
103+
'Janelle Monae - The Electric Lady',
104+
[
105+
'vibrant' => '#CA5749',
106+
'light_vibrant' => '#DA5D66',
107+
'dark_vibrant' => '#5B2931',
108+
'muted' => '#9E5F68',
109+
'light_muted' => '#DDB0BD',
110+
'dark_muted' => '#2D3E56',
111+
],
112+
],
113+
[
114+
'Kodaline - In A Perfect World',
115+
[
116+
'vibrant' => '#4998B6',
117+
'light_vibrant' => null,
118+
'dark_vibrant' => '#254D5C',
119+
'muted' => '#3D6672',
120+
'light_muted' => '#97ACB8',
121+
'dark_muted' => '#233C40',
122+
],
123+
],
124+
[
125+
'OneRepublic - Native',
126+
[
127+
'vibrant' => '#972837',
128+
'light_vibrant' => null,
129+
'dark_vibrant' => '#661838',
130+
'muted' => '#976866',
131+
'light_muted' => '#A694B5',
132+
'dark_muted' => '#6C4045',
133+
],
134+
],
135+
[
136+
'Pharrell Williams - G I R L',
137+
[
138+
'vibrant' => '#E5B531',
139+
'light_vibrant' => null,
140+
'dark_vibrant' => '#512922',
141+
'muted' => null,
142+
'light_muted' => null,
143+
'dark_muted' => '#1F1010',
144+
],
145+
],
146+
[
147+
'Rhye - Woman',
148+
[
149+
'vibrant' => null,
150+
'light_vibrant' => null,
151+
'dark_vibrant' => null,
152+
'muted' => '#7E7F83',
153+
'light_muted' => '#BABCBD',
154+
'dark_muted' => '#3F4044',
155+
],
156+
],
157+
[
158+
'The Strokes - Comedown Machine',
159+
[
160+
'vibrant' => '#B22D29',
161+
'light_vibrant' => null,
162+
'dark_vibrant' => '#66312A',
163+
'muted' => null,
164+
'light_muted' => null,
165+
'dark_muted' => null,
166+
167+
],
168+
],
169+
[
170+
'Yuna - Nocturnal',
171+
[
172+
'vibrant' => '#FAE812',
173+
'light_vibrant' => '#D7A7A9',
174+
'dark_vibrant' => '#AF1A34',
175+
'muted' => '#A36576',
176+
'light_muted' => '#DFD2D1',
177+
'dark_muted' => '#5D3632',
178+
],
179+
],
180+
];
181+
}
182+
}

0 commit comments

Comments
 (0)