How to resolve the algorithm Colour pinstripe/Display step by step in the Quackery programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Colour pinstripe/Display step by step in the Quackery programming language

Table of Contents

Problem Statement

The task is to create 1 pixel wide coloured vertical pinstripes with a sufficient number of pinstripes to span the entire width of the graphics display.

The pinstripes should either follow the system palette sequence,   or a sequence that includes: black,   red,   green,   blue,   magenta,   cyan,   yellow,   and   white:

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Colour pinstripe/Display step by step in the Quackery programming language

Source code in the quackery programming language

  [ $ "turtleduck.qky" loadfile ] now!

  [ 1280 ]                 is width      (   --> n     )
  [ 720 ]                  is height     (   --> n     )

  [   0   0   0 ]          is black      (   --> n n n )
  [ 255   0   0 ]          is red        (   --> n n n )
  [   0 255   0 ]          is green      (   --> n n n )
  [   0   0 255 ]          is blue       (   --> n n n )
  [ 255   0 255 ]          is magenta    (   --> n n n )
  [   0 255 255 ]          is cyan       (   --> n n n )
  [ 255 255   0 ]          is yellow     (   --> n n n )
  [ 255 255 255 ]          is white      (   --> n n n )

  [ [] swap
    ' [ black   red
        green   blue
        magenta cyan
        yellow  white ]
    witheach
      [ over times
        [ dip swap tuck
          nested join
          unrot ]
        drop ]
     drop ]                is colours    ( n --> [     )

  [ behead
    dup dip
      [ nested join ] ]    is nextcolour ( [ --> [ [   )

  [ nextcolour colour
     -1 4 turn
    height n->v
    4 n->v v/ 2dup walk
    -v fly
    1 4 turn
    1 n->v fly ]           is stripe     ( [ --> [     )

  [ turtle
    50 frames
    width n->v 2 1 v/ fly
    -1 4 turn
    height n->v 2 1 v/ fly
    -1 4 turn
    4 times 
    [ i^ 1+ colours
      width times stripe
      drop
      width n->v -v fly
      -1 4 turn
      height n->v
      4 n->v v/ fly
      1 4 turn ]
     1 frames ]            is pinstripes (   -->       )

  

You may also check:How to resolve the algorithm Substitution cipher step by step in the Perl programming language
You may also check:How to resolve the algorithm Pascal's triangle step by step in the BQN programming language
You may also check:How to resolve the algorithm Operator precedence step by step in the Erlang programming language
You may also check:How to resolve the algorithm Flow-control structures step by step in the 11l programming language
You may also check:How to resolve the algorithm Integer sequence step by step in the Lua programming language