Add flip procedures - #78
Conversation
If I am reading "pict.rkt" correctly, https://github.com/racket/pict/blob/master/pict-lib/pict/private/pict.rkt |
Oh, phew. That makes sense. |
|
If there's something else needed to merge this (tests? version note?), I'll be happy to dig into it, but otherwise this is complete from my end. |
|
I'm not really complete sure how the transformation matricies work but, the specific linear algebra aside, this looks good to me. I agree it would be nice to have a test that I had thought that this would be implemented with a scale of -1, actually (but that's neither here nor there). |
|
The scale with -1 trick almost works - but the bounding box ends up wrong. See the original issue: |
|
Ah, thanks. And my comment about Perhaps a test case that would distinguish this implementation from the "scale by negative one" approach? |
|
I'll have to take a look at how pict testing is done, but I agree it would be nice for flip-x and flip-y to be tested for compositions and against the bounding-box issue. |
|
Tests passed 100% according to |
|
Does (I think this won't pass with the |
|
Hmm, so far they don't seem to pass (failure reported for |
|
You (Robby) were right, the In When applied the transformations work from bottom to top.
Similarly the transformation in With these changes Robby's example work again and the ellipse tests pass too. |
|
I'll get these added today! |
|
I made @soegaard's changes, but the test ,r pict racket/gui
(show-pict (cc-superimpose (ellipse 200 300 #:border-color "red")
(flip-x (ellipse 200 300)))) |
It depends on your perspective. The default setting for "smoothing" is To test this, I tried the same example, but with My perspective is that this sort of discrepancy is expected when using |
|
I don't have a strong opinion on whether or not this should work for Or, failing that, maybe a test case with a rectangle (but drawn inside a pict with a larger bounding box), perhaps something like |
|
Turns out I made a mistake earlier. I thought of the (dx,dy) as the coordinates of the pict center, This test revealed the problem: Sadly this example still isn't pixel perfect. |
|
FWIW the svg version looks correct when examined in Inkscape. |
|
I've incorporated the changes for centering/corners, but as pointed out it is not enough for pixel-perfect transforms. I can try to adjust the test to use smoothing for those picts, or we might need to find a different way to express "equivalence with some tolerance." |
|
I cherry-picked the current version of this pull request into my copy of the pict repo and then ran this program: and this is the output I see: Did I do something wrong? |
|
No, I haven't pushed the latest changes while we were… debating? …the ellipse issue. I'll push it by Monday; hopefully that fixes what you're seeing. This is almost certainly the miscalculation about the meaning of |
|
Oh, okay! Sorry!
Thanks,
Robby
…On Sat, Mar 18, 2023 at 10:16 PM D. Ben Knoble ***@***.***> wrote:
No, I haven't pushed the latest changes while we were… debating? …the
ellipse issue. I'll push it by Monday; hopefully that fixes what you're
seeing.
—
Reply to this email directly, view it on GitHub
<#78 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AADBNMEQJGEXVSBMW4HBFZ3W4Z3AHANCNFSM6AAAAAAVZOMY3U>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
|
Good thing you weren't sitting around waiting on me @rfindler 😅 just re-pushed changes with centering fix. |
|
Thanks @benknoble . Looks to me like the images are the same now. I just ran this on macos not linux, tho. But this program produces |
|
@rfindler your program does indeed print pict/pict-test/tests/pict/main.rkt Lines 754 to 756 in dc72758 raco test -y.
If I make the change - (define oval (ellipse 20 30))
+ (define oval (colorize (filled-ellipse 20 30 #:draw-border? #f) "green"))the tests pass. Similarly without So, since the borders are what cause problems, possibly due to the reasons @soegaard explained, what do you want to do? |
|
Well, I can't tell if it is a rounding error, something that's a bug in this transformation, or a bug in how transformations work in general that has nothing to do with flipping, so I guess the best thing to do is to put in the test cases that we know work properly (some with one flip of an ellipse in both x and y but without any pen drawing) and then merge this PR. FWIW, I am not sure that this problem is specific to |
|
Just found the following bug report. If I understand correctly, the border of an ellipse is alligned, but the filled area isn't. |
|
That would seem to support the "it is a rounding error in smoothed mode and actually a different image in aligned mode" theory, I guess? |
Close racket#29. Co-authored-by: Jens Axel Søgaard <jensaxel@soegaard.net>
|
I confess I haven't followed most of the rounding/border/draw issues, but I pushed the test that works. |
|
Probably not worth including here (or even making a PR for…), but pict/pict-test/tests/pict/main.rkt Lines 26 to 27 in 2541f12 (send b …) instead of the saved w/h.
|
|
I don't see any more improvements to make; seems ready to go to me. |
|
@soegaard any thing that should be done before merging that you see? |
|
No, looks good to me. |
|
Thanks! |





I'm not actually sure if the contract
pict-convertible?is right, but it's whatscalehad and it also usespict-widthandpict-heighton apict-convertible?, so I went with it.(Is this one of those contracts like Butterick's sugar that automatically does the conversion? Or is
pict-widthexported as a wrapper? Because the docs suggest thatpict-widthis the struct accessor, so the implementation ofscaleand thus the flipping functions is actually at fault relative to its contract.)