Skip to content

Is it possible to display bitmap in a loop? #30

Description

@drakbar

I am drawing bitmaps to the output like so

#lang racket

(require racket/draw)  

(define imageWidth 64)
(define imageHeight 64)

(define target (make-bitmap imageWidth imageHeight)) 
(define dc (new bitmap-dc% [bitmap target]))

(define (set-frame dc color)
  (send dc set-pen "black" 2 'solid)
  (send dc set-brush color 'solid)
)

(define (display-frame dc)
  (send dc draw-rectangle 0 0 imageWidth imageHeight)
  target
)

(set-frame dc (make-color 255 255 255))
(display-frame dc)

(set-frame dc (make-color 255 0 0))
(display-frame dc)

(set-frame dc (make-color 0 255 0))
(display-frame dc)

(set-frame dc (make-color 0 0 255))
(display-frame dc)

image

However if I try to loop and send the bitmap to the output like so I don't see anything

#lang racket

(require racket/draw)  

(define imageWidth 64)
(define imageHeight 64)

(define target (make-bitmap imageWidth imageHeight)) 
(define dc (new bitmap-dc% [bitmap target]))

(define (set-frame dc color)
  (send dc set-pen "black" 2 'solid)
  (send dc set-brush color 'solid)
)

(define (display-frame dc)
  (send dc draw-rectangle 0 0 imageWidth imageHeight)
  target
)

(for ([x (in-range 4)])
    (set-frame dc (make-color 255 0 0))
    (display-frame dc)
)

image

I am not sure why its not working, but I am sure I am just making some noobie mistake.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions