Core Objects¶
keyed.base
¶
Base classes for drawable stuff.
Lifetime
¶
Represents the lifespan of a drawable object in an animation.
An object will only be drawn if the current frame is within the specified start and end frames.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
start
|
float | None
|
The start frame of the lifetime. Defaults to negative infinity if not provided. |
None
|
end
|
float | None
|
The end frame of the lifetime. Defaults to positive infinity if not provided. |
None
|
Attributes:
Name | Type | Description |
---|---|---|
start |
The starting frame of the object's lifetime. |
|
end |
The ending frame of the object's lifetime. |
Source code in src/keyed/base.py
Base
¶
Bases: Transformable
Base class for drawable objects in an animation scene.
Attributes:
Name | Type | Description |
---|---|---|
scene |
Scene
|
The scene to which the object belongs. |
lifetime |
Lifetime
|
The lifetime of the object. |
Source code in src/keyed/base.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 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 |
|
draw
¶
emphasize
¶
emphasize(buffer=5, radius=0, fill_color=(1, 1, 1), color=(1, 1, 1), alpha=1, dash=None, line_width=2, draw_fill=True, draw_stroke=True, operator=OPERATOR_SCREEN)
Emphasize the object by drawing a rectangle around it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buffer
|
float
|
The buffer distance around the object's geometry for the emphasis. |
5
|
radius
|
float
|
The corner radius of the emphasized area. |
0
|
fill_color
|
tuple[float, float, float]
|
The fill color of the emphasis as an RGB tuple. |
(1, 1, 1)
|
color
|
tuple[float, float, float]
|
The stroke color of the emphasis as an RGB tuple. |
(1, 1, 1)
|
alpha
|
float
|
The alpha transparency of the emphasis. |
1
|
dash
|
tuple[Sequence[float], float] | None
|
The dash pattern for the emphasis outline. Default is solid line. |
None
|
line_width
|
float
|
The line width of the emphasis outline. |
2
|
draw_fill
|
bool
|
Whether to draw the fill of the emphasis. |
True
|
draw_stroke
|
bool
|
Whether to draw the stroke of the emphasis. |
True
|
operator
|
Operator
|
The compositing operator to use for drawing the emphasis. |
OPERATOR_SCREEN
|
Returns:
Type | Description |
---|---|
Rectangle
|
A Rectangle object representing the emphasized area around the original object. |
Notes
This creates a Rectangle instance and sets up dynamic expressions to follow the geometry of the object as it changes through different frames, applying the specified emphasis effects. Emphasis should generally be applied after all animations on the original object have been added.
Source code in src/keyed/base.py
set
¶
set(property, value, frame=ALWAYS)
Set a property of the object at a specific frame.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
property
|
str
|
The name of the property to set. |
required |
value
|
Any
|
The new value for the property. |
required |
frame
|
int
|
The frame at which the property value should be set. |
ALWAYS
|
Returns:
Type | Description |
---|---|
Self
|
Self |
See Also
Source code in src/keyed/base.py
set_literal
¶
center
¶
center(frame=ALWAYS)
fade
¶
fade(value, start, end, ease=linear_in_out)
Control the object's alpha parameter to fade it in or out.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
HasValue[float]
|
Value to set alpha to. |
required |
start
|
int
|
Frame to start changing alpha. |
required |
end
|
int
|
Frame to finish changing alpha. |
required |
ease
|
EasingFunctionT
|
Easing function |
linear_in_out
|
Returns:
Type | Description |
---|---|
Self
|
Self |
Source code in src/keyed/base.py
line_to
¶
Create a line connecting this object to another object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other
|
Base
|
The target object to connect to |
required |
self_direction
|
Direction
|
Direction for the connection point on this object |
RIGHT
|
other_direction
|
Direction
|
Direction for the connection point on the target object |
LEFT
|
**line_kwargs
|
Any
|
Additional arguments to pass to the Line constructor. |
{}
|
Returns:
Type | Description |
---|---|
'Line'
|
The created Line object |
Source code in src/keyed/base.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 |
Source code in src/keyed/transforms.py
is_visible
¶
keyed.group
¶
A class for manipulating groups of things.
Group
¶
A sequence of drawable objects, allowing collective transformations and animations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
iterable
|
Iterable[T]
|
An iterable of drawable objects. |
tuple()
|
Source code in src/keyed/group.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 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 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 |
|
scene
property
¶
Returns the scene associated with the first object in the group.
Raises:
Type | Description |
---|---|
ValueError
|
If the group is empty and the scene cannot be retrieved. |
frame
property
¶
Returns the frame associated with the first object in the group.
Raises:
Type | Description |
---|---|
ValueError
|
If the group is empty and the frame cannot be retrieved. |
geom
property
¶
Return a reactive value of the geometry.
Returns:
Type | Description |
---|---|
Computed[GeometryCollection[BaseGeometry]]
|
A reactive value of the geometry. |
draw
¶
set
¶
Set a property to a new value for all objects in the group at the specified frame.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
property
|
str
|
The name of the property to set. |
required |
value
|
Any
|
The value to set it to. |
required |
frame
|
int
|
The frame at which to set the value. |
0
|
Returns:
Type | Description |
---|---|
Self
|
Self |
See Also
Source code in src/keyed/group.py
set_literal
¶
Overwrite a property to a new value for all objects in the group.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
property
|
str
|
The name of the property to set. |
required |
value
|
Any
|
Value to set to. |
required |
Returns:
Type | Description |
---|---|
Self
|
Self |
See Also
Source code in src/keyed/group.py
write_on
¶
Sequentially animates a property across all objects in the group.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
property
|
str
|
The property to animate. |
required |
animator
|
The animation function to apply, which should create an Animation.
See :func: |
required | |
start
|
int
|
The frame at which the first animation should start. |
required |
delay
|
int
|
The delay in frames before starting the next object's animation. |
required |
duration
|
int
|
The duration of each object's animation in frames. |
required |
Source code in src/keyed/group.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/group.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 |
Source code in src/keyed/group.py
distribute
¶
distribute(direction=ORIGIN, start=ALWAYS, end=ALWAYS, easing=cubic_in_out, x=True, y=True)
Distribute objects evenly between the first and last objects in the group.
This keeps the first and last objects in their initial positions and distributes the remaining objects in between with equal spacing.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
direction
|
Direction
|
Direction used to get anchor points on objects |
ORIGIN
|
start
|
int
|
Starting frame for the animation |
ALWAYS
|
end
|
int
|
Ending frame for the animation |
ALWAYS
|
easing
|
EasingFunctionT
|
Easing function to use |
cubic_in_out
|
x
|
bool
|
Whether to distribute along the x-axis |
True
|
y
|
bool
|
Whether to distribute along the y-axis |
True
|
Returns:
Type | Description |
---|---|
Self
|
self |
Source code in src/keyed/group.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
emphasize
¶
emphasize(buffer=5, radius=0, fill_color=(1, 1, 1), color=(1, 1, 1), alpha=1, dash=None, line_width=2, draw_fill=True, draw_stroke=True, operator=OPERATOR_SCREEN)
Emphasize the object by drawing a rectangle around it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buffer
|
float
|
The buffer distance around the object's geometry for the emphasis. |
5
|
radius
|
float
|
The corner radius of the emphasized area. |
0
|
fill_color
|
tuple[float, float, float]
|
The fill color of the emphasis as an RGB tuple. |
(1, 1, 1)
|
color
|
tuple[float, float, float]
|
The stroke color of the emphasis as an RGB tuple. |
(1, 1, 1)
|
alpha
|
float
|
The alpha transparency of the emphasis. |
1
|
dash
|
tuple[Sequence[float], float] | None
|
The dash pattern for the emphasis outline. Default is solid line. |
None
|
line_width
|
float
|
The line width of the emphasis outline. |
2
|
draw_fill
|
bool
|
Whether to draw the fill of the emphasis. |
True
|
draw_stroke
|
bool
|
Whether to draw the stroke of the emphasis. |
True
|
operator
|
Operator
|
The compositing operator to use for drawing the emphasis. |
OPERATOR_SCREEN
|
Returns:
Type | Description |
---|---|
Rectangle
|
A Rectangle object representing the emphasized area around the original object. |
Notes
This creates a Rectangle instance and sets up dynamic expressions to follow the geometry of the object as it changes through different frames, applying the specified emphasis effects. Emphasis should generally be applied after all animations on the original object have been added.
Source code in src/keyed/base.py
center
¶
center(frame=ALWAYS)
line_to
¶
Create a line connecting this object to another object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other
|
Base
|
The target object to connect to |
required |
self_direction
|
Direction
|
Direction for the connection point on this object |
RIGHT
|
other_direction
|
Direction
|
Direction for the connection point on the target object |
LEFT
|
**line_kwargs
|
Any
|
Additional arguments to pass to the Line constructor. |
{}
|
Returns:
Type | Description |
---|---|
'Line'
|
The created Line object |