racket/draw: background and text colors in `record-dc%'
Also, improve docs to clarify how the recorded settings interact with the target DC's settings.
This commit is contained in:
parent
8ab87a9fcc
commit
00ef7da640
|
@ -347,6 +347,7 @@
|
||||||
(inherit get-origin get-scale get-rotation get-initial-matrix
|
(inherit get-origin get-scale get-rotation get-initial-matrix
|
||||||
get-pen get-brush get-font
|
get-pen get-brush get-font
|
||||||
get-smoothing get-text-mode
|
get-smoothing get-text-mode
|
||||||
|
get-background get-text-background get-text-foreground
|
||||||
get-alpha get-clipping-region
|
get-alpha get-clipping-region
|
||||||
translate rotate scale)
|
translate rotate scale)
|
||||||
|
|
||||||
|
@ -489,6 +490,9 @@
|
||||||
[(s) (get-smoothing)]
|
[(s) (get-smoothing)]
|
||||||
[(f) (get-font)]
|
[(f) (get-font)]
|
||||||
[(tm) (get-text-mode)]
|
[(tm) (get-text-mode)]
|
||||||
|
[(bg) (get-background)]
|
||||||
|
[(tbg) (get-text-background)]
|
||||||
|
[(tfg) (get-text-foreground)]
|
||||||
[(a) (get-alpha)]
|
[(a) (get-alpha)]
|
||||||
[(cr) (get-clipping-region)]
|
[(cr) (get-clipping-region)]
|
||||||
[(to-default?) (applies-to-default?)])
|
[(to-default?) (applies-to-default?)])
|
||||||
|
@ -502,7 +506,19 @@
|
||||||
(unless (and to-default? (eq? s 'unsmoothed)) (set-smoothing s))
|
(unless (and to-default? (eq? s 'unsmoothed)) (set-smoothing s))
|
||||||
(unless (and to-default? (eq? tm 'transparent)) (set-text-mode tm))
|
(unless (and to-default? (eq? tm 'transparent)) (set-text-mode tm))
|
||||||
(unless (and to-default? (= a 1.0)) (set-alpha a))
|
(unless (and to-default? (= a 1.0)) (set-alpha a))
|
||||||
(unless (and to-default? (not cr)) (set-clipping-region cr))))
|
(unless (and to-default? (not cr)) (set-clipping-region cr))
|
||||||
|
(unless (and to-default? (and (= (color-red bg) 255)
|
||||||
|
(= (color-green bg) 255)
|
||||||
|
(= (color-blue bg) 255)))
|
||||||
|
(set-background bg))
|
||||||
|
(unless (and to-default? (and (= (color-red tbg) 255)
|
||||||
|
(= (color-green tbg) 255)
|
||||||
|
(= (color-blue tbg) 255)))
|
||||||
|
(set-text-background tbg))
|
||||||
|
(unless (and to-default? (and (= (color-red tfg) 0)
|
||||||
|
(= (color-green tfg) 0)
|
||||||
|
(= (color-blue tfg) 0)))
|
||||||
|
(set-text-foreground tfg))))
|
||||||
|
|
||||||
(define/public (applies-to-default?) #t)
|
(define/public (applies-to-default?) #t)
|
||||||
|
|
||||||
|
@ -725,6 +741,9 @@
|
||||||
(define s (send dc get-smoothing))
|
(define s (send dc get-smoothing))
|
||||||
(define f (send dc get-font))
|
(define f (send dc get-font))
|
||||||
(define tm (send dc get-text-mode))
|
(define tm (send dc get-text-mode))
|
||||||
|
(define bg (send dc get-background))
|
||||||
|
(define tbg (send dc get-text-background))
|
||||||
|
(define tfg (send dc get-text-foreground))
|
||||||
(define a (send dc get-alpha))
|
(define a (send dc get-alpha))
|
||||||
(define cr (send dc get-clipping-region))
|
(define cr (send dc get-clipping-region))
|
||||||
|
|
||||||
|
@ -742,5 +761,8 @@
|
||||||
(send dc set-font f)
|
(send dc set-font f)
|
||||||
(send dc set-smoothing s)
|
(send dc set-smoothing s)
|
||||||
(send dc set-text-mode tm)
|
(send dc set-text-mode tm)
|
||||||
|
(send dc set-background bg)
|
||||||
|
(send dc set-text-background tbg)
|
||||||
|
(send dc set-text-foreground tfg)
|
||||||
(send dc set-alpha a)
|
(send dc set-alpha a)
|
||||||
(send dc set-clipping-region cr)))
|
(send dc set-clipping-region cr)))
|
||||||
|
|
|
@ -10,6 +10,18 @@ A @racket[record-dc%] object records drawing actions for replay into
|
||||||
(that can be printed with @racket[write] and recreated with
|
(that can be printed with @racket[write] and recreated with
|
||||||
@racket[read]) via @method[record-dc% get-recorded-datum].
|
@racket[read]) via @method[record-dc% get-recorded-datum].
|
||||||
|
|
||||||
|
When drawing recorded actions, the target drawing context's pen,
|
||||||
|
brush, font, text, background, text background, and text foreground do
|
||||||
|
not affect the recorded actions. The target drawing context's
|
||||||
|
transformation, alpha, and clipping region compose with settings in
|
||||||
|
the recorded actions (so that, for example, a recorded action to set
|
||||||
|
the clipping region actually intersects the region with the drawing
|
||||||
|
context's clipping region at the time that the recorded commands are
|
||||||
|
replayed). After recoded commands are replayed, all settings in the
|
||||||
|
target drawing context, such as its clipping region or current font,
|
||||||
|
are as before the replay.
|
||||||
|
|
||||||
|
|
||||||
@defconstructor[([width (>=/c 0) 640]
|
@defconstructor[([width (>=/c 0) 640]
|
||||||
[height (>=/c 0) 480])]{
|
[height (>=/c 0) 480])]{
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user