I don't think, you'll see much higher fps without doing less work in on-paint
.
This might give you a small gain though:
(define black-pen (new pen% [color "black"] [width 1] [style 'solid]))
(define white-pen (new pen% [color "white"] [width 1] [style 'solid]))
(define black-brush (new brush% [color "black"] [style 'solid]))
(define white-brush (new brush% [color "white"] [style 'solid]))
(define dc (get-dc))
(define/override (on-paint)
(set! *counted-frames* (+ 1 *counted-frames*))
(for* ([x (in-range *width*)] [y (in-range *height*)])
(if (get-element x y)
(begin
(send dc set-pen black-pen)
(send dc set-brush black-brush))
(begin
(send dc set-pen white-pen)
(send dc set-brush white-brush)))
(send dc draw-rectangle (* x 10) (* y 10) 10 10)))
If your game is a retro game with 10x10 "pixels", then you can get a speedup
by having a bitmap with a low resolution, say, 100x80 and then
in on-paint
finish by drawing a scaled copy to the bitmap to the screen.
This technique is used in here:
https://github.com/soegaard/sketching/blob/main/sketching-examples/examples/pacman/maze-game.rkt
[It's not 60 fps though.]
If that's not fast enough, you'll need to look at how to use the GPU - either
directly or using one of the available libraries.