Dark & Light Theme [TradingFinder] Switching Colors Library🔵 Introduction
One of the challenges of script users is matching the colors used in indicators or strategies. By default, colors are chosen to display based on either the dark theme or the light theme.
In scripts with a large number of colors used, changing all colors to better display in dark mode or light mode can be a difficult and tedious process.
This library provides developers with the ability to adjust the colors used in their scripts based on the theme of the display.
🔵 Logic
To categorize the color spectrum, the range from 0 to 255 of all three main colors red, green and blue was divided into smaller ranges.
Blue color, which is more effective in darkening or lightening colors, is divided into 8 categories, red color into 5 categories, and green color into 3 categories, because it has little effect on darkening or brightening colors.
The combination of these categories creates 120 different modes for the color range, which leads to a more accurate identification of the color and its brightness, and helps to decide how to change it.
Except for these 120 modes, there are 2 other modes that are related to colors almost white or black, which makes a total of 122 modes.
🔵 How to Use
First, you can add the library to your code as shown in the example below.
import TFlab/Dark_Light_Theme_TradingFinder_Switching_Colors_Library/1 as SC
🟣 Parameters
SwitchingColorMode(Color, Mode) =>
Parameters:
Color (color)
Mode (string)
Color : In this parameter, enter the color you want to adjust based on light mode and dark mode.
Mode : Three modes "Off", "Light" and "Dark" are included in this parameter. "Light" mode is for color adjustment for use in "Light Mode".
"Dark" mode is for color adjustment for use in "Dark Mode" and "Off" mode turns off the color adjustment function and the input color to the function is the same as the output color.
🔵 Function Outputs
OriginalColor = input.color(color.red)
= SC.SwitchingColorMode(OriginalColor, Mode)
Themes
base16Library "base16"
Base16 Syntax Theme Collection. dark/light Pairs placed into 2 matched groups.
included is tool for assembling your own themes, as well as all themes String names
to create your own Input menus / add to your own theme matrix, and theme selectors
addToMatrix(_mtx, _title, _choices, _theme)
To create a theme matrix with string index, use a color matrix global
add theme name to string array of theme titles
and last input a theme from above, or create your own theme arrays.
Parameters:
_mtx : (color ) matrix for storage
_title : (string ) Name of theme being added
_choices : (string ) name index
_theme : (color ) colors being added
Returns: void
addToMatrix(_mtx, _theme)
Add theme to color matrix Non-indexed
Parameters:
_mtx : (color ) matrix for storage
_theme : (color ) colors being added
dark()
Dark Themne Selection (With light Equivalent in same location)
Returns: Color matrix of dark themes
light()
light Themne Selection (With dark Equivalent in same location)
Returns: Color matrix of light themes
selectTheme(_mtx, _themes, _theme)
Get a Theme By Name
Parameters:
_mtx : (Matrix color) Name of Theme
_themes : (Array string) Array with Names of Themes
_theme : (string ) Name of Theme to select
selectTheme(_mtx, _theme)
Get a Theme By Number
Parameters:
_mtx : (Matrix color) Name of Theme
_theme : (int ) Number of Theme to select
/// all themes included:
3024
apathy
apprentice
ashes
atelier_cave_light
atelier_cave
atelier_dune_light
atelier_dune
atelier_estuary_light
atelier_estuary
atelier_forest_light
atelier_forest
atelier_heath_light
atelier_heath
atelier_lakeside_light
atelier_lakeside
atelier_plateau_light
atelier_plateau
atelier_savanna_light
atelier_savanna
atelier_seaside_light
atelier_seaside
atelier_sulphurpool_light
atelier_sulphurpool
atlas
ayu_dark
ayu_light
ayu_mirage
bespin
black_metal_bathory
black_metal_burzum
black_metal_dark_funeral
black_metal_gorgoroth
black_metal_immortal
black_metal_khold
black_metal_marduk
black_metal_mayhem
black_metal_nile
black_metal_venom
black_metal
blue_forest
blueish
brewer
bright
brogrammer
brush_trees_dark
brush_trees
catppuccin
chalk
circus
classic_dark
classic_light
codeschool
clrs
cupcake
cupertino
da_one_black
da_one_gray
da_one_ocean
da_one_paper
da_one_sea
da_one_white
danqing_light
danqing
darcula
darkmoss
darktooth
dark_violet
decaf
default_dark
default_light
dirtysea
dracula
edge_dark
edge_light
eighties
embers
emil
equilibrium_dark
equilibrium_gray_dark
equilibrium_gray_light
equilibrium_light
espresso
eva_dim
eva
everforest
flat
framer
fruit_soda
gigavolt
github
google_dark
google_light
gotham
grayscale_dark
grayscale_light
green_screen
gruber
gruvbox_dark_hard
gruvbox_dark_medium
gruvbox_dark_pale
gruvbox_dark_soft
gruvbox_light_hard
gruvbox_light_medium
gruvbox_light_soft
gruvbox_material_dark_hard
gruvbox_material_dark_medium
gruvbox_material_dark_soft
gruvbox_material_light_hard
gruvbox_material_light_medium
gruvbox_material_light_soft
hardcore
harmonic16_dark
harmonic16_light
heetch_light
heetch_dark
helios
hopscotch
horizon_dark
horizon_light
horizon_terminal_dark
horizon_terminal_light
humanoid_dark
humanoid_light
ia_dark
ia_light
icy_dark
ir_black
isotope
kanagawa
katy
kimber
lime
macintosh
marrakesh
materia
material_darker
material_lighter
material_palenight
material_vivid
material
mellow_purple
mexico_light
mocha
monokai
Nebula
nord
nova
ocean
oceanicnext
one_light
onedark
outrun_dark
pandora
papercolor_dark
papercolor_light
paraiso
pasque
phd
pico
pinky
pop
porple
primer_dark_dimmed
primer_dark
primer_light
purpledream
qualia
railscasts
rebecca
rose_pine_dawn
rose_pine_moon
rose_pine
sagelight
sakura
sandcastle
seti_ui
shades_of_purple
shadesmear_dark
shadesmear_light
shapeshifter
silk_dark
silk_light
snazzy
solar_flare_light
solar_flare
solarized_dark
solarized_light
spaceduck
spacemacs
stella
still_alive
summercamp
summerfruit_dark
summerfruit_light
synth_midnight_terminal_dark
synth_midnight_terminal_light
tango
tender
tokyo_city_dark
tokyo_city_light
tokyo_city_terminal_dark
tokyo_city_terminal_light
tokyo_night_dark
tokyo_night_light
tokyo_night_storm
tokyo_night_terminal_dark
tokyo_night_terminal_light
tokyo_night_terminal_storm
tokyodark_terminal
tokyodark
tomorrow_night_eighties
tomorrow_night
tomorrow
london_tube
twilight
unikitty_dark
unikitty_light
unikitty_reversible
uwunicorn
vice
vulcan
windows_10_light
windows_10
windows_95_light
windows_95
windows_high_contrast_light
windows_high_contrast
windows_nt_light
windows_nt
woodland
xcode_dusk
zenburn