#lang racket/gui ;;; api5.rkt -Utilisation d'un thread - pas de double buffer (page 334) ;;; Chapitre 14 (Objets et API graphique) ;;; Livre PCPS : "Premiers Cours de Programmation avec Scheme" ;;; Langage determine par le source (define FRAME (new frame% (label "thread") (stretchable-width #f) (stretchable-height #f))) (define BLACK-BRUSH (make-object brush% "black" 'solid)) (define cpt 0) (define CANVAS (new canvas% (parent FRAME) (min-width 400) (min-height 100) (paint-callback (lambda (obj evt) (let ((dc (send obj get-dc))) (thread (lambda () (send dc set-brush BLACK-BRUSH) (do ((x 0 (+ x 1))) ((= x 800) (void)) (send dc clear) (send dc draw-ellipse (modulo x 400) 0 100 100) (sleep 0.01)))) (printf "Pas de double-buffer.\n") (printf "Vous observerez peut-etre un leger scintillement ?...\n")))))) (send FRAME show #t)