Rainbow: Difference between revisions

From Rosetta Code
Content added Content deleted
(Created page with "{{draft task}} ;Task: Print out the word 'RAINBOW' to the screen with every character being a different color of the rainbow. =={{header|Python}}== ===Colored=== <syntaxhighlight lang="python"> from colored import Fore, Style red: str = f'{Fore.rgb(255, 0, 0)}' orange: str = f'{Fore.rgb(255, 128, 0)}' yellow: str = f'{Fore.rgb(255, 255, 0)}' green: str = f'{Fore.rgb(0, 255, 0)}' blue: str = f'{Fore.rgb(0, 0, 255)}' indigo: str = f'{Fore.rgb(75, 0, 130)}' violet: str =...")
 
(Added Wren)
Line 16: Line 16:
print(f'{red}R{Style.reset}' + f'{orange}A{Style.reset}' + f'{yellow}I{Style.reset}' + f'{green}N{Style.reset}' + f'{blue}B{Style.reset}' + f'{indigo}O{Style.reset}' + f'{violet}W{Style.reset}')
print(f'{red}R{Style.reset}' + f'{orange}A{Style.reset}' + f'{yellow}I{Style.reset}' + f'{green}N{Style.reset}' + f'{blue}B{Style.reset}' + f'{indigo}O{Style.reset}' + f'{violet}W{Style.reset}')
</syntaxhighlight>
</syntaxhighlight>

=={{header|Wren}}==
<syntaxhighlight lang="ecmascript">var colors = [
[255, 0, 0], // red
[255, 128, 0], // orange
[255, 255, 0], // yellow
[ 0, 255, 0], // green
[ 0, 0, 255], // blue
[75, 0, 130], // indigo
[128, 0, 255] // violet
]

var s = "RAINBOW"
for (i in 0..6) {
var fore = "\e[38;2;%(colors[i][0]);%(colors[i][1]);%(colors[i][2])m"
System.write("%(fore)%(s[i])")
}
System.print()</syntaxhighlight>

Revision as of 18:57, 16 July 2023

Rainbow is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.
Task
Print out the word 'RAINBOW' to the screen with every character being a different color of the rainbow.

Python

Colored

from colored import Fore, Style
red: str = f'{Fore.rgb(255, 0, 0)}'
orange: str = f'{Fore.rgb(255, 128, 0)}'
yellow: str = f'{Fore.rgb(255, 255, 0)}'
green: str = f'{Fore.rgb(0, 255, 0)}'
blue: str = f'{Fore.rgb(0, 0, 255)}'
indigo: str = f'{Fore.rgb(75, 0, 130)}'
violet: str = f'{Fore.rgb(128, 0, 255)}'
print(f'{red}R{Style.reset}' + f'{orange}A{Style.reset}' + f'{yellow}I{Style.reset}' + f'{green}N{Style.reset}' + f'{blue}B{Style.reset}' + f'{indigo}O{Style.reset}' + f'{violet}W{Style.reset}')

Wren

var colors = [
    [255,   0,   0], // red
    [255, 128,   0], // orange
    [255, 255,   0], // yellow
    [  0, 255,   0], // green
    [  0,   0, 255], // blue
    [75,    0, 130], // indigo
    [128,   0, 255]  // violet
]

var s = "RAINBOW"
for (i in 0..6) {
    var fore = "\e[38;2;%(colors[i][0]);%(colors[i][1]);%(colors[i][2])m"
    System.write("%(fore)%(s[i])")
}
System.print()