Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

view: fix scaling of image #50

Merged
merged 2 commits into from
Feb 16, 2024
Merged

view: fix scaling of image #50

merged 2 commits into from
Feb 16, 2024

Conversation

xioi
Copy link
Contributor

@xioi xioi commented Feb 15, 2024

The image's #:size property doesn't work well with something like '(#f 300), it tries to treat both of them as integers when they are not both #f and that's the point.
The problem happens in its internal scale function and I made it to scale either w or h following it original scale when one of them is #f so it can properly fit the frame.
BTW I don't know if it is fine for 'fill mode...maybe it deserves further consideration.

The problem can be tested with this piece of code.

#lang racket/base

;;; (require "gui-easy-lib/gui/easy.rkt")
(require racket/gui/easy)

(define @height (obs 300))

(render
 (window
  (vpanel
   (slider
    300
    (λ (v) (obs-set! @height v))
    #:min-value 100
    #:max-value 800)
   (image
    #:size (obs-map @height (λ (h) (list #f h)))
    "path/to/photo.jpg")))) ;;; Whatever, a non-square-like photo

@Bogdanp Bogdanp merged commit 6749695 into Bogdanp:master Feb 16, 2024
1 check passed
@Bogdanp
Copy link
Owner

Bogdanp commented Feb 16, 2024

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants