-
Notifications
You must be signed in to change notification settings - Fork 20k
Added algorithm for color contrast ratio. #1794
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I'm closing this as I've replaced it with #2023 which merges to |
would you please remove |
I could try, but that was the Google Java Formatter that did that, not me. |
it is weird, Fromatter will format only those files which are linked to the PR. If it starts formatting files which are not linked in PR then there are so many files in the repository which are not up to standard, it would have formatted all of them. Well try to remove this from this PR. |
I removed both |
How did you removed |
I just did |
🤔 try |
Tried it, however no changes were made, no files were staged, and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a test function to verify the implementation, rest of the code looks good to me.
Just checking, is there a section for unit tests? public static void main(String args[]) {
final ColorContrastRatio algorithmImpl = new ColorContrastRatio();
// Relative Luminance: 0.12215748057375966
final Color foreground = new Color(23, 103, 154);
// Relative Luminance: 0.7898468477881603
final Color background = new Color(226, 229, 248);
// Contrast Ratio: 4.878363954846178
final double contrastRatio = algorithmImpl.getContrastRatio(foreground, background);
System.out.println(contrastRatio);
} Looking at other classes, this appears to be how they're testing it also. |
May I also ask, you requested some javadocs have Could you explain why you wanted this or what it does? |
yes, i know it does have a main method. what i want to say is that, create a member function with name void test() {
final ColorContrastRatio algorithmImpl = new ColorContrastRatio();
// test 1
final Color foreground = new Color(23, 103, 154);
final Color background = new Color(226, 229, 248);
final double contrastRatio = algorithmImpl.getContrastRatio(foreground, background);
assert contrastRation == 4.878363954846178 : "Failed test 1";
// test 2
..............................
..............................
.............................
}
public static void main(String [] args) {
// call test() here to execute test.
} |
Currently this repository is not up to a good standard, I am planing to improve this repository as we did in C++ repository. The reason i am enforcing javadocs style is, with the help of javadocs we can generate documentation for this repository automatically. Other files are not mainted properly, we will be improving them soon. please have a look here https://thealgorithms.github.io/C-Plus-Plus/ (this is the documentaion of C++ repository algorithms, it is generated automatically using Doxygen) |
Soon we will be updating the contribution guidelines so that people will follow proper guildelines for each and every PR. Thereby facilitating faster reviews and less burden on Maintainers and Contributors. |
Understood, thanks for clarifying, I believe I've done this now.
Ahh I see, I wasn't familiar with Doxygen before now, I've only ever used the vanilla Javadocs. That would explain the markdown and odd tags I've never seen before. High hopes this is fine now? Don't be afraid to let me know if there are any other issues. |
Co-authored-by: Ayaan Khan <ayaankhan98@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks for your contribution @SethFalco
Describe your change:
This implements the procedure documented on the W3 website to calculate the contrast ratio between two colors.
https://www.w3.org/TR/WCAG20-TECHS/G17.html#G17-procedure
References
N/A
Checklist: