Skip to content

Instantly share code, notes, and snippets.

@samdphillips
Last active August 29, 2015 14:05
Show Gist options
  • Save samdphillips/560b8fb1d293d6a91a67 to your computer and use it in GitHub Desktop.
Save samdphillips/560b8fb1d293d6a91a67 to your computer and use it in GitHub Desktop.
Bitmap doesn't draw correctly at scales larger than 1. (At least not on Racket 6.1 on OSX 10.9.4)
#lang racket/base
(require racket/class
(only-in racket/draw
make-bitmap)
(only-in racket/gui
canvas%
frame%)
(only-in racket/math
exact-ceiling)
)
(define SIZE 200)
(define test-canvas%
(class canvas%
(init-field [scale 1])
(inherit get-dc)
(define bm
(let ([bm (make-bitmap SIZE SIZE)])
(send* (send bm make-dc)
[draw-line SIZE 0 0 SIZE])
bm))
(define/override (on-paint)
(send* (get-dc)
(scale scale scale)
(draw-bitmap bm 0 0)))
(super-new [min-width (exact-ceiling (* scale SIZE))]
[min-height (exact-ceiling (* scale SIZE))])))
(define (run [s 1])
(define w (new frame% [label "test"]))
(define c (new test-canvas% [parent w] [scale s]))
(send w show #t))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment