How to resolve the algorithm Colour bars/Display step by step in the Wren programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Colour bars/Display step by step in the Wren programming language

Table of Contents

Problem Statement

Display a series of vertical color bars across the width of the display. The color bars should either use:

Let's start with the solution:

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

Source code in the wren programming language

import "graphics" for Canvas, Color
import "dome" for Window

class Game {
    static init() {
        Window.title = "Color bars"
        __width = 400
        __height = 400
        Canvas.resize(__width, __height)
        Window.resize(__width, __height)
        var colors = [
            Color.hex("000000"), // black
            Color.hex("FF0000"), // red
            Color.hex("00FF00"), // green
            Color.hex("0000FF"), // blue
            Color.hex("FF00FF"), // magenta
            Color.hex("00FFFF"), // cyan
            Color.hex("FFFF00"), // yellow
            Color.hex("FFFFFF")  // white
        ]
        drawBars(colors)
    }

    static drawBars(colors) {
        var w = __width / colors.count
        var h = __height
        for (i in 0...colors.count) {
            Canvas.rectfill(w*i, 0, w, h, colors[i])
        }
    }

    static update() {}

    static draw(dt) {}
}


  

You may also check:How to resolve the algorithm Transliterate English text using the Greek alphabet step by step in the Raku programming language
You may also check:How to resolve the algorithm Greatest common divisor step by step in the Ada programming language
You may also check:How to resolve the algorithm Hello world/Text step by step in the Oxygene programming language
You may also check:How to resolve the algorithm Soundex step by step in the Scala programming language
You may also check:How to resolve the algorithm De Bruijn sequences step by step in the Haskell programming language