Page 1 of 1

A function for a String to Color value:

Posted: 09 Jul 2012
by arjfca
Hello

I created a function based on information received from user JoshM to translate in EasyLanguage value a Named color. The function will return Blue for the word "Blue"

Blue is a reserved word and it is considered as an Integer

The function to be created as a Numeric Function

Ex: NameToColor("Blue") will return Blue ** as an Integer
**: Constant, used to designate the color Blue

Code: Select all

Inputs:
ColourName(StringSimple);

Variables:
colourInLowerString(""); // not case-sensitive anymore

colourInLowerString = LowerStr(ColourName);

switch (colourInLowerString ) begin

case "blue":
NameToColor = blue;
case "black":
NameToColor = black;
case "cyan":
NameToColor = cyan;
Case"green":
NameToColor = Green;
Case"magenta":
NameToColor = Magenta;
Case "red" :
NameToColor = Red;
Case "yellow" :
NameToColor = Yellow;
Case "white" :
NameToColor = White;
Case "darkblue" :
NameToColor = DarkBlue;
Case "darkcyan":
NameToColor = DarkCyan;
Case "darkgreen":
NameToColor = DarkGreen;
Case "darkmagenta":
NameToColor = DarkMagenta;
Case "darkred":
NameToColor = DarkRed;
Case "darkbrown" :
NameToColor = DarkBrown;
Case "darkgray":
NameToColor = DarkGray;
Case "lightgray":
NameToColor = LightGray;
end;

Re: A function for a String to Color value:

Posted: 09 Jul 2012
by TJ
Hello

I created a function based on information received from user JoshM to translate in EasyLanguage value a Named color. The function will return Blue for the word "Blue"

Blue is a reserved word and it is considered as an Integer

The function to be created as a Numeric Function

Ex: NameToColor("Blue") will return Blue ** as an Integer
**: Constant, used to designate the color Blue
...
Interesting.

Thanks for sharing the code.

Can you explain how, or describe under what operation, to use this function?

Re: A function for a String to Color value:

Posted: 09 Jul 2012
by arjfca
Hello

I created a function based on information received from user JoshM to translate in EasyLanguage value a Named color. The function will return Blue for the word "Blue"

Blue is a reserved word and it is considered as an Integer

The function to be created as a Numeric Function

Ex: NameToColor("Blue") will return Blue ** as an Integer
**: Constant, used to designate the color Blue
...
Interesting.

Thanks for sharing the code.

Can you explain how, or describe under what operation, to use this function?
I'm creating an indicator to display a horizontal Trend Line list. The Trend Line list is created in Excel and saved as a Global Variable. Once created, The indicator in MC will be called and a trend line will be created for each entry in the list. I will be able to set the size and the style and color for each of them.

The trend line list is saved as a CSV string

It will be easy to transport all trend line from one chart to the other

The Excel function is finished. Now, I'm working on the MC part. Later, I will add a text reference to each Trend Line

Steps'
Erase existing Trend Line
Read Trend line list
While Trend line to display
Install each of them with is own attributes
Loop

Martin

Re: A function for a String to Color value:

Posted: 09 Jul 2012
by TJ
I'm creating an indicator to display a horizontal Trend Line list. The Trend Line list is created in Excel and saved as a Global Variable. Once created, The indicator in MC will be called and a trend line will be created for each entry in the list. I will be able to set the size and the style and color for each of them.

The trend line list is saved as a CSV string

It will be easy to transport all trend line from one chart to the other

The Excel function is finished. Now, I'm working on the MC part. Later, I will add a text reference to each Trend Line

Steps'
Erase existing Trend Line
Read Trend line list
While Trend line to display
Install each of them with is own attributes
Loop

Martin
Thanks for sharing your project.
Sounds like a lot of fun.
Good luck.

Re: A function for a String to Color value:

Posted: 10 Jul 2012
by SP
Attached is a function for calling 1045 colors as RGB code.

Second option:
Color Palette from http://jamstrategytrading.com/FreeStuff.htm#C with 140 colors.

Re: A function for a String to Color value:

Posted: 19 Jul 2012
by TJ
Too many color choices might be intimidating.

Here's a list of popular colors with their RGB value
Simply make a function with the name: e.g. COLOR.PURPLE, COLOR.ORANGE, etc.

e.g.

Code: Select all

// function: color.purple

color.purple = RGB(69, 0, 68);
Image

1. dark skin= 94, 28, 13
2. light skin= 241, 149, 108
3. blue sky= 97, 119, 171
4. foliage= 90, 103, 39
5. blue flower= 164, 131, 196
6. bluish green =140, 253, 153
7. orange= 255, 116, 21
8. purplish blue= 7, 47, 122
9. moderate red= 222, 29, 42
10. purple= 69, 0, 68
11. yellow green= 187, 255 19
12. orange yellow= 255, 142, 0
13. blue= 0, 0, 142
14. green= 64, 173, 38
15. red= 203, 0, 0
16. yellow= 255, 217, 0
17. magenta= 207, 3, 124
18. cyan= 0, 148, 189
19. white (.05)= 255, 255, 255
20. neutral 8 (.23)= 249, 249, 249
21. neutral 6.5 (.44)= 180, 180, 180
22. neutral 5 (.70)= 117, 117, 117
23. neutral 3.5 (1.05)= 53, 53, 53
24. black (1.50)= 0, 0, 0