2D Graphics

InfoInfo
Search:    

next: 3D Graphics top: UI and graphics

Airglow provides basic drawing procedures that help you create simple 2D graphics. The drawing of a widget happens in a special procedure called the drawing-callback. We can dictate how a widget is drawn by overriding this callback. The following code shows how to draw a white, sunken box on a widget:


(import (airglow))

;; The drawing-callback.
(define (draw-cb self p)
  (let ((x (widget-x self))
        (y (widget-y self))
        (w (widget-width self))
        (h (widget-height self)))
    ;; Draw a box with the given style,
    ;; dimension and color.
    (graphics-draw-box 'thin-down
                       x y
                       w h
                       'white)))

(define main-window (window 'x 300 'y 300
                            'w 300 'h 300
                            'title "Box"
                            'type 'double))

;; Add the widget where we render the
;; graphics.
(widget 'w 300 'h 300 'super 'widget 'draw draw-cb)

(group-finish main-window)
(window-show main-window)
(airglow-run)

Note the call to widget. The drawing-callback is passed as the value of the keyword argument - 'draw. This code is a template for drawing things in airglow.

TODO: API Reference. Document airglow/graphics.ss.

This is a Wiki Spot wiki. Wiki Spot is a non-profit organization that helps communities collaborate via wikis.