put-image

74 views
Skip to first unread message

patric...@gmail.com

unread,
Feb 6, 2021, 6:24:15 PM2/6/21
to Racket Users

What do I need to do to be able to use the "put-image" method from WeScheme? I am starting off my program with:

#lang htdp/bsl

(require 2htdp/image)

Is there another package I need to use?

Sorawee Porncharoenwase

unread,
Feb 6, 2021, 7:32:09 PM2/6/21
to patric...@gmail.com, Racket Users

As explained in documentation of WeScheme, put-image is only available in WeScheme. Racket and its libraries don’t have this function.

It’s easy to implement it yourself, however, by using place-image and image-height. Both are available in 2htdp/image


--
You received this message because you are subscribed to the Google Groups "Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to racket-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/c8788557-0fe6-46a2-be1a-1dbb432ab939n%40googlegroups.com.

Robby Findler

unread,
Feb 6, 2021, 10:41:42 PM2/6/21
to Sorawee Porncharoenwase, patric...@gmail.com, Racket Users
Any objection to adding it to 2htdp/image?

Robby

Stephen De Gabrielle

unread,
Feb 7, 2021, 6:32:48 AM2/7/21
to Robby Findler, Racket Users, Sorawee Porncharoenwase, patric...@gmail.com

Robby Findler

unread,
Feb 7, 2021, 4:51:27 PM2/7/21
to Stephen De Gabrielle, Racket Users, Sorawee Porncharoenwase, patric...@gmail.com
Okay, I've added it. It is pretty straightforward to define it in your own code in the meantime, Patrick:

(define (put-image i1 x y i2)
  (place-image i1 x (- (image-height i2) y) i2))

Robby


patric...@gmail.com

unread,
Feb 16, 2021, 3:53:12 PM2/16/21
to Racket Users
I was able to use the Bootstrap teachpack. I am running my program from the command line and racket returns #<image>. Is there a way to view the output outside of Dr. Racket?

Shu-Hung You

unread,
Feb 17, 2021, 11:33:02 PM2/17/21
to patric...@gmail.com, Racket Users
One option is using save-image from 2htdp/image to save the images as
PNG files and open them using external programs.
https://docs.racket-lang.org/teachpack/2htdpimage.html#%28def._%28%28lib._2htdp%2Fimage..rkt%29._save-image%29%29

If you can use a different language (say racket), another option is
using show-pict from pict:

;; needs the 'require' form from racket (or racket/base)
(require racket/gui/base (only-in pict show-pict))
(show-pict
(put-image
(circle 50 "solid" "green")
50
50
(square 100 "solid" "blue")))

Since many functions in pict have the same names as those provided by
2htdp/image, you need only-in to require only the show-pict function.
> To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/e80e29fd-cc01-40c8-8a4d-6ffaeac7cd85n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages