Last active
February 24, 2017 19:21
-
-
Save HopperMCS/183a4513f1ba659608d3d7d4d2df45ba to your computer and use it in GitHub Desktop.
For converting between RGB and Cairo's fucked up version of it
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def toCairo(): | |
| print " Enter the R value to be converted.\n"; | |
| r_one = float(raw_input(" >> ")); | |
| print "\n" | |
| print " Enter the G value to be converted.\n"; | |
| g_one = float(raw_input(" >> ")); | |
| print "\n" | |
| print " Enter the B value to be converted.\n"; | |
| b_one = float(raw_input(" >> ")); | |
| print "\n" | |
| r_two = r_one / 255; | |
| g_two = g_one / 255; | |
| b_two = b_one / 255; | |
| r_three = round(r_two, 2); | |
| g_three = round(g_two, 2); | |
| b_three = round(b_two, 2); | |
| print "cairo_set_source_rgba(" + str(r_three) + ", " + str(g_three) + ", " + str(b_three) + ", 0.8);\n\n"; | |
| def toRGBA(): | |
| print "\n Enter the R value to be converted.\n"; | |
| r_one = float(raw_input(" >> ")); | |
| print "\n" | |
| print " Enter the G value to be converted.\n"; | |
| g_one = float(raw_input(" >> ")); | |
| print "\n" | |
| print " Enter the B value to be converted.\n"; | |
| b_one = float(raw_input(" >> ")); | |
| print "\n" | |
| r_two = r_one * 255; | |
| g_two = g_one * 255; | |
| b_two = b_one * 255; | |
| print "Before Cairo, the original RGB values are: " + str(int(r_two)) + ", " + str(int(g_two)) + ", " + str(int(b_two)) + ".\n\n"; | |
| print "(c) 2017 M. Gage Morgan. All Rights Reserved. Project start date: 2/24/2017\n"; | |
| print "Script to convert between sane-people RGB and near retard-level Cairo API.\n" | |
| print "Type 'cairo' to convert to the Cairo-formatted RGB, or 'rgb' for the standard form.\n\n"; | |
| mode = raw_input(" >> "); | |
| if (mode == 'cairo'): | |
| toCairo(); | |
| elif (mode == 'rgb'): | |
| toRGBA(); | |
| else: | |
| print "Command unrecognized"; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment