一个透明的GIF动画

来源:互联网 发布:完整性保护算法 编辑:程序博客网 时间:2024/05/01 14:12

解决初等数学问题的动态演示,需要生成GIF动画;

在设置透明背景时, Mathematica的Export函数中的选项颇多,用法诡异,下面例子供参考


ClearAll["`*"];xmin = -3;xmax = 4;ymin = -10;ymax = 3;line1 = Line[{{xmin, ymin}, {xmin, ymax}}];line2 = Line[{{xmax, ymin}, {xmax,     ymax}}]; slides = 8; cmin = -10; cmax = 5/2; v =  Table[Manipulate[   Plot[{1/3 x^3 + x^2 + x - (2 x^2 + 4 x), c}, {x, xmin, xmax},     PlotStyle -> {Blue, Red}, AspectRatio -> GoldenRatio,     PlotRange -> {{xmin, xmax}, {ymin, ymax}},     Epilog -> {Directive[{Green, Green}], line1, line2},     Background -> None], {{c, k/slides, "Constant:"}, cmin,     cmax}], {k, cmin*slides, cmax*slides}]; v =  Join[v[[1 ;; Dimensions[v][[1]] - 1]], Reverse[v]];Export["vTest.gif", v, "TransparentColor" -> White,  "TransitionEffect" -> Background]


不仅"TransparentColor"而且"TransitionEffect"都必须设置非默认值;

0 0