Scene¶
keyed.scene
¶
The core Scene object upon which objects are drawn/animated.
Layer
¶
Bases: Freezeable
Source code in src/keyed/scene.py
rasterize
¶
Be sure to pass frame to have proper caching behavior.
Source code in src/keyed/scene.py
Scene
¶
Bases: Transformable
, Freezeable
A scene within which graphical objects are placed and manipulated.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scene_name
|
str | None
|
The name of the scene, used for naming output directories and files. |
None
|
num_frames
|
int
|
The number of frames to render in the scene. |
60
|
output_dir
|
Path
|
The directory path where output files will be stored. |
Path('media')
|
width
|
int
|
The width of the scene in pixels. |
3840
|
height
|
int
|
The height of the scene in pixels. |
2160
|
antialias
|
Antialias
|
The antialiasing level for rendering the scene. |
ANTIALIAS_DEFAULT
|
freehand
|
bool
|
Indicates whether to enable freehand drawing mode. |
False
|
Source code in src/keyed/scene.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 |
|
full_output_dir
property
¶
nx
¶
ny
¶
add
¶
Add one or more graphical objects to the scene.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
content
|
Base
|
One or more Base-derived objects to be added to the scene. |
()
|
clear
¶
Clear the drawing surface of the scene.
delete_old_frames
¶
draw
¶
Draw the scene by rendering it to images.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
layers
|
Sequence[int] | None
|
Specific layer(s) to render. If None, all layers are rendered. |
None
|
delete
|
bool
|
Whether to delete old frames before drawing new ones. |
True
|
open_dir
|
bool
|
Whether to open the output directory after drawing. |
False
|
Source code in src/keyed/scene.py
draw_as_layers
¶
Draw each layer of the scene separately.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
open_dir
|
bool
|
Whether to open the output directory after drawing. Default is False. |
False
|
Source code in src/keyed/scene.py
asarray
¶
Convert a frame of the scene to a NumPy array.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
frame
|
int
|
The frame number to convert. |
0
|
layers
|
Sequence[int] | None
|
Specific layer(s) to convert. If None, all layers are converted. |
None
|
Returns:
Type | Description |
---|---|
ndarray
|
A NumPy array representing the raster image of the specified frame. |
Source code in src/keyed/scene.py
find
¶
Find the nearest object on the canvas to the given x, y coordinates.
For composite objects, this will return the most atomic object possible. Namely, if a user clicks on Code, which itself contains Lines, Tokens, and Chars (Text), this method will return the nearest Text.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
HasValue[float]
|
The x-coordinate to check. |
required |
y
|
HasValue[float]
|
The y-coordinate to check. |
required |
frame
|
int
|
The frame number to check against. Default is 0. |
0
|
Returns:
Type | Description |
---|---|
Base | None
|
The nearest object if found; otherwise, None. |
Source code in src/keyed/scene.py
preview
¶
Preview the scene in a window with specified frame rate.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
frame_rate
|
int
|
The frame rate at which to preview the animation. Default is 24 fps. |
24
|
Source code in src/keyed/scene.py
get_context
¶
Get the drawing context for the scene.
Returns:
Type | Description |
---|---|
Context[SVGSurface] | FreeHandContext
|
The context to use for drawing. |
Source code in src/keyed/scene.py
rotate
¶
rotate(amount, start=ALWAYS, end=ALWAYS, easing=cubic_in_out, center=None, direction=ORIGIN)
Rotate the object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
amount
|
HasValue[float]
|
Amount to rotate by. |
required |
start
|
int
|
The frame to start rotating. |
ALWAYS
|
end
|
int
|
The frame to end rotating. |
ALWAYS
|
easing
|
EasingFunctionT
|
The easing function to use. |
cubic_in_out
|
center
|
ReactiveValue[GeometryT] | None
|
The object around which to rotate. |
None
|
direction
|
Direction
|
The relative critical point of the center. |
ORIGIN
|
Returns:
Type | Description |
---|---|
Self
|
self |
Source code in src/keyed/transforms.py
scale
¶
scale(amount, start=ALWAYS, end=ALWAYS, easing=cubic_in_out, center=None, direction=ORIGIN)
Scale the object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
amount
|
HasValue[float]
|
Amount to scale by. |
required |
start
|
int
|
The frame to start scaling. |
ALWAYS
|
end
|
int
|
The frame to end scaling. |
ALWAYS
|
easing
|
EasingFunctionT
|
The easing function to use. |
cubic_in_out
|
center
|
ReactiveValue[GeometryT] | None
|
The object around which to rotate. |
None
|
direction
|
Direction
|
The relative critical point of the center. |
ORIGIN
|
Returns:
Type | Description |
---|---|
Self
|
self |
Source code in src/keyed/transforms.py
translate
¶
translate(x=0, y=0, start=ALWAYS, end=ALWAYS, easing=cubic_in_out)
Translate the object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
HasValue[float]
|
x offset. |
0
|
y
|
HasValue[float]
|
y offset. |
0
|
start
|
int
|
The frame to start translating. |
ALWAYS
|
end
|
int
|
The frame to end translating. |
ALWAYS
|
easing
|
EasingFunctionT
|
The easing function to use. |
cubic_in_out
|
Source code in src/keyed/transforms.py
move_to
¶
move_to(x=None, y=None, start=ALWAYS, end=ALWAYS, easing=cubic_in_out, center=None, direction=ORIGIN)
Move object to absolute coordinates.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
HasValue[float] | None
|
Destination x coordinate |
None
|
y
|
HasValue[float] | None
|
Destination y coordinate |
None
|
start
|
int
|
Starting frame, by default ALWAYS |
ALWAYS
|
end
|
int
|
Ending frame, by default ALWAYS |
ALWAYS
|
easing
|
EasingFunctionT
|
Easing function, by default cubic_in_out |
cubic_in_out
|
Returns:
Type | Description |
---|---|
Self
|
Self |
Source code in src/keyed/transforms.py
align_to
¶
align_to(to, start=ALWAYS, lock=None, end=ALWAYS, from_=None, easing=cubic_in_out, direction=ORIGIN, center_on_zero=False)
Align the object to another object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
to
|
Transformable
|
The object to align to. |
required |
start
|
int
|
Start of animation (begin aligning to the object). |
ALWAYS
|
end
|
int
|
End of animation (finish aligning to the object at this frame, and then stay there). |
ALWAYS
|
from_
|
ReactiveValue[GeometryT] | None
|
Use this object as self when doing the alignment. This is helpful for code animations. It is sometimes desirable to align, say, the top-left edge of one character in a TextSelection to the top-left of another character. |
None
|
easing
|
EasingFunctionT
|
The easing function to use. |
cubic_in_out
|
direction
|
Direction
|
The critical point of to and from_to use for the alignment. |
ORIGIN
|
center_on_zero
|
bool
|
If true, align along the "0"-valued dimensions. Otherwise, only align to on non-zero directions. This is beneficial for, say, centering the object at the origin (which has a vector that consists of two zeros). |
False
|
Returns:
Type | Description |
---|---|
Self
|
self |
Source code in src/keyed/transforms.py
lock_on
¶
Lock on to a target.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target
|
Transformable
|
Object to lock onto |
required |
reference
|
ReactiveValue[GeometryT] | None
|
Measure from this object. This is useful for TextSelections, where you want to align to a particular character in the selection. |
None
|
start
|
int
|
When to start locking on. |
ALWAYS
|
end
|
int
|
When to end locking on. |
-ALWAYS
|
x
|
bool
|
If true, lock on in the x dimension. |
True
|
y
|
bool
|
If true, lock on in the y dimension. |
True
|
Source code in src/keyed/transforms.py
lock_on2
¶
lock_on2(target, reference=None, direction=ORIGIN, x=True, y=True)
Lock on to a target.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target
|
Transformable
|
Object to lock onto |
required |
reference
|
ReactiveValue[GeometryT] | None
|
Measure from this object. This is useful for TextSelections, where you want to align to a particular character in the selection. |
None
|
x
|
bool
|
If true, lock on in the x dimension. |
True
|
y
|
bool
|
if true, lock on in the y dimension. |
True
|
Source code in src/keyed/transforms.py
shear
¶
shear(angle_x=0, angle_y=0, start=ALWAYS, end=ALWAYS, easing=cubic_in_out, center=None)
Shear the object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
angle_x
|
HasValue[float]
|
Angle (in degrees) to shear by along x direction. |
0
|
angle_y
|
HasValue[float]
|
Angle (in degrees) to shear by along x direction. |
0
|
start
|
int
|
The frame to start scaling. |
ALWAYS
|
end
|
int
|
The frame to end scaling. |
ALWAYS
|
easing
|
EasingFunctionT
|
The easing function to use. |
cubic_in_out
|
center
|
ReactiveValue[GeometryT] | None
|
The object around which to rotate. |
None
|
Returns:
Type | Description |
---|---|
Self
|
self |
Source code in src/keyed/transforms.py
stretch
¶
stretch(scale_x=1, scale_y=1, start=ALWAYS, end=ALWAYS, easing=cubic_in_out, center=None, direction=ORIGIN)
Stretch the object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scale_x
|
HasValue[float]
|
Amount to scale by in x direction. |
1
|
scale_y
|
HasValue[float]
|
Amount to scale by in y direction. |
1
|
start
|
int
|
The frame to start scaling. |
ALWAYS
|
end
|
int
|
The frame to end scaling. |
ALWAYS
|
easing
|
EasingFunctionT
|
The easing function to use. |
cubic_in_out
|
center
|
ReactiveValue[GeometryT] | None
|
The object around which to rotate. |
None
|
direction
|
Direction
|
The relative critical point of the center. |
ORIGIN
|
Returns:
Type | Description |
---|---|
Self
|
self |
Source code in src/keyed/transforms.py
next_to
¶
next_to(to, start=ALWAYS, end=ALWAYS, easing=cubic_in_out, offset=10.0, direction=LEFT)
Align the object to another object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
to
|
Transformable
|
The object to align to. |
required |
start
|
int
|
Start of animation (begin aligning to the object). |
ALWAYS
|
end
|
int
|
End of animation (finish aligning to the object at this frame, and then stay there). |
ALWAYS
|
easing
|
EasingFunctionT
|
The easing function to use. |
cubic_in_out
|
offset
|
HasValue[float]
|
Distance between objects (in pixels). |
10.0
|
direction
|
Direction
|
The critical point of to and from_to use for the alignment. |
LEFT
|
Returns:
Type | Description |
---|---|
Self
|
self |