# ColorBlindHelperAPI Documentation
uri
- https://68ul82p053.execute-api.us-west-2.amazonaws.com
- (the uri probably won't last long)
## Quick Summary


Input & Output of the API
- Input: String targetColorCode, String[] colorToAvoid, String colorBlindType, int intensityOfIndistinguishableColor
- Output: String strokeColor, int strokeWidth, boolean dotLine
What dose the API **do**, essentially?
- Find the suitable color according to the colorBlindType (input) from to the database, find the opposite colors which are distinguishable (need to sort by distinguishability). and output the color and width of the contour line
- Avoid the color listed in colorToAvoid (input)
Things to do of the Whole process
1. get input
2. Look up the [IndistinguishableColorDataBase], get the indistinguishable colors for the designated color blind type, and hence **complete the colorToAvoid**.
3. Look up the [ColorWeShouldChooseDataBase], loop and **find out the color we should choose** while avoiding color to avoid.
4. Output the color we should choose
<br/>
# API in general
## Input
- if the color is actually distinguishable, add an attribute to the output and return the input color
| Name | Description | Type | Example |
| --------------------------------- | ------------------------------------------------------------ | ------------------- | --------------------------------- |
| indistinguishableColor | the indistinguishable color (if it's distinguishable, return ) | Color | "#fff00x" |
| colorToAvoid | colors that can't be chosen (additional colors that can't be distinguished, or adjacent colors) | Array of Colors | ["#fff00x", "#fff11x", "#fff33x"] |
| colorPreferred | color preferred to be chosen as the color of the contour line | Array of Colors | ["#fff00x", "#fff11x", "#fff33x"] |
| colorBlindType | Type of Color Blind | String or Character | "A" or "B" or "C" |
| intensityOfIndistinguishableColor | the intensity of the indistinguishable color. Use to determine the width of the contour line | Int | 3 |
Sample Input
~~~json
{
"indistinguishableColor": "#ffff00x",
"colorToAvoid": ["#ffff00x", "#ffff11x", "#ffff33x"],
"colorBlindType": "Protanopes",
"colorPreferred": '["#8B8000"]',
"intensityOfIndistinguishableColor": "3",
"isDotLine": true
}
~~~
## Output
| Name | Description | Type | Example |
| ----------- | ---------------------------------------------------------- | -------- | ------- |
| strokeColor | Color of the contour line | Hex Code | #FFFFF0 |
| strokeWidth | Width of the contour line, from 1 - 5, from thick to thin. | int | 3 |
| dotLine | should the contour line be dot line | boolean | true |
Sample Output
~~~json
{
"strokeColor" : "#FFFFFF0",
"strokeWidth" : "3",
"dotLine" : true
}
~~~
<br/><br/>
# Database:
<br/>
## DynamoDB 1: Data Base - indistinguishableColorDataBase
- This database stores the distinguishable colors of a specific type of color blind
- Input to search (TypeOfColorBlind, )
An Item in the Data Base contains the following information
| Name | Description | Type | Sample |
| ---------------------- | ------------------------------------------------------------ | ------- | ------- |
| TypeOfColorBlind | (partition key); The type of Color Blind | String | A |
| SortKey | (Sort Key) This key will determine the order in the table. For example, if a item "blue" is classified as ColorBlindType "A", and its SortKey is zero, this element would be placed at the top of all the other type "A" items. The sort key for items under the same ColorBlindType have to be different. | integer | 0 |
| indistinguishableColor | The color code of the the indistinguishable color | String | #FFFFFF |
## DynamoDB 2: Data Base - ColorWeShouldChooseDataBase
- Will find highly distinguishable color for a indistinguishable color (input) for a specific color blind
- This database will take color blind type and the colorToAvoid as input, and provide a color suitable for the contour line
An Item in the Data Base contains the following information
| Name | Description | Type | Sample |
| ---------------------- | ------------------------------------------------------------ | ------ | ------- |
| ColorBlindType | (partition key) The type of color blind | String | A |
| indistinguishableColor | (sort key) This value tells us what color is highly distinguishable with the "color" that store in this item. For example, if the color blind cannot distinguish yellow, and we know that it will be great if the contour line is blue (which will be store in "Color" attribute), then we store "yellow" in this attribute. | String | #444444 |
| ColorWeShouldChoose | The color of this item, which is a highly distinguishable color. | String | #666666 |
<br/>
In the code, we will create a Data Structure to store the data fetched from the database.
An item contains the following information
| Name | Type | | |
| ---------------------- | ------ | ---- | ---- |
| indistinguishableColor | String | | |
| ColorWeShouldChoose | String | | |
| | | | |
#### Yi-Ting's Note Pad
default value of theResponse, remember to add
~~~json
var theResponse = { //default value
body:
JSON.stringify({ErrorMessage : "Error: Illegal Input."})
};
~~~
Test Case:
~~~Test Case
https://68ul82p053.execute-api.us-west-2.amazonaws.com?indistinguishableColor=%ffff00x&colorToAvoid=["%ffff00x", "%ffff11x", "%ffff33x"]&colorBlindType=Protanopes&colorPreferred=["%8B8000"]&intensityOfIndistinguishableColor=3&isDotLine=true#ffff00x", "#ffff11x", "#ffff33x"]&colorBlindType=Protanopes&colorPreferred=["#8B8000"]&intensityOfIndistinguishableColor=3&isDotLine=true
~~~
Test Case 2
~~~json
{
"indistinguishableColor": "#32CD32",
"colorToAvoid": ["#ffff11x", "#ffff33x"],
"colorBlindType": "Deuteranopes",
"colorPreferred": '["#8B8000"]',
"intensityOfIndistinguishableColor": "1",
"isDotLine": false
}
~~~
#### Questions:
- [x] How should we determine the **width** of the contour line? Do we calculate it through the brightness of the color? then we should use RGB instead of Hex because it's easier to calculate the brightness.
- We are calculating it by the input value: intensityOfIndistinguishableColor
- [x] How should we determine whether the line should be dot line?
- the dot line should be enabled if two adjacent indistinguishable color chosen the same color for the contour line, so we probably should take dot line as input and let the user of our API decide what to do?