How to resolve the algorithm Colour bars/Display step by step in the Racket programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Colour bars/Display step by step in the Racket 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 Racket programming language
Source code in the racket programming language
#lang racket/gui
(define-values [W H] (get-display-size #t))
(define colors
'("Black" "Red" "Green" "Blue" "Magenta" "Cyan" "Yellow" "White"))
(define (paint-pinstripe canvas dc)
(send dc set-pen "black" 0 'transparent)
(for ([x (in-range 0 W (/ W (length colors)))] [c colors])
(send* dc (set-brush c 'solid) (draw-rectangle x 0 W H))))
(define full-frame%
(class frame%
(define/override (on-subwindow-char r e)
(when (eq? 'escape (send e get-key-code))
(send this show #f)))
(super-new
[label "Color bars"] [width W] [height H]
[style '(no-caption no-resize-border hide-menu-bar no-system-menu)])
(define c (new canvas% [parent this] [paint-callback paint-pinstripe]))
(send this show #t)))
(void (new full-frame%))
You may also check:How to resolve the algorithm Stack step by step in the PicoLisp programming language
You may also check:How to resolve the algorithm Recaman's sequence step by step in the FOCAL programming language
You may also check:How to resolve the algorithm Bulls and cows step by step in the Liberty BASIC programming language
You may also check:How to resolve the algorithm Rename a file step by step in the UNIX Shell programming language
You may also check:How to resolve the algorithm Ulam spiral (for primes) step by step in the Kotlin programming language