Output
Movies made of several scenes and the transitions between them.
Contents:
k.movie: Composes several scenes into a single output, with one transition per join (k.cutwhen omitted).k.Movie: Composes several scenes into a single output, with one transition per join (k.cutwhen omitted).k.cut: Hard-cut transition between two scenes of ak.movie(the default).k.crossfade: Transition in which the end of one scene dissolves into the start of the next, overdurationseconds.k.morph_cut: Transition in which objects with the samekey=in neighboring scenes travel across the cut.
Back to the reference index.
k.movie (function)#
k.movie(
scenes: Sequence[SceneDef],
transitions: Sequence[Transition] = (),
*,
name: str = "movie",
) -> Movie
Composes several scenes into a single output, with one transition per join (k.cut when omitted). kinemo render renders the movie as a single video.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
scenes |
Sequence[SceneDef] |
required | |
transitions |
Sequence[Transition] |
() |
k.movie([intro, pythagoras], transitions=[k.crossfade(0.5)]). |
name |
str |
"movie" |
Example:
@k.scene
def intro(s: k.Scene):
s.play(k.write(k.Text("Chapter 1").place(at="center")))
@k.scene
def body(s: k.Scene):
s.play(k.draw(k.Circle(r=1.5).place(at="center")))
movie = k.movie([intro, body], transitions=[k.crossfade(0.5)])
See also: k.crossfade, k.cut, k.morph_cut.
k.Movie (class)#
k.Movie(
scenes: list[SceneDef],
transitions: list[Transition] = <factory>,
name: str = "movie",
)
Documented together with k.movie. Composes several scenes into a single output, with one transition per join (k.cut when omitted). kinemo render renders the movie as a single video.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
scenes |
list[SceneDef] |
required | |
transitions |
list[Transition] |
<factory> |
|
name |
str |
"movie" |
Members:
build: Build every scene of the movie.render: Render the movie to one video file, joining scenes with their transitions.
k.Movie.build (method)
movie.build(params: dict[str, object] | None = None) -> list[Scene]
Build every scene of the movie.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
params |
dict[str, object] | None |
None |
k.Movie.render (method)
movie.render(
path: str,
format: str = "mp4",
quality: str = "final",
progress: Callable[[int, int], object] | None = None,
)
Render the movie to one video file, joining scenes with their transitions.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
path |
str |
required | |
format |
str |
"mp4" |
|
quality |
str |
"final" |
|
progress |
Callable[[int, int], object] | None |
None |
k.cut (value)#
k.cut: Transition = Transition(kind='cut', duration=0.0)
Hard-cut transition between two scenes of a k.movie (the default).
Example:
@k.scene
def before(s: k.Scene):
s.play(k.write(k.Text("Before").place(at="center")))
@k.scene
def after(s: k.Scene):
s.play(k.write(k.Text("After").place(at="center")))
movie = k.movie([before, after], transitions=[k.cut])
See also: k.movie, k.crossfade.
k.crossfade (function)#
k.crossfade(duration: float = 0.5) -> Transition
Transition in which the end of one scene dissolves into the start of the next, over duration seconds.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
duration |
float |
0.5 |
Transition in which the end of one scene dissolves into the start of the next, over duration seconds. |
Example: same as k.movie.
See also: k.movie, k.cut, k.morph_cut.
k.morph_cut (function)#
k.morph_cut(duration: float = 0.5) -> Transition
Transition in which objects with the same key= in neighboring scenes travel across the cut.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
duration |
float |
0.5 |
Example:
@k.scene
def one(s: k.Scene):
s.play(k.draw(k.Circle(r=1, key="sun").place(at="left", margin=3)))
@k.scene
def two(s: k.Scene):
s.play(k.draw(k.Circle(r=1, key="sun").place(at="right", margin=3)))
movie = k.movie([one, two], transitions=[k.morph_cut(0.8)])
See also: k.movie, k.crossfade.