├── .codeclimate.yml
├── .editorconfig
├── .gitignore
├── .scrutinizer.yml
├── .travis.yml
├── LICENSE
├── README.md
├── autoload.php
├── composer.json
├── composer.lock
├── meta
└── sample.php
├── php5
├── cache.php
├── check.php
├── color.php
├── convert.php
├── css.php
├── error.php
├── generate.php
├── hsl.php
├── main.php
├── main_peripheral.php
├── modify.php
├── regulate.php
├── scheme.php
└── yiq_scheme.php
├── phpunit-scrutinizer.xml
├── phpunit-travis.xml
├── phpunit.xml
├── src
├── check.php
├── convert
│ ├── cmyk.php
│ ├── hex.php
│ ├── hsb.php
│ ├── hsl.php
│ └── rgb.php
├── css.php
├── data
│ ├── cache.php
│ ├── color
│ │ ├── space.php
│ │ ├── space
│ │ │ ├── cmyk.php
│ │ │ ├── hsb.php
│ │ │ ├── hsl.php
│ │ │ └── rgb.php
│ │ ├── type.php
│ │ └── x11.php
│ ├── store.old.php
│ ├── store.php
│ └── type.php
├── error.php
├── exceptions
│ ├── general_error.php
│ ├── invalid_argument.php
│ ├── invalid_color.php
│ ├── invalid_config.php
│ ├── invalid_value.php
│ └── value_out_of_range.php
├── generate.php
├── hsl.php
├── interfaces
│ └── converter.php
├── main.php
├── main_peripheral.php
├── modify.php
├── regulate.php
├── scheme.php
├── traits
│ └── converter.php
├── validate.php
└── yiq_scheme.php
├── tasks.todo
├── testing
├── bootstrap.php
└── tests
│ ├── 00_ErrorTest.php
│ ├── 01_RegulateTest.php
│ ├── 02_ConverterTest.php
│ ├── 03_GeneratorTest.php
│ ├── 04_CheckTest.php
│ ├── 05_SchemeTest.php
│ ├── 06_YIQSchemeTest.php
│ ├── 07_CacheTest.php
│ ├── 08_HSLTest.php
│ ├── 09_ColorTest.php
│ ├── 10_MainTest.php
│ ├── 11_CSSTest.php
│ └── 12_CloneTest.php
└── tput.exe.stackdump
/.codeclimate.yml:
--------------------------------------------------------------------------------
1 | engines:
2 | duplication:
3 | enabled: true
4 | config:
5 | languages:
6 | - php
7 | fixme:
8 | enabled: true
9 | phan:
10 | enabled: true
11 | config:
12 | file_extensions: "php"
13 | fixme:
14 | enabled: true
15 | markdownlint:
16 | enabled: true
17 | ratings:
18 | paths:
19 | - "**.php"
20 | - "**.md"
21 | exclude_paths:
22 | - "meta/"
23 | - "testing/"
24 | - "php5/"
25 | - "autload.php"
26 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | # Standard
2 | [*]
3 | charset = utf-8
4 | end_of_line = lf
5 | insert_final_newline = true
6 | indent_size = 2
7 | indent_style = tab
8 |
9 | # Spaces are important
10 | [*.yml]
11 | indent_style = space
12 |
13 | [*.sql]
14 | indent_style = space
15 |
16 | # Windows endings
17 | [*.bat]
18 | end_of_line = crlf
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ### Unit Testing ###
2 | /coverage
3 | /vendor
4 | /meta/test.php
5 | sample.html
6 |
7 | ### OS ###
8 | .DS_Store
9 | .DS_Store?
10 | ._*
11 | .Spotlight-V100
12 | .Trashes
13 | Icon?
14 | ehthumbs.db
15 | Thumbs.db
16 |
--------------------------------------------------------------------------------
/.scrutinizer.yml:
--------------------------------------------------------------------------------
1 | build:
2 | tests:
3 | override:
4 | -
5 | command: 'phpunit -c phpunit-scrutinizer.xml'
6 | environment:
7 | php:
8 | version: 7.0.8
9 | tools:
10 | external_code_coverage:
11 | timeout: 600
12 | filter:
13 | paths: [src/*]
14 | checks:
15 | php:
16 | verify_property_names: true
17 | verify_argument_usable_as_reference: true
18 | verify_access_scope_valid: true
19 | variable_existence: true
20 | use_self_instead_of_fqcn: true
21 | use_statement_alias_conflict: true
22 | uppercase_constants: true
23 | uppercase_basic_constants: true
24 | unused_variables: true
25 | unused_properties: true
26 | unused_parameters: true
27 | unused_methods: true
28 | unreachable_code: true
29 | too_many_arguments: true
30 | spacing_of_function_arguments: true
31 | spacing_around_non_conditional_operators: true
32 | spacing_around_conditional_operators: true
33 | space_after_cast: true
34 | single_namespace_per_use: true
35 | security_vulnerabilities: true
36 | return_doc_comments: true
37 | return_doc_comment_if_not_inferrable: true
38 | require_scope_for_properties: true
39 | require_scope_for_methods: true
40 | require_php_tag_first: true
41 | require_braces_around_control_structures: true
42 | remove_trailing_whitespace: true
43 | remove_php_closing_tag: true
44 | property_assignments: true
45 | prefer_while_loop_over_for_loop: true
46 | prefer_unix_line_ending: true
47 | precedence_mistakes: true
48 | precedence_in_conditions: true
49 | php5_style_constructor: true
50 | parameter_non_unique: true
51 | parameter_doc_comments: true
52 | param_doc_comment_if_not_inferrable: true
53 | overriding_private_members: true
54 | optional_parameters_at_the_end: true
55 | non_commented_empty_catch_block: true
56 | no_trailing_whitespace: true
57 | no_space_inside_cast_operator: true
58 | no_space_between_concatenation_operator: true
59 | no_space_before_semicolon: true
60 | no_space_around_object_operator: true
61 | no_short_open_tag: true
62 | no_non_implemented_abstract_methods: true
63 | no_goto: true
64 | no_eval: true
65 | no_empty_statements: true
66 | no_else_if_statements: true
67 | no_debug_code: true
68 | missing_arguments: true
69 | method_calls_on_non_object: true
70 | lowercase_php_keywords: true
71 | instanceof_class_exists: true
72 | function_body_start_on_same_line: true
73 | foreach_usable_as_reference: true
74 | foreach_traversable: true
75 | fix_use_statements:
76 | remove_unused: true
77 | preserve_multiple: false
78 | preserve_blanklines: false
79 | order_alphabetically: true
80 | fix_php_opening_tag: true
81 | fix_doc_comments: true
82 | ensure_lower_case_builtin_functions: true
83 | encourage_single_quotes: true
84 | encourage_postdec_operator: true
85 | deprecated_code_usage: true
86 | deadlock_detection_in_loops: true
87 | code_rating: true
88 | closure_use_not_conflicting: true
89 | catch_class_exists: true
90 | avoid_usage_of_logical_operators: true
91 | avoid_unnecessary_concatenation: true
92 | avoid_todo_comments: true
93 | avoid_space_indentation: true
94 | avoid_multiple_statements_on_same_line: true
95 | avoid_fixme_comments: true
96 | avoid_corrupting_byteorder_marks: true
97 | assignment_of_null_return: true
98 | argument_type_checks: true
99 | align_assignments: true
100 | newline_at_end_of_file: true
101 | more_specific_types_in_doc_comments: true
102 | avoid_perl_style_comments: true
103 |
104 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: php
2 | before_script:
3 | - wget https://scrutinizer-ci.com/ocular.phar
4 | - composer install -n
5 | script:
6 | - ./vendor/phpunit/phpunit/phpunit -c phpunit-travis.xml
7 | after_script:
8 | - php ocular.phar code-coverage:upload --format=php-clover coverage.clover
9 | - php vendor/bin/codacycoverage clover coverage.clover
10 | - ./vendor/bin/test-reporter --coverage-report coverage.clover
11 | php:
12 | - 5.6
13 | - 7.0
14 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The PHP-Color documentation & source code (hereafter referred to as "Library") by Nicholas Summers (hereafter referred to as "Author") is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License with the below "Additional Terms" superseding it. To view a copy of the Creative Commons license, visit https://creativecommons.org/licenses/by-nc-nd/4.0/. From now on "License" refers to this combination of licensing.
2 |
3 | Additional Terms:
4 |
5 | 1. Any person or non-profit entity or may use this Library for personal or professional use as long as the Library as well as any of its parts are not sold in any fashion, and users are not forced to pay to use it in any way.
6 | 2. Anyone may use this Library for purely internal use as long as the Library as well as any of its parts are available without payment and are not publicly accessible.
7 | 3. Anyone seeking to sell this Library or use this Library in a commercial environment MUST first obtain a OEM license from the Author.
8 | 4. Anyone in direct violation of this License is liable for a minimum of $50,000 in damages, plus an additional $10 per user, and agrees to refund any charge or fees collected as a result of violating this License.
9 | 5. By downloading or using this Library you agree to all the License terms.
10 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # PHP Color [](https://njordon.mit-license.org/@2016) [](https://travis-ci.org/ProjectCleverWeb/PHP-Color) [](https://scrutinizer-ci.com/g/ProjectCleverWeb/PHP-Color/) [](https://scrutinizer-ci.com/g/ProjectCleverWeb/PHP-Color/) [](https://codeclimate.com/github/ProjectCleverWeb/PHP-Color)
2 |
3 | This is a PHP 7 library for working with RGB, HSL, and Hexadecimal colors. Create schemes, modify specific color properties, export CMYK, and make color suggestions quickly and easily with this stand-alone library.
4 |
5 | Demo: [jsfiddle.net/t3LL4q14](http://jsfiddle.net/t3LL4q14/embedded/result/)
6 |
7 | ### Download:
8 |
9 | [](https://github.com/ProjectCleverWeb/PHP-Color/releases)
10 |
11 | Copyright © 2016 Nicholas Jordon — All Rights Reserved
12 |
13 | ## Features
14 |
15 | * Convert any color between the RGB, HSL, HSB, Hexadecimal, and CMYK color spectrums.
16 | * Dynamically generate 10 different color scheme algorithims for any color. (That's over 165,000,000 possible schemes)
17 | * Check whether a color appears visually dark or light. (uses [YIQ](https://en.wikipedia.org/wiki/YIQ) weights for better accuraccy)
18 | * Easily modify a color's hue, saturation, light, red, green, blue, and alpha (transparcency) values.
19 | * Generate CSS values on the fly
20 | * Find the contrast between 2 colors.
21 | * Dynamically generate random colors, including for specific color ranges.
22 | * All errors are recoverable, and errors can be triggered as exceptions (default), using `trigger_error()`, or can be turned off for all instances.
23 |
24 | ## Installation & Usage
25 |
26 | See the [Official Wiki on Github](https://github.com/ProjectCleverWeb/PHP-Color/wiki) for all documentation.
27 |
28 | ## Contributing
29 |
30 | **Contributing *via* Suggestions:**
31 | The best way to submit a suggestion is to open an issue on Github and prefix the
32 | title with `[Suggestion]`. Alternatively, you can email your suggestions to
33 | projectcleverweb(at)gmail(dot)com.
34 |
35 | **Contributing *via* Reporting Problems:**
36 | All problems must be reported via Github's
37 | [issue tracker](https://github.com/ProjectCleverWeb/PHP-Color/issues).
38 |
39 | **Contributing *via* Code:**
40 |
41 | 1. Fork the repo on Github: [github.com/ProjectCleverWeb/PHP-Color](https://github.com/ProjectCleverWeb/PHP-Color)
42 | 2. Make your changes.
43 | 3. Send a pull request to have your changes reviewed.
44 |
45 | ## License
46 |
47 | The PHP-Color documentation & source code (hereafter referred to as "Library") by Nicholas Summers (hereafter referred to as "Author") is licensed
48 | under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License with the below "Additional Terms" superseding it.
49 | To view a copy of the Creative Commons license, visit [creativecommons.org/licenses/by-nc-nd/4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/). From now on "License" refers to this combination of licensing.
50 |
51 | **Additional Terms:**
52 |
53 | 1. Any person or non-profit entity or may use this Library for personal or professional use as long as the Library as well as any of its parts are not sold in any fashion, and users are not forced to pay to use it in any way.
54 | 2. Anyone may use this Library for purely internal use as long as the Library as well as any of its parts are available without payment and are not publicly accessible.
55 | 3. Anyone seeking to sell this Library or use this Library in a commercial environment MUST first obtain a OEM license from the Author.
56 | 4. Anyone in direct violation of this License is liable for a minimum of $50,000 in damages, plus an additional $10 per user, and agrees to refund any charge or fees collected as a result of violating this License.
57 | 5. By downloading or using this Library you agree to all the License terms.
58 |
--------------------------------------------------------------------------------
/autoload.php:
--------------------------------------------------------------------------------
1 | =5.3"
52 | },
53 | "require-dev": {
54 | "phpunit/phpunit": "~5.5.5",
55 | "codeclimate/php-test-reporter": "dev-master",
56 | "codacy/coverage": "dev-master"
57 | },
58 | "autoload": {
59 | "files": ["autoload.php"]
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/meta/sample.php:
--------------------------------------------------------------------------------
1 | 72, 's' => 20, 'l' => 20)),
22 | new main(array('h' => 108, 's' => 30, 'l' => 30)),
23 | new main(array('h' => 144, 's' => 40, 'l' => 40)),
24 | new main(array('h' => 180, 's' => 50, 'l' => 50)),
25 | new main(array('h' => 216, 's' => 60, 'l' => 60)),
26 | new main(array('h' => 252, 's' => 70, 'l' => 70)),
27 | new main(array('h' => 288, 's' => 80, 'l' => 80)),
28 | new main(array('h' => 324, 's' => 90, 'l' => 90))
29 | ];
30 |
31 |
32 | $colors = array_reverse($colors);
33 |
34 | // Scheme functions and their definitions
35 | $funcs = [
36 | 'shades' => '5 different shades of one color. (unaffected by YIQ)',
37 | 'monochromatic' => '5 complementary shades of one color. (unaffected by YIQ)',
38 | 'analogous' => 'These colors are all close to each other on a color wheel.',
39 | 'complementary' => '2 of these colors are a different shade of the base color. The other 2 are a weighted opposite of the base color.',
40 | 'triad' => 'These colors are all equally distanced from each other on a color wheel, 2 of which have an alternate shade.',
41 | 'weighted_triad' => 'These colors are all similarly distanced from each other on a color wheel, 2 of which have an alternate shade. These colors are all slightly closer to the base color than in a normal triad.',
42 | 'tetrad' => '3 of these colors are all equally distanced from each other on a color wheel, plus 1 alternated shade for the base color and the 1 color that is opposite of the base color.',
43 | 'weighted_tetrad' => '3 of these colors are all similarly distanced from each other on a color wheel, the base color has an alternate shade, and there is a weighted opposite color. These colors are all slightly closer to the base color than in a normal tetrad.',
44 | 'compound' => 'These colors use mathematical offsets that usually complement each other well, and can highlight the base color.',
45 | 'rectangular' => '4 of these colors form a rectangle on a color wheel, and 1 color is an alternate shade for the base color.'
46 | ];
47 | $fmt =
48 | '
rgb(%3$s) / hsl(%4$s) / hsb(%5$s) / cmyk(%6$s)