Created
February 9, 2017 14:22
-
-
Save alblaz/5789d069c821e5817d3a9f98e1fba10b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Colors, GLVisualize, Reactive, GLAbstraction, GeometryTypes, GLWindow | |
window = glscreen() | |
@async GLWindow.waiting_renderloop(window) | |
plot_screen = Screen(window) | |
GLVisualize.add_screen(plot_screen) | |
#initial data | |
n = 200 | |
xls = linspace(0,1,n) | |
yls = zeros(xls) | |
using Plots ; glvisualize(size = widths(plot_screen)) | |
pl = plot([xls,xls,xls,xls,xls],[yls,yls,yls,yls,yls], | |
color=[:red :green :blue :cyan :purple], | |
lw= 2, | |
label = "", | |
ylim = (-10000,10000)); | |
gui() | |
current_series = pl.o.children[1].renderlist[1][3:end] | |
function update_plot!(coeffSignal,myx,myseries) | |
n = length(myx) | |
k = length(myseries) | |
for i=1:k | |
ynew = rand(n)*coeffSignal | |
new_vals = map(Point2f0, zip(myx, ynew)) | |
set_arg!(myseries[i], :vertex, new_vals) | |
end | |
nothing | |
end | |
function update_plot_in_another_way!(t,myx,myseries) | |
k = length(myseries) | |
for i=1:k | |
ynew = sin(t*myx + i*10./(myx+15.))*1000.*i | |
new_vals = map(Point2f0, zip(myx, ynew)) | |
set_arg!(myseries[i], :vertex, new_vals) | |
end | |
nothing | |
end | |
update_plot2!(x) = update_plot!(x,xls,current_series) | |
update_plot_in_another_way2!(x) = update_plot_in_another_way!(x,xls,current_series) | |
function animate_myplot() | |
ticks = fps(1) | |
t = foldp(+, 0.0, ticks) | |
coeff_signal = map(x-> x<10.?7000:3000, t) | |
ref_plotmap = preserve(map(update_plot2!,coeff_signal)) | |
return ref_plotmap,coeff_signal,ticks,t | |
end | |
function animate_myplot2() | |
ticks = fps(3) | |
t = foldp(+, 0.0, ticks) | |
coeff_signal = map(x-> x*100, t) | |
ref_plotmap = preserve(map(update_plot2!,coeff_signal)) | |
return ref_plotmap,coeff_signal,ticks,t | |
end | |
function animate_myplot3() | |
ticks = fps(10) | |
t = foldp(+, 0.0, ticks) | |
ref_plotmap = preserve(map(update_plot_in_another_way2!,t)) | |
return ref_plotmap,ticks,t | |
end | |
# ref_plotmap,m,ticks,t = animate_myplot(); unpreserve(ref_plotmap); gc(); | |
# ref_plotmap,m,ticks,t = animate_myplot2(); unpreserve(ref_plotmap); gc(); | |
ref_plotmap,ticks,t = animate_myplot3(); unpreserve(ref_plotmap); gc(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment