-
-
Notifications
You must be signed in to change notification settings - Fork 97
add 3 units of padding around printed picts #704
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
Conversation
|
It would make sense to make the amount of padding configurable in DrRacket. I didn't implement that here, because I think it would rarely get changed. The amount of space for a pict's bitmap conversion is controlled by a parameter, but I have never considered changing it in any application. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resyntax analyzed 1 file in this pull request and has added suggestions.
| (draw-pict pict rdc | ||
| (if (< w 0) aw 0) | ||
| (if (< h 0) ah 0)) | ||
| (+ (if (< w 0) aw 0) pad) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
zero-comparison-to-negative?: This expression is equivalent to calling the negative? predicate.
| (+ (if (< w 0) aw 0) pad) | |
| (+ (if (negative? w) aw 0) pad) |
Debugging details
Textual replacement
(line-replacement
#:new-lines '#(" (+ (if (negative? w) aw 0) pad)")
#:original-lines '#(" (+ (if (< w 0) aw 0) pad)")
#:start-line 421)Syntactic replacement
(syntax-replacement
#:introduction-scope #<procedure:do-make-syntax-introducer>
#:new-syntax
#<syntax:/home/runner/.local/share/racket/8.15.0.11/pkgs/resyntax/default-recommendations/numeric-shortcuts.rkt:66:2 (negative? w)>
#:original-syntax
#<syntax:drracket/drracket/private/language.rkt:421:24 (< w 0)>
#:source
(file-source
#<path:/home/runner/work/drracket/drracket/drracket/drracket/private/language.rkt>))| (if (< w 0) aw 0) | ||
| (if (< h 0) ah 0)) | ||
| (+ (if (< w 0) aw 0) pad) | ||
| (+ (if (< h 0) ah 0) pad)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
zero-comparison-to-negative?: This expression is equivalent to calling the negative? predicate.
| (+ (if (< h 0) ah 0) pad)) | |
| (+ (if (negative? h) ah 0) pad)) |
Debugging details
Textual replacement
(line-replacement
#:new-lines '#(" (+ (if (negative? h) ah 0) pad))")
#:original-lines '#(" (+ (if (< h 0) ah 0) pad))")
#:start-line 422)Syntactic replacement
(syntax-replacement
#:introduction-scope #<procedure:do-make-syntax-introducer>
#:new-syntax
#<syntax:/home/runner/.local/share/racket/8.15.0.11/pkgs/resyntax/default-recommendations/numeric-shortcuts.rkt:66:2 (negative? h)>
#:original-syntax
#<syntax:drracket/drracket/private/language.rkt:422:24 (< h 0)>
#:source
(file-source
#<path:/home/runner/work/drracket/drracket/drracket/drracket/private/language.rkt>))A pict's bounding box does not bound the pixels of the pict's rendered form. That kind of "bounding" box works well for composing pictures, but it's confusing when lines and edges are cut off in a DrRacket interaction. A pict's default conversion to bitmap or SVG form, meanwhile, adds 3 units of padding around a pict to help avoid confusion and edge effects, especially when rendering to Scribble documents (where the passing is compensated by an inset return with the bitmap to preserve alignment). Printing in DrRacket does not convert a pict to a bitmap, but instead wraps it directly in a snip. This commits adds the same padding around the pict within a snip for its printed form. That padding extends the descent, so baseline alignment still works. Snips don't support horizontal inset, at least not in the same way as Scribble (or potentially other consumers of a pict-to-bitmap conversion), but that seems less important in a value-printing context. With this change, the output of the following program looks nicer and almost certainly is a better reflection on the programmer's intent: ``` (require pict) (hline 10 0) (rectangle 10 10) ```
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resyntax analyzed 1 file in this pull request and has added suggestions.
| (draw-pict pict rdc | ||
| (if (< w 0) aw 0) | ||
| (if (< h 0) ah 0)) | ||
| (+ (if (< w 0) aw 0) l-pad) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
zero-comparison-to-negative?: This expression is equivalent to calling the negative? predicate.
| (+ (if (< w 0) aw 0) l-pad) | |
| (+ (if (negative? w) aw 0) l-pad) |
Debugging details
Textual replacement
(line-replacement
#:new-lines '#(" (+ (if (negative? w) aw 0) l-pad)")
#:original-lines '#(" (+ (if (< w 0) aw 0) l-pad)")
#:start-line 423)Syntactic replacement
(syntax-replacement
#:introduction-scope #<procedure:do-make-syntax-introducer>
#:new-syntax
#<syntax:/home/runner/.local/share/racket/8.15.0.11/pkgs/resyntax/default-recommendations/numeric-shortcuts.rkt:66:2 (negative? w)>
#:original-syntax
#<syntax:drracket/drracket/private/language.rkt:423:24 (< w 0)>
#:source
(file-source
#<path:/home/runner/work/drracket/drracket/drracket/drracket/private/language.rkt>))| (if (< w 0) aw 0) | ||
| (if (< h 0) ah 0)) | ||
| (+ (if (< w 0) aw 0) l-pad) | ||
| (+ (if (< h 0) ah 0) t-pad)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
zero-comparison-to-negative?: This expression is equivalent to calling the negative? predicate.
| (+ (if (< h 0) ah 0) t-pad)) | |
| (+ (if (negative? h) ah 0) t-pad)) |
Debugging details
Textual replacement
(line-replacement
#:new-lines '#(" (+ (if (negative? h) ah 0) t-pad))")
#:original-lines '#(" (+ (if (< h 0) ah 0) t-pad))")
#:start-line 424)Syntactic replacement
(syntax-replacement
#:introduction-scope #<procedure:do-make-syntax-introducer>
#:new-syntax
#<syntax:/home/runner/.local/share/racket/8.15.0.11/pkgs/resyntax/default-recommendations/numeric-shortcuts.rkt:66:2 (negative? h)>
#:original-syntax
#<syntax:drracket/drracket/private/language.rkt:424:24 (< h 0)>
#:source
(file-source
#<path:/home/runner/work/drracket/drracket/drracket/drracket/private/language.rkt>))
A pict's bounding box does not bound the pixels of the pict's rendered form. That kind of "bounding" box works well for composing pictures, but it's confusing when lines and edges are cut off in a DrRacket interaction. A pict's default conversion to bitmap or SVG form, meanwhile, adds 3 units of padding around a pict to help avoid confusion and edge effects, especially when rendering to Scribble documents (where the passing is compensated by an inset return with the bitmap to preserve alignment). Printing in DrRacket does not convert a pict to a bitmap, but instead wraps it directly in a snip.
This commits adds 3 units of padding around the pict within a snip for its printed form. That padding extends the descent, so baseline alignment still works. Snips don't support horizontal inset, at least not in the same way as Scribble (or potentially other consumers of a pict-to-bitmap conversion), but that seems less important in a value-printing context.
With this change, the output of the following program looks nicer and almost certainly is a better reflection on the programmer's intent: