Reputation: 29
I have a variable that controls the number of blue in (color R, G, B). Now I am confused about how to use that variable in (color R, G, B). Also, I am totally new to Racket. I know I can combine these functions together, but I don't know how :( The purpose of this code is to make a color changing scene in animate. Here is my code:
(require 2htdp/image)
(define(Skycolor num) (remainder num 510))
(define(skycolor num) (abs(- 255(Skycolor num))))
(define(sky-color num) (color 0 0 (skycolor num)))
(define (SKY num ) (square 200 "solid" (color 0 0 (sky-color num)))))
Upvotes: 0
Views: 165
Reputation: 7568
It's not very clear what do you mean with "color changing", but you can take some inspiration from following code. See also this similar question, where I explain how animate
works.
#lang racket
(require 2htdp/universe)
(require 2htdp/image)
(define speed 5)
(define (sky-color ticks)
(color 0 (modulo (* speed (- 255 ticks)) 255) 255))
(define bg
(empty-scene 125 125))
(define (make-sky ticks)
(square 250 "solid" (sky-color ticks)))
(define (draw-image ticks)
(place-image (make-sky ticks) 0 0 bg))
(animate draw-image)
Upvotes: 0