[racket] Setting background color in slideshow

From: Neil Toronto (neil.toronto at gmail.com)
Date: Wed Feb 2 11:39:25 EST 2011

I had some code lying around that'll do you two better: background 
images and sane slide numbers. I think you can pass in any pict to 
`background-image', so if you want a solid color, pass a solid 
rectangle. (Of any size, I think.) For you, I suggest a nice mauve 
instead of black. :D

It uses `current-slide-assembler' as Sam suggested.


#lang racket

(require slideshow)

;; ---------------------------------------------------------------
;; Slides with pict backgrounds and custom/sane slide numbers

(set-page-numbers-visible! #f)

;; Background parameters
(define background-image (make-parameter #f))
(define (background-image-pict)
   (define bg (background-image))
   (inset (scale bg (/ 1024 (pict-width bg)) (/ 768 (pict-height bg)))
          (- margin)))

;; Slide number parameters
(define slide-number (make-parameter 0))
(define (add1-slide-number) (slide-number (add1 (slide-number))))
(define format-slide-number
   (make-parameter
    (lambda (num)
      (scale (rt (number->string (slide-number))) 3/5))))

;; Slide assembly

(define (add-slide bg-pct pct)
   (refocus (ct-superimpose bg-pct pct) bg-pct))

(define (add-slide-number pct)
   (refocus
    (rb-superimpose pct ((format-slide-number) (slide-number)))
    pct))

(current-slide-assembler
  (let ([orig  (current-slide-assembler)])
    (lambda (title sep body)
      (let* ([pct  (if (background-image)
                       (background-image-pict)
                       (inset (blank 1024 768) (- margin)))]
             [pct  (add-slide pct (orig title sep body))]
             [pct  (if (slide-number) (add-slide-number pct) pct)])
        pct))))

;; ---------------------------------------------------------------
;; Demo

(slide-number 1)
;(background-image ...)
(slide
  #:title "Title of the Presentation"
  (item "Bluh bluh"))

(add1-slide-number)
;(background-image ...)
(slide
  #:title "Punchy First Point"
  (item "Bluh bluh"))


Evan Farrer wrote:
> I'm attempting to use slideshow for a presentation and I really want to use white text on a black background. I can see how to change the color of the text, but I don't see how to manipulate the color of the blackground. I'm currently using v5.1.0.2 from git.
> 
> Evan
> _________________________________________________
>   For list-related administrative tasks:
>   http://lists.racket-lang.org/listinfo/users



Posted on the users mailing list.