sketching icon indicating copy to clipboard operation
sketching copied to clipboard

window resize

Open nodrygo opened this issue 1 year ago • 2 comments

Hello great job but is there a way to calculate parametrically when the size of the canvas changes (window resize) my naive test and probably ugly code from Racket does this

thanks

sorry for my bad translation

nodrygo avatar Mar 29 '23 08:03 nodrygo

Hi @nodrygo

I have added an event handler on-resize that a user can define if he wants to know if the window size changed. The system variables width and height are automatically updated, so it might not be necessary to use on-resize.

Remember to update sketching before trying the program below.

#lang sketching
 
(define (setup)
    (size 400 300))
 
(define (on-resize width height)
    (displayln (list width height)))
 
(define (draw)
    (rect (random width) (random height) 100 100))

soegaard avatar Mar 29 '23 10:03 soegaard

great work fine thank's a lot

nodrygo avatar Mar 29 '23 11:03 nodrygo