Greyscale bars/Display: Difference between revisions

Content added Content deleted
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
Line 7: Line 7:


Halfway down the display, we start with black, and produce 32 bars, ending in white, and for the last quarter, we start with white and step through 62 shades of grey, before finally arriving at black in the bottom right hand corner, producing a total of 64 bars for the bottom quarter.
Halfway down the display, we start with black, and produce 32 bars, ending in white, and for the last quarter, we start with white and step through 62 shades of grey, before finally arriving at black in the bottom right hand corner, producing a total of 64 bars for the bottom quarter.

=={{header|ActionScript}}==
=={{header|ActionScript}}==
<lang ActionScript>package
<lang ActionScript>package
Line 124: Line 125:
end Greyscale;
end Greyscale;
</lang>
</lang>

=={{header|ANSI Standard BASIC}}==
=={{header|ANSI Standard BASIC}}==


Line 245: Line 247:
next row
next row
</lang>
</lang>



=={{header|BBC BASIC}}==
=={{header|BBC BASIC}}==
Line 405: Line 406:
}</lang>
}</lang>


=={{Header|Component Pascal}}==
=={{header|Component Pascal}}==
{{works with|Black Box Component Builder}}
{{works with|Black Box Component Builder}}


Line 488: Line 489:
"RosettaGreys.Deposit; StdCmds.Open"
"RosettaGreys.Deposit; StdCmds.Open"
</lang>
</lang>

=={{header|EasyLang}}==
=={{header|EasyLang}}==


Line 532: Line 534:
>grayscales:
>grayscales:
</lang>
</lang>

=={{header|FreeBASIC}}==
=={{header|FreeBASIC}}==
<lang freebasic>' version 01-09-2017
<lang freebasic>' version 01-09-2017
Line 874: Line 877:
</body></html>
</body></html>
</lang>
</lang>



=={{header|Julia}}==
=={{header|Julia}}==
Line 1,176: Line 1,178:
bars($h4,$w,6,1);</lang>
bars($h4,$w,6,1);</lang>
[https://github.com/SqrtNegInf/Rosettacode-Perl5-Smoke/blob/master/ref/Greyscale-bars-perl5.png See Greyscale-bars-perl5] (offsite image)
[https://github.com/SqrtNegInf/Rosettacode-Perl5-Smoke/blob/master/ref/Greyscale-bars-perl5.png See Greyscale-bars-perl5] (offsite image)

=={{header|Perl 6}}==
<lang perl6>my ($width,$height) = 1280,768;
my $PGM = open "Greyscale-bars-perl6.pgm", :w orelse die "Can't create Greyscale-bars-perl6.pgm: $_";
$PGM.print: qq:to/EOH/;
P2
# Greyscale-bars-perl6.pgm
$width $height
65535
EOH
my ($h1,$h2,$h3,$h4) = divvy($height,4);
my @nums = ((0/7,1/7...7/7) X* 65535)».floor;
my $line = ~(@nums Zxx divvy($width,8));
$PGM.say: $line for ^$h1;
@nums = ((15/15,14/15...0/15) X* 65535)».floor;
$line = ~(@nums Zxx divvy($width,16));
$PGM.say: $line for ^$h2;
@nums = ((0/31,1/31...31/31) X* 65535)».floor;
$line = ~(@nums Zxx divvy($width,32));
$PGM.say: $line for ^$h3;
@nums = ((63/63,62/63...0/63) X* 65535)».floor;
$line = ~(@nums Zxx divvy($width,64));
$PGM.say: $line for ^$h4;
$PGM.close;
sub divvy($all, $div) {
my @marks = ((1/$div,2/$div ... 1) X* $all)».round;
@marks Z- 0,|@marks;
}</lang>
[https://github.com/SqrtNegInf/Rosettacode-Perl6-Smoke/blob/master/ref/Greyscale-bars-perl6.png See Greyscale-bars-perl6] (offsite image)


=={{header|Phix}}==
=={{header|Phix}}==
Line 1,435: Line 1,399:
(grays 1/32 'right) (grays 1/64 'left))
(grays 1/32 'right) (grays 1/64 'left))
</lang>
</lang>

=={{header|Raku}}==
(formerly Perl 6)
<lang perl6>my ($width,$height) = 1280,768;
my $PGM = open "Greyscale-bars-perl6.pgm", :w orelse die "Can't create Greyscale-bars-perl6.pgm: $_";
$PGM.print: qq:to/EOH/;
P2
# Greyscale-bars-perl6.pgm
$width $height
65535
EOH
my ($h1,$h2,$h3,$h4) = divvy($height,4);
my @nums = ((0/7,1/7...7/7) X* 65535)».floor;
my $line = ~(@nums Zxx divvy($width,8));
$PGM.say: $line for ^$h1;
@nums = ((15/15,14/15...0/15) X* 65535)».floor;
$line = ~(@nums Zxx divvy($width,16));
$PGM.say: $line for ^$h2;
@nums = ((0/31,1/31...31/31) X* 65535)».floor;
$line = ~(@nums Zxx divvy($width,32));
$PGM.say: $line for ^$h3;
@nums = ((63/63,62/63...0/63) X* 65535)».floor;
$line = ~(@nums Zxx divvy($width,64));
$PGM.say: $line for ^$h4;
$PGM.close;
sub divvy($all, $div) {
my @marks = ((1/$div,2/$div ... 1) X* $all)».round;
@marks Z- 0,|@marks;
}</lang>
[https://github.com/SqrtNegInf/Rosettacode-Perl6-Smoke/blob/master/ref/Greyscale-bars-perl6.png See Greyscale-bars-perl6] (offsite image)


=={{header|RapidQ}}==
=={{header|RapidQ}}==