-
Notifications
You must be signed in to change notification settings - Fork 9
/
brewtransform.ado
95 lines (69 loc) · 3.28 KB
/
brewtransform.ado
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
********************************************************************************
* Description of the Program - *
* This program takes an RGB variable and creates/returns transforms of the RGB *
* value for each of the types of color sightedness impairment. *
* *
* Data Requirements - *
* none *
* *
* Dependencies - *
* libbrewscheme.mlib *
* *
* Program Output - *
* achronopsia - Complete color blindness RGB transform/translate *
* protanopia - Red color blindness RGB transform/translate *
* deuteranopia - Green color blindness RGB transform/translate *
* tritanopia - Blue color blindness RGB transform/translate *
* *
* Lines - *
* 94 *
* *
********************************************************************************
*! brewtransform
*! v 1.0.1
*! 03APR2016
// Drop the program if already loaded in memory
cap prog drop brewtransform
// Define the program brewtransform
prog def brewtransform
// Version to use for interpretation of code
version 13.1
// Syntax structure for program
syntax varlist(max=1 string)
// Check for brewscheme Mata library
qui: brewlibcheck
// Get all unique rgb values
qui: levelsof `varlist', loc(colors)
// New variable creation/checks
foreach v in achromatopsia protanopia deuteranopia tritanopia {
// Check to see if variable exists
cap confirm new v `v'
// If variable does not exist
if _rc == 0 {
// Create the variable
qui: g `v' = ""
} // End IF Block for new variable
} // End Loop for color transformation variable creation
// Loop over the rgb values
foreach rgbval of loc colors {
// Get the transformed rgb
mata translateColor(`: subinstr loc rgbval `" "' `", "', all')
// Set achomatopsia value
qui: replace achromatopsia = "`achromatopsia'" if `varlist' == "`rgbval'"
// Set protanopia value
qui: replace protanopia = "`protanopia'" if `varlist' == "`rgbval'"
// Set deuteranopia value
qui: replace deuteranopia = "`deuteranopia'" if `varlist' == "`rgbval'"
// Set tritanopia value
qui: replace tritanopia = "`tritanopia'" if `varlist' == "`rgbval'"
} // End loop over colors
// Label the color sightedness impairment variables
la var achromatopsia `"`achromatopsialab' RGB Transformed Equivalent"'
// Label the color sightedness impairment variables
la var protanopia `"`protanopialab' RGB Transformed Equivalent"'
// Label the color sightedness impairment variables
la var deuteranopia `"`deuteranopialab' RGB Transformed Equivalent"'
// Label the color sightedness impairment variables
la var tritanopia `"`tritanopialab' RGB Transformed Equivalent"'
// End of program
end