How to resolve the algorithm Pinstripe/Display step by step in the Raku programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Pinstripe/Display step by step in the Raku programming language
Table of Contents
Problem Statement
The task is to demonstrate the creation of a series of vertical pinstripes across the entire width of the display.
c.f. Colour_pinstripe/Display
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Pinstripe/Display step by step in the Raku programming language
Source code in the raku programming language
my ($x,$y) = 1280,720;
my @colors = 0, 1;
spurt "pinstripes.pgm", qq:to/EOH/ orelse .die;
P5
# pinstripes.pgm
$x $y
1
EOH
my $img = open "pinstripes.pgm", :a, :bin orelse .die;
my $vzones = $y div 4;
for 1..4 -> $w {
my $stripes = ceiling $x / $w / +@colors;
my $line = Buf.new: (flat((@colors Xxx $w) xx $stripes).Array).splice(0,$x); # DH change 2015-12-20
$img.write: $line for ^$vzones;
}
$img.close;
You may also check:How to resolve the algorithm Anagrams step by step in the PowerShell programming language
You may also check:How to resolve the algorithm Evaluate binomial coefficients step by step in the Oberon programming language
You may also check:How to resolve the algorithm Jordan-Pólya numbers step by step in the EasyLang programming language
You may also check:How to resolve the algorithm Munchausen numbers step by step in the ALGOL W programming language
You may also check:How to resolve the algorithm Digital root step by step in the Pascal programming language