racket / racket/draw

Is it possible to display bitmap in a loop?

Open
#30 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Racket
Stars
19
Forks
24
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the two Racket examples from the issue using racket/draw, comparing the top-level bitmap expressions with the for loop. Determine whether the loop's bitmap output is expected to be displayed and identify what behavior should be documented or corrected; done means the loop behavior is explained and the reported example works or has a clear resolution.

Written by the indexing model from the issue text.

Assessment

Domain
computer-graphics
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.