Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
WP Mail
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wpdesk
Library
WP Mail
Commits
e14e5e81
Commit
e14e5e81
authored
10 months ago
by
Piotr Potrebka
Browse files
Options
Downloads
Patches
Plain Diff
feat: refactor
parent
b537f22a
No related branches found
No related tags found
2 merge requests
!5
Devel
,
!4
Refactor/templates
Pipeline
#406284
passed with warnings with stages
in 33 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Helpers/ColorConversion.php
+10
-10
10 additions, 10 deletions
src/Helpers/ColorConversion.php
with
10 additions
and
10 deletions
src/Helpers/ColorConversion.php
+
10
−
10
View file @
e14e5e81
...
@@ -11,7 +11,7 @@ class ColorConversion {
...
@@ -11,7 +11,7 @@ class ColorConversion {
*
*
* @return bool True if a light color.
* @return bool True if a light color.
*/
*/
public
static
function
is_hex_light
(
$color
)
{
public
static
function
is_hex_light
(
$color
)
:
bool
{
$hex
=
str_replace
(
'#'
,
''
,
$color
);
$hex
=
str_replace
(
'#'
,
''
,
$color
);
$c_r
=
hexdec
(
substr
(
$hex
,
0
,
2
)
);
$c_r
=
hexdec
(
substr
(
$hex
,
0
,
2
)
);
...
@@ -31,11 +31,11 @@ class ColorConversion {
...
@@ -31,11 +31,11 @@ class ColorConversion {
/**
/**
* Convert RGB to HEX.
* Convert RGB to HEX.
*
*
* @param
mixed
$color Color.
* @param
string
$color Color.
*
*
* @return array
* @return array
*/
*/
public
static
function
rgb_from_hex
(
$color
)
{
public
static
function
rgb_from_hex
(
string
$color
)
:
array
{
$color
=
str_replace
(
'#'
,
''
,
$color
);
$color
=
str_replace
(
'#'
,
''
,
$color
);
// Convert shorthand colors to full format, e.g. "FFF" -> "FFFFFF".
// Convert shorthand colors to full format, e.g. "FFF" -> "FFFFFF".
$color
=
preg_replace
(
'~^(.)(.)(.)$~'
,
'$1$1$2$2$3$3'
,
$color
);
$color
=
preg_replace
(
'~^(.)(.)(.)$~'
,
'$1$1$2$2$3$3'
,
$color
);
...
@@ -52,17 +52,17 @@ class ColorConversion {
...
@@ -52,17 +52,17 @@ class ColorConversion {
/**
/**
* Make HEX color darker.
* Make HEX color darker.
*
*
* @param
mixed
$color Color.
* @param
string
$color Color.
* @param int $factor Darker factor.
* @param int $factor Darker factor.
* Defaults to 30.
* Defaults to 30.
*
*
* @return string
* @return string
*/
*/
public
static
function
hex_darker
(
$color
,
$factor
=
30
)
{
public
static
function
hex_darker
(
string
$color
,
int
$factor
=
30
)
:
string
{
$base
=
self
::
rgb_from_hex
(
$color
);
$base
=
self
::
rgb_from_hex
(
$color
);
$color
=
'#'
;
$color
=
'#'
;
foreach
(
$base
as
$k
=>
$v
)
{
foreach
(
$base
as
$v
)
{
$amount
=
$v
/
100
;
$amount
=
$v
/
100
;
$amount
=
self
::
round
(
$amount
*
$factor
);
$amount
=
self
::
round
(
$amount
*
$factor
);
$new_decimal
=
$v
-
$amount
;
$new_decimal
=
$v
-
$amount
;
...
@@ -81,17 +81,17 @@ class ColorConversion {
...
@@ -81,17 +81,17 @@ class ColorConversion {
/**
/**
* Make HEX color lighter.
* Make HEX color lighter.
*
*
* @param
mixed
$color Color.
* @param
string
$color Color.
* @param int $factor Lighter factor.
* @param int
$factor Lighter factor.
* Defaults to 30.
* Defaults to 30.
*
*
* @return string
* @return string
*/
*/
public
static
function
hex_lighter
(
$color
,
$factor
=
30
)
{
public
static
function
hex_lighter
(
string
$color
,
int
$factor
=
30
)
:
string
{
$base
=
self
::
rgb_from_hex
(
$color
);
$base
=
self
::
rgb_from_hex
(
$color
);
$color
=
'#'
;
$color
=
'#'
;
foreach
(
$base
as
$k
=>
$v
)
{
foreach
(
$base
as
$v
)
{
$amount
=
255
-
$v
;
$amount
=
255
-
$v
;
$amount
=
$amount
/
100
;
$amount
=
$amount
/
100
;
$amount
=
self
::
round
(
$amount
*
$factor
);
$amount
=
self
::
round
(
$amount
*
$factor
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment