Comments (5)
Hey @davidwych! Thanks for the issue and suggestion.
I can look at adding the non-loop parameter
As for the other issue. Could you drop in your data, so I can poke at it?
from gif.
(1) The non-loop functionality would be useful for "one-time use" animations (e.g. in my case I'm creating this gif for a slide in a presentation, so I really just need the animation to run through once and then stay in the form it's in at the last frame for the remaining time I'm presenting the slide).
(2) Here's the piano data:
piano.npy.zip
to load it:
piano = np.load("piano.npy")
t = np.linspace(0, len(piano)/22050, len(piano))
n.b. in the code above: replace piano[0]
with just piano
from gif.
Okay, figured out your first thing!
Seems like you need to adjust your if
s. Basically, you need two for every note. One to track the note, and another to keep the color turned on.
See this reproducible example:
import gif
from matplotlib import pyplot as plt
x = list(range(100))
y = [10] * len(x)
@gif.frame
def plot(i):
plt.plot(x[:i], y[:i])
plt.xlim([0, max(x)])
plt.ylim([0, max(y) * 2])
# track the RED note
if x[i] > 50 and x[i] < 70:
plt.axvspan(50, x[i-1], facecolor="Red", ls="--", lw=2.0, alpha=0.2)
# track the BLUE note
if x[i] > 80 and x[i] < 90:
plt.axvspan(80, x[i-1], facecolor="Blue", ls="--", lw=2.0, alpha=0.2)
# make sure the RED stays on
if x[i] >= 70:
plt.axvspan(50, 70, facecolor="Red", ls="--", lw=2.0, alpha=0.2)
# make sure the BLUE stays on
if x[i] >= 90:
plt.axvspan(80, 90, facecolor="Blue", ls="--", lw=2.0, alpha=0.2)
frames = []
for i in range(len(x)):
frame = plot(i)
frames.append(frame)
gif.save(frames, 'piano.gif', duration=30)
Output:
from gif.
As for the non-looping. Let me meditate on it... for now... just skip the slide a millisecond before it finishes
from gif.
Thanks so much! Sorry if this wasn't really an "issue" so much as me not knowing how conditionals work... :|
I thought maybe it had something to do with how arguments are handled by the decorator.
from gif.
Related Issues (9)
- More Examples 💪
- Duration parameter has no effect HOT 3
- AttributeError: partially initialized module 'gif' has no attribute 'options' (most likely due to a circular import) HOT 1
- Size optimization idea HOT 2
- Could this work on generators instead of lists? HOT 5
- Is there a way to stop the gif after one iteration? HOT 4
- Consider using an image object HOT 1
- Compatibility with plotly HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gif.