def composition(cfg): cfg.duration = 5 # fmt: off points = ( (-.6, .2, 0), (-.2, .7, 0), (.5, .3, 0), (-.3, .1, 0), (.1, -.2, 0), (-.2, -.4, 0), (.3, -.6, 0), (.7, -.2, 0), (-.4, -.1, 0), (-.8, -.1, 0), (-.6, .2, 0), ) controls = ( (.4, .8, 0), (.0, .1, 0), (-.1, .2, 0), (.6, -.6, 0), (-.6, -.2, 0), (-.8, .4, 0), (-1.2, .5, 0), ) # fmt: on keyframes = [ ngl.PathKeyMove(to=points[0]), ngl.PathKeyLine(to=points[1]), ngl.PathKeyBezier3(control1=controls[0], control2=controls[1], to=points[2]), ngl.PathKeyMove(to=points[3]), ngl.PathKeyBezier2(control=controls[2], to=points[4]), ngl.PathKeyLine(to=points[5]), ngl.PathKeyLine(to=points[6]), ngl.PathKeyBezier2(control=controls[3], to=points[7]), ngl.PathKeyMove(to=points[8]), ngl.PathKeyBezier3(control1=controls[4], control2=controls[5], to=points[9]), ngl.PathKeyBezier2(control=controls[6], to=points[10]), ] path = ngl.Path(keyframes) return _path_scene(cfg, path, points, controls)
def transform_path(cfg): cfg.aspect_ratio = (1, 1) cfg.duration = 7 shape = _transform_shape(cfg, w=0.2, h=0.5) # fmt: off points = ( (0.7, 0.0, -0.3), (-0.8, -0.1, 0.1), ) controls = ( (0.2, 0.3, -0.2), (-0.2, -0.8, -0.4), ) # fmt: on keyframes = ( ngl.PathKeyMove(to=points[0]), ngl.PathKeyLine(to=points[1]), ngl.PathKeyBezier2(control=controls[0], to=points[0]), ngl.PathKeyBezier3(control1=controls[0], control2=controls[1], to=points[1]), ) path = ngl.Path(keyframes) # We use back_in_out easing to force an overflow on both sides anim_kf = [ ngl.AnimKeyFrameFloat(0, 0), ngl.AnimKeyFrameFloat(cfg.duration - 1, 1, "back_in_out"), ] return ngl.Translate(shape, vector=ngl.AnimatedPath(anim_kf, path))
def complex_bezier(cfg): cfg.duration = 5 # fmt: off points = ( (-0.70, 0.08, 0.0), (-0.15, 0.06, 0.0), (-0.24, 0.52, 0.0), (0.23, 0.15, 0.0), (0.05, -0.25, 0.0), ) controls = ( (0.45, -0.59, 0.0), (-1.1, -0.47, 0.0), (0.25, 0.29, 0.0), (-0.19, -1.1, 0.0), (-0.25, 1.1, 0.0), (0.19, -0.75, 0.0), (0.0, 0.96, 0.0), (1.1, -0.86, 0.0), ) # fmt: on keyframes = [ ngl.PathKeyMove(to=points[0]), ngl.PathKeyBezier3(control1=controls[0], control2=controls[1], to=points[1]), ngl.PathKeyBezier3(control1=controls[2], control2=controls[3], to=points[2]), ngl.PathKeyBezier3(control1=controls[4], control2=controls[5], to=points[3]), ngl.PathKeyBezier3(control1=controls[6], control2=controls[7], to=points[4]), ] path = ngl.Path(keyframes) return _path_scene(cfg, path, points, controls)
def simple_bezier(cfg, easing="linear"): cfg.duration = 2 # fmt: off points = ( (-0.7, 0.0, 0.0), (0.8, 0.1, 0.0), ) controls = ( (-0.2, -0.3, 0.0), (0.2, 0.8, 0.0), ) # fmt: on keyframes = ( ngl.PathKeyMove(to=points[0]), ngl.PathKeyBezier3(control1=controls[0], control2=controls[1], to=points[1]), ) path = ngl.Path(keyframes) return _path_scene(cfg, path, points, controls, easing=easing)
def character_otf(cfg): """The 'g' glyph from Adobe Source Code Pro Black""" cfg.duration = 5 keyframes = [ # fmt: off ngl.PathKeyMove(to=(0.423713, 0, 0)), ngl.PathKeyBezier3(control1=(0.775735, 0, 0), control2=(1, 0.103331, 0), to=(1, 0.253569, 0)), ngl.PathKeyBezier3(control1=(1, 0.381373, 0), control2=(0.856618, 0.434398, 0), to=(0.608456, 0.434398, 0)), ngl.PathKeyLine(to=(0.448529, 0.434398, 0)), ngl.PathKeyBezier3(control1=(0.342831, 0.434398, 0), control2=(0.301471, 0.445275, 0), to=(0.301471, 0.476547, 0)), ngl.PathKeyBezier3(control1=(0.301471, 0.495581, 0), control2=(0.308824, 0.503739, 0), to=(0.331801, 0.516655, 0)), ngl.PathKeyBezier3(control1=(0.376838, 0.509857, 0), control2=(0.41636, 0.507138, 0), to=(0.450368, 0.507138, 0)), ngl.PathKeyBezier3(control1=(0.673713, 0.507138, 0), control2=(0.847426, 0.573759, 0), to=(0.847426, 0.738273, 0)), ngl.PathKeyBezier3(control1=(0.847426, 0.766145, 0), control2=(0.83364, 0.793338, 0), to=(0.820772, 0.810333, 0)), ngl.PathKeyLine(to=(0.98989, 0.810333, 0)), ngl.PathKeyLine(to=(0.98989, 0.983005, 0)), ngl.PathKeyLine(to=(0.610294, 0.983005, 0)), ngl.PathKeyBezier3(control1=(0.5625, 0.993882, 0), control2=(0.506434, 1, 0), to=(0.450368, 1, 0)), ngl.PathKeyBezier3(control1=(0.231618, 1, 0), control2=(0.0340074, 0.919103, 0), to=(0.0340074, 0.746431, 0)), ngl.PathKeyBezier3(control1=(0.0340074, 0.665534, 0), control2=(0.0900735, 0.601632, 0), to=(0.161765, 0.568321, 0)), ngl.PathKeyLine(to=(0.161765, 0.562882, 0)), ngl.PathKeyBezier3(control1=(0.0965074, 0.528892, 0), control2=(0.0487132, 0.479266, 0), to=(0.0487132, 0.431679, 0)), ngl.PathKeyBezier3(control1=(0.0487132, 0.373215, 0), control2=(0.0900735, 0.337186, 0), to=(0.143382, 0.312033, 0)), ngl.PathKeyLine(to=(0.143382, 0.306594, 0)), ngl.PathKeyBezier3(control1=(0.0487132, 0.273283, 0), control2=(0, 0.229776, 0), to=(0, 0.172672, 0)), ngl.PathKeyBezier3(control1=(0, 0.0475867, 0), control2=(0.190257, 0, 0), to=(0.423713, 0, 0)), ngl.PathKeyMove(to=(0.450368, 0.648538, 0)), ngl.PathKeyBezier3(control1=(0.387868, 0.648538, 0), control2=(0.337316, 0.67981, 0), to=(0.337316, 0.746431, 0)), ngl.PathKeyBezier3(control1=(0.337316, 0.810333, 0), control2=(0.387868, 0.840925, 0), to=(0.450368, 0.840925, 0)), ngl.PathKeyBezier3(control1=(0.511949, 0.840925, 0), control2=(0.565257, 0.810333, 0), to=(0.565257, 0.746431, 0)), ngl.PathKeyBezier3(control1=(0.565257, 0.67981, 0), control2=(0.511949, 0.648538, 0), to=(0.450368, 0.648538, 0)), ngl.PathKeyMove(to=(0.474265, 0.147519, 0)), ngl.PathKeyBezier3(control1=(0.348346, 0.147519, 0), control2=(0.261949, 0.167233, 0), to=(0.261949, 0.211421, 0)), ngl.PathKeyBezier3(control1=(0.261949, 0.231135, 0), control2=(0.276654, 0.245411, 0), to=(0.308824, 0.261727, 0)), ngl.PathKeyBezier3(control1=(0.340993, 0.256288, 0), control2=(0.378676, 0.253569, 0), to=(0.452206, 0.253569, 0)), ngl.PathKeyLine(to=(0.545956, 0.253569, 0)), ngl.PathKeyBezier3(control1=(0.639706, 0.253569, 0), control2=(0.693015, 0.248131, 0), to=(0.693015, 0.211421, 0)), ngl.PathKeyBezier3(control1=(0.693015, 0.172672, 0), control2=(0.600184, 0.147519, 0), to=(0.474265, 0.147519, 0)), # fmt: on ] path = ngl.Path(keyframes) return ngl.Scale(_path_scene(cfg, path), factors=(2, 2, 0), anchor=(1, 1, 0))