Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite2ab55a

Browse files
committed
[Console] Remove redundant method getSaturation()
1 parent670e0f3 commite2ab55a

File tree

2 files changed

+11
-19
lines changed

2 files changed

+11
-19
lines changed

‎src/Symfony/Component/Console/Output/AnsiColorMode.php‎

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -78,25 +78,7 @@ private function convertFromRGB(int $r, int $g, int $b): int
7878

7979
privatefunctiondegradeHexColorToAnsi4(int$r,int$g,int$b):int
8080
{
81-
if (0 ===round($this->getSaturation($r,$g,$b) /50)) {
82-
return0;
83-
}
84-
85-
return (int) ((round($b /255) <<2) | (round($g /255) <<1) |round($r /255));
86-
}
87-
88-
privatefunctiongetSaturation(int$r,int$g,int$b):int
89-
{
90-
$r =$r /255;
91-
$g =$g /255;
92-
$b =$b /255;
93-
$v =max($r,$g,$b);
94-
95-
if (0 ===$diff =$v -min($r,$g,$b)) {
96-
return0;
97-
}
98-
99-
return (int) ((int)$diff *100 /$v);
81+
returnround($b /255) <<2 | (round($g /255) <<1) |round($r /255);
10082
}
10183

10284
/**

‎src/Symfony/Component/Console/Tests/Output/AnsiColorModeTest.php‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,16 @@ public static function provideColorsConversion(): \Generator
6464
AnsiColorMode::Ansi8->name =>248,
6565
AnsiColorMode::Ansi4->name =>7,
6666
]];
67+
68+
yield ['#000000', [
69+
AnsiColorMode::Ansi8->name =>16,
70+
AnsiColorMode::Ansi4->name =>0,
71+
]];
72+
73+
yield ['#ffffff', [
74+
AnsiColorMode::Ansi8->name =>231,
75+
AnsiColorMode::Ansi4->name =>7,
76+
]];
6777
}
6878

6979
publicfunctiontestColorsConversionWithoutSharp()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp