How to resolve the algorithm Colour pinstripe/Display step by step in the Wren programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Colour pinstripe/Display step by step in the Wren 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 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 pinstripe"
__width = 900
__height = 600
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
]
pinstripe(colors)
}
static pinstripe(colors) {
var w = __width
var h = (__height/4).floor
for (b in 1..4) {
var x = 0
var ci = 0
while (x < w) {
var y = h * (b - 1)
Canvas.rectfill(x, y, b, h, colors[ci%8])
x = x + b
ci = ci + 1
}
}
}
static update() {}
static draw(dt) {}
}
You may also check:How to resolve the algorithm Gapful numbers step by step in the Ruby programming language
You may also check:How to resolve the algorithm Casting out nines step by step in the Action! programming language
You may also check:How to resolve the algorithm Memory layout of a data structure step by step in the Wren programming language
You may also check:How to resolve the algorithm Jewels and stones step by step in the Dyalect programming language
You may also check:How to resolve the algorithm Convert seconds to compound duration step by step in the EasyLang programming language