Exemplo n.º 1
0
def particle():
    g = layer.add_shape(objects.Group())
    b = g.add_shape(objects.Ellipse())
    fill = objects.Fill()
    g.add_shape(fill)
    t = random.random()

    if t < 1/2:
        lf = t * 2
        fill.color.add_keyframe(0, color1.lerp(color2, lf))
        fill.color.add_keyframe(last_frame*t, color2)
        fill.color.add_keyframe((1 - t) * last_frame, color3, easing.Jump())
        fill.color.add_keyframe((1 - t) * last_frame+1, color1)
        fill.color.add_keyframe(last_frame, color1.lerp(color2, lf))
    else:
        lf = (t-0.5) * 2
        tf = (1-lf)/2
        fill.color.add_keyframe(0, color2.lerp(color3, lf))
        fill.color.add_keyframe(last_frame*tf, color3, easing.Jump())
        fill.color.add_keyframe(last_frame*tf+1, color1)
        fill.color.add_keyframe((.5 + tf) * last_frame, color2)
        fill.color.add_keyframe(last_frame, color2.lerp(color3, lf))

    fill.opacity.add_keyframe(0, opacity_start + (opacity_end - opacity_start) * t)
    fill.opacity.add_keyframe((1 - t) * last_frame, opacity_end)
    fill.opacity.add_keyframe((1 - t) * last_frame+1, opacity_start)
    fill.opacity.add_keyframe(last_frame, opacity_start + (opacity_end - opacity_start) * t)

    bezier = objects.Bezier()
    outp = PolarVector(random.uniform(start_len_min, start_len_max), random.random() * math.pi)
    inp = Point(0,  random.random() * (particle_end.y - particle_start.y) / 3)
    bezier.add_point(particle_start, outp=outp)
    bezier.add_point(particle_end, outp)

    b.size.value = particle_size
    anutils.follow_path(b.position, bezier, 0, last_frame, 10, start_t=t)
Exemplo n.º 2
0
#!/usr/bin/env python3
import sys
import os
sys.path.insert(
    0,
    os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
                 "lib"))
from lottie.utils import script
from lottie import objects
from lottie.parsers.svg import parse_svg_file
from lottie import Point, Color

an = parse_svg_file(
    os.path.join(os.path.dirname(os.path.abspath(__file__)), "blep.svg"))

layer = an.insert_layer(0, objects.ShapeLayer())
r = layer.add_shape(objects.Rect())
r.position.value = Point(256, 256)
r.size.value = Point(512, 512)
gf = layer.add_shape(
    objects.GradientFill([(0, Color(1, 1, 1)), (1, Color(0, 0, 0))]))
gf.start_point.value = Point(256, 256)
gf.end_point.value = Point(256, 64)

an.layers[-1].matte_mode = objects.MatteMode.Luma

script.script_main(an)
Exemplo n.º 3
0
from lottie.utils import script
from lottie import objects
from lottie import Point, Color, NVector

last_frame = 180
an = objects.Animation(last_frame)

layer = objects.ShapeLayer()
an.add_layer(layer)
layer.auto_orient = True

group = layer.add_shape(objects.Group())
star = objects.Star()
star.inner_radius.value = 20
star.outer_radius.value = 50
star.position.value = Point(0, 0)
group.add_shape(star)

group.add_shape(objects.Ellipse(NVector(0, 35), NVector(16, 16)))

layer.add_shape(objects.Fill(Color(1, 1, 0)))

tl = 120
layer.transform.position.add_keyframe(last_frame / 4 * 0,
                                      Point(+50, 256),
                                      out_tan=NVector(0, -tl),
                                      in_tan=NVector(-tl, 0))
layer.transform.position.add_keyframe(last_frame / 4 * 1,
                                      Point(256, +50),
                                      out_tan=NVector(+tl, 0),
                                      in_tan=NVector(0, -tl))
Exemplo n.º 4
0
    os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
                 "lib"))
from lottie.utils import script
from lottie import objects
from lottie.utils import animation as anutils
from lottie import Size, Point3D, Point, Color

an = objects.Animation(120)

layer = objects.ShapeLayer()
an.add_layer(layer)

g = layer.add_shape(objects.Group())
b = g.add_shape(objects.Ellipse())
b.size.value = Size(256, 256)
b.position.value = Point(256, 256)
g.add_shape(objects.Fill(Color(1, 1, 0)))

g = layer.insert_shape(0, objects.Group())
eye1 = g.add_shape(objects.Ellipse())
eye1.size.value = Size(20, 20)
eye1.position.value = Point3D(256 - 50, 256 - 50, -100)
g.add_shape(objects.Fill(Color(0, 0, 0)))

g = layer.insert_shape(0, objects.Group())
eye2 = g.add_shape(objects.Ellipse())
eye2.size.value = Size(20, 20)
eye2.position.value = Point3D(256 + 50, 256 - 50, -100)
g.add_shape(objects.Fill(Color(0, 0, 0)))

g = layer.insert_shape(0, objects.Group())
Exemplo n.º 5
0
import os
sys.path.insert(
    0,
    os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
                 "lib"))
from lottie.utils import script
from lottie import objects
from lottie import Point, Color

an = objects.Animation(59)

layer = objects.ShapeLayer()
an.add_layer(layer)

circle = layer.add_shape(objects.Ellipse())
circle.size.value = Point(100, 100)
circle.position.value = Point(220, 110)

star = layer.add_shape(objects.Star())
star.inner_radius.value = 20
star.outer_radius.value = 50
star.position.value = Point(330, 110)

rect = layer.add_shape(objects.Rect())
rect.size.value = Point(100, 100)
rect.position.value = Point(110, 110)

rrect = layer.add_shape(objects.Rect())
rrect.size.value = Point(100, 100)
rrect.position.value = Point(110, 220)
rrect.rounded.value = 30
Exemplo n.º 6
0
import sys
import os
sys.path.insert(
    0,
    os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
                 "lib"))
from lottie.utils import script
from lottie import objects
from lottie.utils import animation as anutils
from lottie import Point, Color

an = objects.Animation(180)

layer = objects.ShapeLayer()
an.add_layer(layer)

group = layer.add_shape(objects.Group())
bez = group.add_shape(objects.Path())
bez.shape.value.add_point(Point(256, 128), Point(0, 0), Point(64, 64))
bez.shape.value.add_smooth_point(Point(256, 256 + 120), Point(32, -32))
bez.shape.value.add_point(Point(256, 256), Point(-64, -64), Point(-64, 64))
bez.shape.value.add_point(Point(128, 256 + 120), Point(64, 64), Point(0, 0))
group.add_shape(objects.Stroke(Color(1, 0, 0), 10))

group = layer.add_shape(objects.Group())
sh = anutils.generate_path_segment(bez.shape.value, 0, 180, 60, 180, 60, True)
group.add_shape(sh)
group.add_shape(objects.Stroke(Color(0, 1, 0), 20))

script.script_main(an)
Exemplo n.º 7
0
    os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
                 "lib"))
from lottie.utils import script
from lottie import objects
from lottie.utils import animation as anutils
from lottie import Point, Color
from lottie.utils import ik

an = objects.Animation(180)

layer = objects.ShapeLayer()
an.add_layer(layer)

g = layer.add_shape(objects.Group())
b1 = g.add_shape(objects.Ellipse())
b1.size.value = Point(20, 20)
g.add_shape(objects.Fill(Color(1, 1, 0)))

g = layer.add_shape(objects.Group())
b2 = g.add_shape(objects.Ellipse())
b2.size.value = Point(20, 20)
g.add_shape(objects.Fill(Color(0, 1, 0)))

for i in range(an.out_point):
    t = i / (an.out_point - 1)
    p1 = Point(
        math.cos(t * math.pi * 2) / 2 + 1,
        math.sin(t * math.pi * 2) / 2 + 1) * 256
    b1.position.add_keyframe(i, p1)

    p2 = Point(
Exemplo n.º 8
0
    0,
    os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
                 "lib"))
from lottie.utils import script
from lottie import objects
from lottie.utils.animation import follow_path
from lottie import Point, Color

an = objects.Animation(180)

layer = objects.ShapeLayer()
an.add_layer(layer)

group = layer.add_shape(objects.Group())
ball = group.add_shape(objects.Ellipse())
ball.size.value = Point(10, 10)

r1 = group.add_shape(objects.Rect())
r1.size.value = Point(50, 10)

r2 = group.add_shape(objects.Group())
r2.add_shape(objects.Rect()).size.value = Point(50, 10)
r2 = r2.transform

group.add_shape(objects.Fill(Color(0, 1, 0)))

group = layer.add_shape(objects.Group())
bez = group.add_shape(objects.Path())
bez.shape.value.add_point(Point(256, 128), Point(0, 0), Point(64, 64))
bez.shape.value.add_point(Point(256, 256), Point(-64, -64), Point(-64, 64))
bez.shape.value.add_point(Point(256, 256 + 120), Point(0, 0), Point(0, 0))
sys.path.insert(
    0,
    os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
                 "lib"))
from lottie.utils import script
from lottie import objects
from lottie.utils import animation as anutils
from lottie import Point, Color

an = objects.Animation(60)

layer = objects.ShapeLayer()
an.add_layer(layer)

heart = objects.Bezier()
heart.add_point(Point(50, 20), Point(50, -20), Point(-50, -20))
heart.add_smooth_point(Point(0, 50), Point(-5, -10))
heart.add_smooth_point(Point(50, 100), Point(-10, 0))
heart.add_smooth_point(Point(100, 50), Point(-5, 10))
heart.closed = True

g1 = layer.add_shape(objects.Group())
shape = g1.add_shape(objects.Path())
shape.shape.value = heart
fill = layer.add_shape(objects.Fill(Color(1, 0, 0)))
stroke = layer.add_shape(objects.Stroke(Color(0, 0, 0), 5))

g2 = layer.add_shape(objects.Group())
bb = shape.bounding_box()
shapeb = g2.add_shape(objects.Path())
shapeb.shape.value.add_point(Point(bb.x1, bb.y1))
Exemplo n.º 10
0
    os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
    "lib"
))
from lottie.utils import script
from lottie import objects
from lottie import Point, Color

an = objects.Animation(59)

layer = objects.ShapeLayer()
an.add_layer(layer)


g1 = layer.add_shape(objects.Group())
circle = g1.add_shape(objects.Ellipse())
circle.size.value = Point(100, 100)
circle.position.value = Point(200, 100)
g1.add_shape(objects.Fill(Color(1, 0, 0)))
g1.add_shape(objects.Stroke(Color(0, 0, 0), 5))

g2 = layer.add_shape(objects.Group())
star = g2.add_shape(objects.Star())
star.inner_radius.value = 20
star.outer_radius.value = 50
star.position.value = Point(300, 100)
g2.add_shape(objects.Fill(Color(0, 1, 0)))
g2.add_shape(objects.Stroke(Color(0, 0, 0), 5))

g3 = layer.add_shape(objects.Group())
rect = g3.add_shape(objects.Rect())
rect.size.value = Point(100, 100)
Exemplo n.º 11
0
import os
sys.path.insert(0, os.path.join(
    os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
    "lib"
))
from lottie.utils import script
from lottie import objects
from lottie import Point, Color, NVector


last_frame = 180
an = objects.Animation(last_frame)


base = an.add_layer(objects.NullLayer())
base.transform.anchor_point.value = base.transform.position.value = Point(256, 256)
base.transform.rotation.add_keyframe(0, 0)
base.transform.rotation.add_keyframe(last_frame, 360)


star_layer = objects.ShapeLayer()
base.add_child(star_layer)
star = star_layer.add_shape(objects.Star())
star.inner_radius.value = 20
star.outer_radius.value = 50
star.position.value = Point(50, 50)
star_layer.add_shape(objects.Fill(Color(1, 1, 0)))
star_layer.add_shape(objects.Stroke(Color(0, 0, 0), 5))
star_layer.transform.anchor_point = star.position
star_layer.transform.position.value = Point(50, 256)
star_layer.transform.rotation.add_keyframe(0, 0)
Exemplo n.º 12
0
    0,
    os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
                 "lib"))
from lottie.utils import script
from lottie import objects, NVector
from lottie import Color, Point

an = objects.Animation(59)

layer = objects.ShapeLayer()
an.add_layer(layer)

g1 = layer.add_shape(objects.Group())

circle = g1.add_shape(objects.Ellipse())
circle.size.value = Point(100, 100)
circle.position.value = Point(128, 156)

fill = g1.add_shape(objects.GradientFill())
fill.start_point.value = Point(100, 0)
fill.end_point.value = Point(200, 0)
fill.colors.set_stops([(0, Color(1, 0, 0)), (1, Color(1, 1, 0))])

stroke = g1.add_shape(objects.GradientStroke(5))
stroke.start_point.value = Point(100, 0)
stroke.end_point.value = Point(200, 0)
stroke.colors.add_keyframe(0, [(0, Color(1, 0, 0)), (1, Color(1, 1, 0))])
stroke.colors.add_keyframe(10, [(0, Color(1, 1, 0)), (1, Color(0, 1, 0))])
stroke.colors.add_keyframe(30, [(0, Color(1, 0, 1)), (1, Color(0, 0, 1))])
stroke.colors.add_keyframe(59, [(0, Color(1, 0, 0)), (1, Color(1, 1, 0))])
stroke.colors.count = 2
Exemplo n.º 13
0
from lottie.utils import animation as anutils
from lottie import Point, Color

an = objects.Animation(60)

layer = objects.ShapeLayer()
an.add_layer(layer)
g = layer.add_shape(objects.Group())

sine_displacer = anutils.SineDisplacer(300, 50, 0, 60, 10, 1, 45)
# Keep the left side fixed
displacer = anutils.DisplacerDampener(sine_displacer, lambda p: p.x / 128 if p.x < 128 else 1)

for i in range(0, 512+1, 16):
    b = g.add_shape(objects.Ellipse())
    b.size.value = Point(16, 16)
    b.position.value = Point(i, 100)
    displacer.animate_point(b.position)


bez = g.add_shape(objects.Path())
bez.shape.value.add_smooth_point(Point(256, 200), Point(50, 0))
bez.shape.value.add_smooth_point(Point(156, 300), Point(0, -50))
bez.shape.value.add_smooth_point(Point(256, 400), Point(-50, 0))
bez.shape.value.add_smooth_point(Point(356, 300), Point(0, 50))
bez.shape.value.close()
bez.shape.value.split_self_chunks(8)
displacer.animate_bezier(bez.shape)

g.add_shape(objects.Fill(Color(1, 1, 0)))
Exemplo n.º 14
0
    g.add_shape(objects.Fill(color))
    return s


face1 = add_shape(objects.Ellipse(), Color(1, 1, 0), layer)
face2 = add_shape(objects.Ellipse(), Color(0, 1, 0), layer)

side = layer.add_shape(objects.Group())
side1 = add_shape(objects.Ellipse(), Color(1, 0, 0), side)
side2 = add_shape(objects.Ellipse(), Color(1, 0, 0), side)
sider = add_shape(objects.Rect(), Color(1, 0, 0), side)


width = 10

face1.size.add_keyframe(rot_time*0, Point(256, 256), easing.EaseIn())
face1.size.add_keyframe(rot_time*1, Point(0, 256))
face1.size.add_keyframe(rot_time*2, Point(0, 256))
face1.size.add_keyframe(rot_time*3, Point(0, 256), easing.EaseOut())
face1.size.add_keyframe(rot_time*4, Point(256, 256))
face1.position.add_keyframe(rot_time*0, Point(256, 256), easing.EaseIn())
face1.position.add_keyframe(rot_time*1, Point(256-width, 256))
face1.position.add_keyframe(rot_time*2, Point(256-width, 256))
face1.position.add_keyframe(rot_time*3, Point(256+width, 256), easing.EaseOut())
face1.position.add_keyframe(rot_time*4, Point(256, 256))


face2.size.add_keyframe(rot_time*0, Point(0, 256))
face2.size.add_keyframe(rot_time*1, Point(0, 256), easing.EaseOut())
face2.size.add_keyframe(rot_time*2, Point(256, 256), easing.EaseIn())
face2.size.add_keyframe(rot_time*3, Point(0, 256))
Exemplo n.º 15
0
from lottie.utils import script
from lottie import objects
from lottie import Point, Color

last_frame = 180
an = objects.Animation(last_frame)

layer = objects.ShapeLayer()
an.add_layer(layer)

group = layer.add_shape(objects.Group())

star = group.add_shape(objects.Star())
star.inner_radius.value = 40
star.outer_radius.value = 100
star.position.value = Point(256, 256)

star = group.add_shape(objects.Star())
star.inner_radius.value = 20
star.outer_radius.value = 50
star.position.value = Point(256, 256)

round = layer.add_shape(objects.RoundedCorners())
round.radius.add_keyframe(0, 0)
round.radius.add_keyframe(last_frame / 2, 30)
round.radius.add_keyframe(last_frame, 0)

stroke = group.add_shape(objects.Stroke(Color(1, 1, 0), 10))

script.script_main(an)
Exemplo n.º 16
0
    0,
    os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
                 "lib"))
from lottie.utils import script
from lottie import objects
from lottie import Point, Color

an = objects.Animation(60)

layer = objects.ShapeLayer()
an.add_layer(layer)

shapes = layer.add_shape(objects.Group())

circle = shapes.add_shape(objects.Ellipse())
circle.size.add_keyframe(0, Point(100, 100))
circle.size.add_keyframe(30, Point(50, 120))
circle.size.add_keyframe(60, Point(100, 100))
circle.position.add_keyframe(0, Point(220, 110))
circle.position.add_keyframe(20, Point(180, 110))
circle.position.add_keyframe(40, Point(220, 110))

star = shapes.add_shape(objects.Star())
star.inner_radius.add_keyframe(0, 20)
star.inner_radius.add_keyframe(30, 50)
star.inner_radius.add_keyframe(60, 20)
star.outer_radius.value = 50
#star.inner_roundness.value = 100
#star.outer_roundness.value = 40
star.rotation.value = 45
star.position.value = Point(330, 110)
Exemplo n.º 17
0
    "lib"
))
from lottie.utils import script
from lottie import objects
from lottie.utils.animation import spring_pull
from lottie import Point, Color


an = objects.Animation(100)

layer = objects.ShapeLayer()
an.add_layer(layer)

settings = [
    (Color(1,  1, 0), 128, 7),
    (Color(1,  0, 0), 256, 15),
    (Color(0, .5, 1), 384, 30),
]

for color, x, falloff in settings:
    group = layer.add_shape(objects.Group())
    ball = group.add_shape(objects.Ellipse())
    ball.size.value = Point(100, 100)
    group.add_shape(objects.Fill(color))
    group.transform.position.value = Point(x, -100)
    spring_pull(group.transform.position, Point(x, 256), 0, 60, falloff, 7)
    group.transform.position.add_keyframe(85, Point(x, -100))


script.script_main(an)
Exemplo n.º 18
0
from lottie import objects
from lottie import Point, Color


last_frame = 60
an = objects.Animation(last_frame)

layer = objects.ShapeLayer()
an.add_layer(layer)

group = layer.add_shape(objects.Group())

star = objects.Star()
star.inner_radius.value = 40
star.outer_radius.value = 100
star.position.value = Point(256, 256)
star.name = "big start"
group.add_shape(star)

star = objects.Star()
star.inner_radius.value = 20
star.outer_radius.value = 50
star.position.value = Point(256, 256)
star.name = "small start"
group.add_shape(star)

obj = objects.Path()
obj.shape.value.add_point(Point(10, 10))
obj.shape.value.add_point(Point(500, 10))
group.add_shape(obj)
Exemplo n.º 19
0
    (easing.Sigmoid(1 / 2), Color(0, 0, 1 / 2)),
    (easing.Sigmoid(1 / 3), Color(0, 0, 1 / 3)),
    (easing.Sigmoid(1 / 5), Color(0, 0, 1 / 5)),
    (easing.Sigmoid(1 / 10), Color(0, 0, 1 / 10)),
]
height = 512 / len(easings)
width = height

for i in range(len(easings)):
    group = layer.add_shape(objects.Group())

    rectgroup = group.add_shape(objects.Group())
    rect = rectgroup.add_shape(objects.Rect())
    rect.size.value = Size(width, height)
    y = i * height + height / 2
    group.transform.position.add_keyframe(0, Point(width / 2, y),
                                          easings[i][0])
    group.transform.position.add_keyframe(90, Point(512 - width / 2, y),
                                          easings[i][0])
    group.transform.position.add_keyframe(180, Point(width / 2, y),
                                          easings[i][0])
    rectgroup.add_shape(objects.Fill(easings[i][1]))

    bezgroup = group.insert_shape(0, objects.Group())
    bez = group.transform.position.keyframes[0].bezier()
    bezgroup.transform.scale.value = Size(100 * width, -100 * height)
    bezgroup.transform.position.value = Point(-width / 2, width / 2)
    bezgroup.add_shape(objects.Path()).shape.value = bez
    sc = Color(0, 0, 0) if easings[i][1].length == math.sqrt(3) else Color(
        1, 1, 1)
    bezgroup.add_shape(objects.Stroke(sc, 0.1))
Exemplo n.º 20
0
sys.path.insert(
    0,
    os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
                 "lib"))
from lottie.utils import script
from lottie import objects
from lottie import Point, Color
from lottie.utils import color

an = objects.Animation(59)

layer = objects.ShapeLayer()
an.add_layer(layer)

heart = objects.Bezier()
heart.add_point(Point(50, 20), Point(50, -20), Point(-50, -20))
heart.add_smooth_point(Point(0, 50), Point(-5, -10))
heart.add_smooth_point(Point(50, 100), Point(-10, 0))
heart.add_smooth_point(Point(100, 50), Point(-5, 10))
heart.closed = True
antiheart = (objects.Bezier().add_smooth_point(Point(50, 0), Point(
    10, 0)).add_smooth_point(Point(0, 50), Point(0, -20)).add_point(
        Point(50, 80), Point(-50, 20),
        Point(50, 20)).add_smooth_point(Point(100, 50), Point(0, 20)).close())

g1 = layer.add_shape(objects.Group())
g1.transform.position.value = Point(100, 200)
shape = g1.add_shape(objects.Path())
shape.shape.value = heart

g2 = layer.add_shape(objects.Group())
Exemplo n.º 21
0
#!/usr/bin/env python3
import sys
import os
sys.path.insert(
    0,
    os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
                 "lib"))
from lottie.utils import script
from lottie import objects
from lottie.parsers.svg import parse_svg_file
from lottie import Point

an = parse_svg_file(
    os.path.join(os.path.dirname(os.path.abspath(__file__)), "blep.svg"))

layer = an.find("durg")
layer.transform.anchor_point.value = Point(256, 256)
layer.transform.position.value = Point(256, 256)
layer.transform.rotation.add_keyframe(0, 0)
layer.transform.rotation.add_keyframe(30, 180)
layer.transform.rotation.add_keyframe(60, 360)

script.script_main(an)
Exemplo n.º 22
0
    os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
                 "lib"))
from lottie.utils import script
from lottie import objects
from lottie.utils import animation as anutils
from lottie import Point, Color, Point3D, Size

an = objects.Animation(120)

layer = objects.ShapeLayer()
an.add_layer(layer)

# Build a sphere out of circles
balls = []
axes = [
    Point(1, 0),
    Point(0, 1),
]
for i in range(20):
    a = i / 20 * math.pi * 2
    for axis in axes:
        g = layer.add_shape(objects.Group())
        b = g.add_shape(objects.Ellipse())
        b.size.value = Size(20, 20)
        xz = axis * math.sin(a) * 128
        pos = Point3D(256 + xz[0], 256 + math.cos(a) * 128, xz[1])
        b.position.value = pos
        balls.append(b)
        g.add_shape(objects.Fill(Color(0, 1, 0)))

# Animate the circles using depth rotation
Exemplo n.º 23
0
from lottie.utils import script
from lottie import objects
from lottie.objects import easing
from lottie import Point, Color, Size, PolarVector
from lottie.utils import animation as anutils


last_frame = 120
an = objects.Animation(last_frame)
layer = objects.ShapeLayer()
an.insert_layer(0, layer)

color1 = Color(1, 0.98, 0.282)
color2 = Color(1, 0.341, 0.016)
color3 = Color(0.698, 0.114, 0.02)
particle_start = Point(256, 256)
particle_size = Point(20, 20)
particle_end = Point(256, -particle_size.y*2)
start_len_min = 0
start_len_max = 128
opacity_start = 100
opacity_end = 20


def particle():
    g = layer.add_shape(objects.Group())
    b = g.add_shape(objects.Ellipse())
    fill = objects.Fill()
    g.add_shape(fill)
    t = random.random()
Exemplo n.º 24
0
sys.path.insert(
    0,
    os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
                 "lib"))
from lottie.utils import script
from lottie import objects
from lottie.parsers.svg import parse_svg_file
from lottie import Point, Color

an = parse_svg_file(
    os.path.join(os.path.dirname(os.path.abspath(__file__)), "blep.svg"))

maskshape = objects.Star()
maskshape.inner_radius.value = 100
maskshape.outer_radius.value = 200
maskshape.rotation.value = 180
maskshape.position.value = Point(256, 256)
#maskshape.size.value = Point(256, 256)
maskbez = maskshape.to_bezier()

mask = objects.Mask(maskbez.shape.value)
an.layers[0].masks = [mask]

g = an.layers[0].add_shape(objects.Group())
r = g.add_shape(objects.Rect())
r.position.value = Point(256, 256)
r.size.value = Point(512, 512)
g.add_shape(objects.Fill(Color(1, 1, 1)))

script.script_main(an)
Exemplo n.º 25
0
sys.path.insert(
    0,
    os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
                 "lib"))
from lottie.utils import script
from lottie import objects
from lottie.utils.animation import shake, rot_shake
from lottie import Point, Color

an = objects.Animation(59)

layer = objects.ShapeLayer()
an.add_layer(layer)

circle = layer.add_shape(objects.Ellipse())
circle.size.value = Point(100, 100)
circle.position.value = Point(256, 128)

shake(circle.position, 10, 15, 0, 59, 25)

g = layer.add_shape(objects.Group())
box = g.add_shape(objects.Rect())
box.size.value = Point(200, 100)
g.transform.anchor_point.value = g.transform.position.value = box.position.value = Point(
    256, 384)
rot_shake(g.transform.rotation, Point(-15, 15), 0, 60, 10)

layer.add_shape(objects.Fill(Color(1, 1, 0)))

script.script_main(an)
Exemplo n.º 26
0
sys.path.insert(0, os.path.join(
    os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
    "lib"
))
from lottie.utils import script
from lottie import objects
from lottie import Point, Color


an = objects.Animation(59)

layer = objects.ShapeLayer()
an.add_layer(layer)

circle = layer.add_shape(objects.Ellipse())
circle.size.value = Point(100, 100)
circle.position.add_keyframe(0, Point(0, 256))
circle.position.add_keyframe(20, Point(256, 256))
circle.position.add_keyframe(40, Point(256, 0))
circle.position.add_keyframe(60, Point(0, 256))


fill = layer.add_shape(objects.Fill(Color(1, 1, 0)))
fill.opacity.add_keyframe(0, 100)
fill.opacity.add_keyframe(30, 10)
fill.opacity.add_keyframe(60, 100)


script.script_main(an)

Exemplo n.º 27
0
#!/usr/bin/env python3
"""
@note Text layers are not supported by telegram
"""
import sys
import os
sys.path.insert(
    0,
    os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
                 "lib"))
from lottie.utils import script
from lottie import objects
from lottie import Color, Point

an = objects.Animation(120)
an.fonts = objects.text.FontList()
an.fonts.append(objects.text.Font("sans", name="sans"))
layer = objects.TextLayer()
an.add_layer(layer)

layer.data.add_keyframe(
    0, objects.text.TextDocument("Text", 200, Color(1, 0, 0), "sans"))
layer.data.add_keyframe(
    60, objects.text.TextDocument("Here", 200, Color(0, 1, 0), "sans"))
layer.transform.position.value = Point(30, 200)

script.script_main(an)