How to give a frame as argument to DrRacket when I paint a image by using a painter? (SICP 2nd Edition)

Viewed 47

I am reading SICP 2nd Edition.

A painter is represented as a procedure that, given a frame as argument, draws a particular image shifted and scaled to fit the frame.

I am using DrRacket (SICP Picture Language).

How to give a frame as argument to DrRacket when I paint a image by using a painter?

1 Answers

Here is an example

#lang racket
(require sicp-pict)
(paint einstein)

(paint
 (λ (f)
   (einstein (frame (vect 0. 0.) (vect 1. 0.) (vect 0. 1.)))))

(paint
 (λ (f)
   (einstein (frame (vect 0.5 0.5) (vect 0.5 0.) (vect 0. 0.25)))))

If you want all the gory details of the actual representation used:

https://github.com/sicp-lang/sicp/blob/master/sicp-pict/main.rkt

Related