Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Programming Racket; How do you overlap a background color with an image. I can g

ID: 3818821 • Letter: P

Question

Programming Racket; How do you overlap a background color with an image. I can get both on my frame but not overlapping. In my code I have

#lang racket/gui

(require racket/draw
net/url)

# I created a basic frame

(define frame (new frame% [label "yolo"]))

#Took an image from the internet by

(define image (read-bitmap (get-pure-port (string->url "some image link"))))

# i create my canvas

(define canvas (new canvas% [parent frame]

[paint-callback

(lambda (canvas yo)

(send canvas set-canvas-background "red"))]))

(void (new message% [parent frame] [label image]))

(send frame show #t)

Is there a way for me to overlap the two images???

Explanation / Answer

When two modules provide functions with the same name, you can rename the functions on import.

A simple way to do this is to rename all the functions from one of the modules, renaming all of them using some common prefix. You can do this with the prefix-in modifier to require:

(require racket/draw)
(require (prefix-in htdp: 2htdp/image))

make-pen; the `make-pen` from racket/draw
htdp:make-pen; the `make-pen` from 2htdp
By the way, there is nothing special about the :, it's just a convention I've seen used. Instead of htdp: the prefix could be (say) htdp-. Whatever you use, it is prepended to every name provided by that module.

If just one function name conflicts, you could rename just that one function from one of the modules, using rename-in.