-
Notifications
You must be signed in to change notification settings - Fork 204
Fixed cropping bug #26
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
|
The fix is correct, but the tests are dependent on manual inspection. Rather than using vgimg and writing outthe resulting png, use a vg/recorder.Canvas and compare the resulting sets of vg operations mechanically (you could write the png to a bytes.Buffer, but I would prefer to be able to see that both things are sane).
|
vg/draw/draw_test.go
Outdated
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.
Imported and not used.
|
Chris, thanks for this and for your other changes too. Could you please explain this bug in a bit more detail (in fact, could you please add the explanation to the commit message)? I don't quite understand what's happening here, but I also don't understand why I started the canvas at -w/2, -h/2 either :) |
|
It looks like it was an error in Seb's change to rect. The original code used an implicitly zero Min field. For some reason that got translated into what exists now.
|
|
LGTM, once Dan's suggestions are in. |
|
I fixed the test to not require manual inspection |
|
On mobile, so I'll do this properly later, but to get you started: you can reflect.DeepEqual-compare the recorder actions; now that it's not dependent on being visible, the inches can go away; obvious cleanup of commented out sections; and what is the reason for the change to plotter/main.go?
|
vg/draw/draw_test.go
Outdated
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.
Change the format string to "unexpected result: %+v != %+v".
|
LGTM after minor nits. Then rebase onto gonum/plot master if necessary and squash. |
|
Thanks, Chris. |

There is an issue with the draw.Canvas.Crop() function. I've added a test to document it. The test does cropping two different ways, the rectangles of which should be the same, and produces two output images that should also be the same. In the current version the two methods yield different results. The change that I made fixes this bug.