[racket-dev] status of the new `racket/gui'

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Mon Aug 2 13:09:40 EDT 2010

The `racket/gui' re-implementation is starting to come into focus.
DrRacket mostly works, although lots and lots of problems remain.

The code is still hosted here:


The GUI libraries do not work well enough that it's time to submit bug
reports, but DrRacket works well enough that you could try to run it as
a preview. If GRacket or DRacket fails to start up due to issues
finding/loading Gtk or related libraries, please let me know.

The drawing part of the toolbox is in good shape, and bug reports on
that part are welcome. Slideshow programs should run well; let me know
if you have an example that renders incorrectly.

See below for a list of changes to the drawing library compared to
v5.0.x, so far. We'll eventually add support for gradients.

Currently supported platforms:

 * Unix variants using Gtk (32 and 64 bits)
 * Windows (32 bits)
 * Mac OS X (32 and 64 bits; use --enable-mac64 to build the latter)


 * The drawing portion of the old GUI toolbox is now available as a
   separate layer: `racket/draw'. This layer can be used from plain
   Racket independent of the `racket/gui' library, although
   `racket/gui' re-exports `racket/draw'.

   The `racket/draw' library is built on top of the widely used Cairo
   drawing library and Pango text-rendering library.

 * A color bitmap can have an alpha channel, instead of just a mask
   bitmap. When drawing a bitmap, alpha channels are used more
   consistently and automatically than mask bitmaps. More
   significantly, drawing into a bitmap with an alpha channel
   preserves the drawn alphas; for example, drawing a line in the
   middle of an empty bitmap produces an image with non-zero alpha
   only at the drawn line.

   Create a bitmap with an alpha channel by supplying #t as the new
   `alpha?' argument to the `bitmap%' constructor, or by loading an
   image with a type like 'unknown/alpha insteda of 'unknown or

   A newly created `bitmap%' has an empty content (i.e., white with
   zero alpha), insteda of unspecified content.

   Images can be read into a `bitmap%' from from input ports, instead
   of requiring a file path.

 * A `dc<%>' supports additional drawing transformations: a rotation
   (via `set-rotation') and a general transformation matrix (via
   `set-initial-matrix'). Scaling factors can be negative, which
   corresponds to flipping the direction of drawing.

   A transformation matrix has the form `(vector xx xy yx yy x0 y0)',
   where a point (x1, y1) is transformed to a point (x2, y2) with x2 =
   xx*x1 + yx*y1 + x0 and y2 = xy*x1 + yy*y1 + y0, which is the usual

   New methods `translate', `scale', `rotate', and `transform'
   simplify adding a further translation, scaling, rotation, or
   arbitrary matrix transformation on top of the current
   transformation. The new `get-translation' and `set-translation'
   methods help to capture and restore transformation settings.

   The old translation and scaling transformations apply after the
   initial matrix. The new rotation transformation applies after the
   other transformations. This layering is redundant, since all
   transformations can be expressed in a single matrix, but it is
   backward-compatibile. Methods like `get-translation',
   `set-translation', `scale', etc. help hide the reundancy.

   The alpha value of a `dc<%>' (as set by `set-alpha') is used for
   all drawing operations, including drawing a bitmap.

   The `draw-bitmap' and `draw-bitmap-section' methods now smooth
   bitmaps while scaling, so the `draw-bitmap-section-smooth' method
   of `bitmap-dc%' simply calls `draw-bitmap-section'.

 * A `region%' can be created as independent of any `dc<%>', in which
   cases it uses the drawing context's current transformation at the
   time that it is installed as a clipping region.

 * The old 'xor mode for pens and brushes is no longer available
   (since it is not supported by Cairo).

Posted on the dev mailing list.