# AVSLib :: sample script # Copyright (c) 2005, 2007 George Zarkadas (gzarkadas@users.sourceforge.net) # This program is free software; you can redistribute it and/or modify it under the terms of # the GNU General Public License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR # PURPOSE. See the GNU General Public License for more details. # You should have received a copy of the GNU General Public License along with this program; # if not, write to the "Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA" LoadPackage("avslib", "base") LoadPackage("avslib", "array") LoadModule("avslib", "filters", "animate") # Animates expanding rectangles on multiple curves, with varying overlay modes global _thetas = ArrayRange(0, 2*Pi(), npoints=21) global _aparam = 40 # r,theta correspond to Archimedes spiral (a*theta, theta) global _rs = _thetas.ArrayOpValue(_aparam, "*") Function xpolar(float r, float theta) { return Float(r)*Cos(theta) } Function ypolar(float r, float theta) { return Float(r)*Sin(theta) } global xy_path = ArrayPlex( \ ArrayOpArrayFunc(_rs, _thetas, "xpolar").ArrayOpFunc("Round"), \ ArrayOpArrayFunc(_rs, _thetas, "ypolar").ArrayOpFunc("Round") \ ) global wh_dims = ArrayRange(12, 92, 4) global o_modes = \ "blend,add,blend,subtract,blend,chroma,blend,blend,luma,blend,blend," + \ "lighten,blend,blend,softlight,blend,blend,hardlight,blend,blend" # one less than xy_path Function xrot(int x, int y, float angle) { return Round(x*Cos(angle) - y*Sin(angle)) } Function yrot(int x, int y, float angle) { return Round(x*Sin(angle) + y*Cos(angle)) } # rotates a plexed (x,y) path by angle radians Function rotate_path(string path, float angle) { path_x = path.ArrayDeplex(0, 2) path_y = path.ArrayDeplex(1, 2) new_x = ArrayOpArrayFunc(path_x, path_y, "xrot", String(angle)) new_y = ArrayOpArrayFunc(path_x, path_y, "yrot", String(angle)) return ArrayPlex(new_x, new_y) } # the base effect function Function rect_effect(clip base, string path, int rect_color) { rect = BlankClip(base, color=rect_color) frames = ArrayRange(0, base.Framecount - 1, npoints=21).ArrayOpFunc("Round") # relocate path to center of base clip xp = path.ArrayDeplex(0,2).ArrayOpValue(Round(base.Width / 2), "+") yp = path.ArrayDeplex(1,2).ArrayOpValue(Round(base.Height / 2), "+") # not specifying a mask == full white mask return PolygonAnim(base, rect, frames, xp, yp, 1.0, wh_dims, wh_dims, mode=o_modes) } # the angle step to rotate base (x,y) path ( 2pi/{number of curves} ) the last being 12 global theta = Pi()/6 # 30 degrees # since color constants are globals creating an array with their names will return their value global in_colors = "color_gold,color_ivory,color_mediumorchid,color_beige,color_aquamarine,color_blue," + \ "color_darkorange,color_white,color_darkred,color_crimson,color_olivedrab,color_chocolate" Function MakeEffect006(clip base) { c = base c = c.rect_effect(xy_path, in_colors.ArrayGet( 0)) c = c.rect_effect(xy_path.rotate_path( theta), in_colors.ArrayGet( 1)) c = c.rect_effect(xy_path.rotate_path( 2*theta), in_colors.ArrayGet( 2)) c = c.rect_effect(xy_path.rotate_path( 3*theta), in_colors.ArrayGet( 3)) c = c.rect_effect(xy_path.rotate_path( 4*theta), in_colors.ArrayGet( 4)) c = c.rect_effect(xy_path.rotate_path( 5*theta), in_colors.ArrayGet( 5)) c = c.rect_effect(xy_path.rotate_path( 6*theta), in_colors.ArrayGet( 6)) c = c.rect_effect(xy_path.rotate_path( 7*theta), in_colors.ArrayGet( 7)) c = c.rect_effect(xy_path.rotate_path( 8*theta), in_colors.ArrayGet( 8)) c = c.rect_effect(xy_path.rotate_path( 9*theta), in_colors.ArrayGet( 9)) c = c.rect_effect(xy_path.rotate_path(10*theta), in_colors.ArrayGet(10)) c = c.rect_effect(xy_path.rotate_path(11*theta), in_colors.ArrayGet(11)) return c } # create a 8sec animation in PAL format base = BlankClip(color=$020060, length=200, fps=FRATE_PAL, width=WSIZE_PAL, height=HSIZE_PAL).ConvertToYV12() return MakeEffect006(base)