Scribble-compatible image drawing libraries

I'd like to create images similar to the ones on this page (not the one on the top though :wink: ) and include them in a Scribble document. So these images would consist mostly of text, boxes, lines and arrows.

The Scribble documentation (section "Pictures") mentions two possibilites to directly include images generated by Racket code: Pict and 2htdp/image.

I have no experience with Pict and only very little with 2htdp/image. Since both libraries seem to take some time to learn and use, I would like to settle on one library before diving into it. From looking at the documentation of the two libraries, my impression is that the Pict library would be better for my use case. What do you think?

Are there any other "Scribble-compatible" libraries for drawing simple images (as described above) that you would recommend?

For HtDP, I started with mostlt 2htdp/images and some picts for diagrams. As it came time to publish, I went all pict. So there’s some experience.

Let’s compare:


  • smooth learning curve
  • pretty powerful for a teachpack
  • a “CS1” teacher (middle, high, freshman) can use the code for write-ups and for demos


  • somewhat steeper learning curve
  • somewhat different “work"; think (rectangle 100 200 “solid” “green”) vs (rectangle 100 100 #:border-color "green" #:border-width 100) vs (filled-rectangle 100 100 #:color “green”) — the second is NOT what you really want
  • supports racket code (for slideshows for example)
  • more power (drop down and draw into the dc if you want more than pict offers)
  • sharp pictures, ready for commercial printing; relative easy to turn off colors for pict code
    [[ This might have been my lack of understanding all the knobs and dials in 2htdp/image, which is Robby and Ian's even if I added a few lines of code here and there. ]]
  • easily usable for PDF and HTML output (though you should go through SVG and scale differently)

If this doesn’t help you make a decision, ask.

p.s. I initially wrote a little module in pict so I could port 2htdp/image easily to pict. Not worth the effort.

1 Like

FWIW, there are some constructs of each that are intercompatible. For example, in a current project I am using 2htdp/image's wedge and triangle along with constructs from pict, pict/flash, and pict/color.

1 Like

On the general point, pict is more full-featured and aimed at general use cases, whereas 2htdp/image is aimed at teaching and beginning programmers but has more shapes built-in.

On your specific goal, I think this library is what you want: Sdraw: Cons-Cell Diagrams with Pict


Depending on the type of figure you need, MetaPict is an option too.
MetaPict produces picts, so you can use them just as images produces by pict.

Box and pointers

Docs: MetaPict

Video: Jens Axel Søgaard — MetaPict - YouTube


Thanks for your answers, everyone! :slight_smile:

@EmEf @samth From what you write, I'd rule out 2htdp/image for now.

@benknoble Interesting to know they can be mixed. @EmEf wrote that the picture quality of pict is better. I wonder what that means for 2htdp/image "subimages" in pict images.

It's quite impressive. At the moment I think I won't use it though because

  • I want to draw also pictures of vectors and maybe hashes (although I'm not sure if the latter makes any sense :wink: ), but I could use (for example) pict for that as long as I can reproduce the line widths and arrows that sdraw uses.
  • Since the car values are pointed to outside the cons cell boxes, the images look rather "noisy" (for lack of a better word). I see the point for this (in case the car values don't fit in the box), but I expect to use only things like short numbers or symbols. I'm also open to making the boxes a bit larger if needed.

@soegaard metapict looks quite interesting (also, but by far not only, because of the box and pointers example). So it's now deciding between metapict and pict. I'll read the packages' documentation more thoroughly now and make some experiments to decide.

That said, if someone has more library suggestions, I'm curious. And even if I don't use them for now, it may be interesting for others who search the forum later.

Edit: In the end, I went with pict, but during that, I several times thought of just using LibreOffice Draw. :wink: