-
-
Notifications
You must be signed in to change notification settings - Fork 482
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
Animated GIF plots should repaint bgcolor after each frame #11313
Comments
Author: Keshav Kini |
comment:1
Any ideas on how to doctest this? Doesn't really seem possible, on first glance anyway... |
This comment has been minimized.
This comment has been minimized.
comment:3
Does this slow anything down? |
comment:4
This is a defect, not an enhancement, ticket, so I don't consider potential slowdown to be a problem with the patch. That aside, ImageMagick is written in C and is pretty fast. If To elaborate on what makes this a defect: when you create an animation, Sage first creates a bunch of frames, then uses ImageMagick to make an animated GIF out of them. If the frames are not all the same size, then ImageMagick determines the minimum size for the final GIF in which it is possible to accommodate all the frames. The default behavior is to simply draw frame |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
comment:7
Sorry about the spam... |
This comment has been minimized.
This comment has been minimized.
comment:8
Can you provide code which illustrates the problem (before the patch) and its solution (after)? |
comment:10
Here we are: t = var('t')
def frame(theta):
r = 2
x = r*(t - sin(t))
y = r*(1 - cos(t))
plot = parametric_plot((x, y), (t,0,theta), rgbcolor=hue(0.6))
krug = circle((2*theta, r), r)
tocka = point((r*(theta - sin(theta)), r*(1 - cos(theta))), pointsize=30, color='red')
return plot+krug+tocka;
animacija = animate([frame(x) for x in srange(0.1, 5*pi, 0.1)])
animacija.show(delay=10, iterations=0) Credit to user |
comment:11
Minor point: the patch doesn't apply cleanly to Sage 4.7.1.rc0, but that's easy to fix. More importantly, with Safari 5.1 on a Mac, the area which is no longer part of the picture displays as a black box. On Firefox or Chrome, it's white (or maybe the default background color?), but it looks bad on Safari. I don't know if this is a bug in how Safari displays animated gifs or if we can avoid it somehow. |
comment:12
The "something kind of alarming" appears to be caused by #11170 - the GIF blows up in filesize by a factor of 50 and the aspect ratio is destroyed. I'll cross-post to that ticket... As for Safari, no idea. I'll look into it. |
comment:14
Now that #11650 is in, here's a rebase on sage 4.8.alpha6. How the above GIF looks after the patch: On the imgur page you can see how the GIF's transparency and non-white backgrounds interact. Compare with the old behavior. |
comment:15
Whoops, the "before" image is a bit different now in sage 4.8.alpha6 than it was when I posted [comment:9]. See the description for the updated GIF. |
This comment has been minimized.
This comment has been minimized.
comment:16
This looks good to me. By the way, where is this syntax for defining strings s = ('abc' 'def') documented? |
Reviewer: John Palmieri |
comment:17
Here is the relevant section of the Python docs. Actually, s = 'abc' 'def' works too, but the parentheses in the patch force a line continuation. Thanks for the review! |
apply to $SAGE_ROOT/devel/sage |
comment:18
Attachment: trac_11313-imagemagick-options.patch.gz Changed commit message. |
comment:19
Wait, what? So now we're not putting the trac ticket number in the commit message? Hmm, I didn't realize that. Thanks for the heads up. |
comment:20
Replying to @kini:
Funny how in the beginning when I was release manager, I had to convince everybody to put ticket numbers in the commit message and quite a few didn't do it (or worse: put the wrong ticket number). Since sage-4.7, the ticket numbers are added automatically but it seems that now, more people than before are actually adding the ticket number. |
comment:21
Of course, the best way would be to have people make commits to the tree, and then close the ticket with a reference to the commit, rather than making the commit upon release, when the ticket has been closed already. But for that I guess we need to implement the github-based sage --push/pull workflow Robert Bradshaw suggested, or something similar. By the way, why not just check whether the ticket number is already in the commit message and not add it again if so? |
comment:22
Replying to @kini:
When this was discussed on sage-devel (please don't ask me to find the thread again), somebody suggested that having a uniform format
could be useful for scripts. I would find a version of "hg blame" with ticket numbers quite interesting. If somebody would implement this, then the standard-format ticket numbers would certainly be useful. |
Merged: sage-5.0.beta1 |
As title. ImageMagick should be called with
-dispose Background
, because when you create an animation, Sage first creates a bunch of frames, then uses ImageMagick to make an animated GIF out of them. If the frames are not all the same size, then ImageMagick determines the minimum size for the final GIF in which it is possible to accommodate all the frames. The default behavior is to simply draw framen
over framen-1
without erasing framen-1
. When framen
's image is smaller than framen-1
's image, however, you get garbage in framen
outside the borders of the original image used to create framen
.Before:
After:
The above image was produced by the following code:
(Thanks to user
v-v
on Freenode.)Apply attachment: trac_11313-imagemagick-options.patch to
$SAGE_ROOT/devel/sage
.Component: graphics
Keywords: plot, animate, imagemagick
Author: Keshav Kini
Reviewer: John Palmieri
Merged: sage-5.0.beta1
Issue created by migration from https://trac.sagemath.org/ticket/11313
The text was updated successfully, but these errors were encountered: