@@ -341,9 +341,9 @@ async def interpolate_scalar(self, start, end, *, duration, step=0, transition=_
341
341
.. versionadded:: 0.5.2
342
342
'''
343
343
344
- async def interpolate_sequence (self , start , end , * , duration , step = 0 , transition = _linear , output_type = tuple ) -> AsyncIterator :
344
+ async def interpolate_sequence (self , start , end , * , duration , step = 0 , transition = _linear ) -> AsyncIterator :
345
345
'''
346
- Same as :meth:`interpolate_scalar` except this one is for sequence type .
346
+ Same as :meth:`interpolate_scalar` except this one is for sequence types .
347
347
348
348
.. code-block::
349
349
@@ -353,37 +353,37 @@ async def interpolate_sequence(self, start, end, *, duration, step=0, transition
353
353
============ ==========
354
354
elapsed time output
355
355
============ ==========
356
- 0 ( 0, 50)
357
- 30 ( 30, 65)
358
- 60 ( 60, 80)
359
- 90 ( 90, 95)
360
- **120** ( 100, 100)
356
+ 0 [ 0, 50]
357
+ 30 [ 30, 65]
358
+ 60 [ 60, 80]
359
+ 90 [ 90, 95]
360
+ **120** [ 100, 100]
361
361
============ ==========
362
362
'''
363
363
zip_ = zip
364
- slope = tuple ( end_elem - start_elem for end_elem , start_elem in zip_ (end , start ))
364
+ slope = [ end_elem - start_elem for end_elem , start_elem in zip_ (end , start )]
365
365
366
366
p = transition (0. )
367
- yield output_type ( p * slope_elem + start_elem for slope_elem , start_elem in zip_ (slope , start ))
367
+ yield [ p * slope_elem + start_elem for slope_elem , start_elem in zip_ (slope , start )]
368
368
369
369
if duration :
370
370
async for p in self .anim_with_ratio (step = step , base = duration ):
371
371
if p >= 1.0 :
372
372
break
373
373
p = transition (p )
374
- yield output_type ( p * slope_elem + start_elem for slope_elem , start_elem in zip_ (slope , start ))
374
+ yield [ p * slope_elem + start_elem for slope_elem , start_elem in zip_ (slope , start )]
375
375
else :
376
376
await self .sleep (0 )
377
377
378
378
p = transition (1. )
379
- yield output_type ( p * slope_elem + start_elem for slope_elem , start_elem in zip_ (slope , start ))
379
+ yield [ p * slope_elem + start_elem for slope_elem , start_elem in zip_ (slope , start )]
380
380
381
381
interpolate_seq = interpolate_sequence
382
382
'''
383
383
An alias for :meth:`interpolate_sequence`.
384
384
'''
385
385
386
- def _update (setattr , zip , min , obj , duration , transition , output_seq_type , anim_params , task , p_time , dt ):
386
+ def _update (setattr , zip , min , obj , duration , transition , anim_params , task , p_time , dt ):
387
387
time = p_time [0 ] + dt
388
388
p_time [0 ] = time
389
389
@@ -394,10 +394,10 @@ def _update(setattr, zip, min, obj, duration, transition, output_seq_type, anim_
394
394
# apply progression on obj
395
395
for attr_name , org_value , slope , is_seq in anim_params :
396
396
if is_seq :
397
- new_value = output_seq_type (
397
+ new_value = [
398
398
slope_elem * t + org_elem
399
399
for org_elem , slope_elem in zip (org_value , slope )
400
- )
400
+ ]
401
401
setattr (obj , attr_name , new_value )
402
402
else :
403
403
setattr (obj , attr_name , slope * t + org_value )
@@ -410,26 +410,26 @@ def _update(setattr, zip, min, obj, duration, transition, output_seq_type, anim_
410
410
411
411
@types .coroutine
412
412
def _anim_attrs (
413
- self , obj , duration , step , transition , output_seq_type , animated_properties ,
413
+ self , obj , duration , step , transition , animated_properties ,
414
414
getattr = getattr , isinstance = isinstance , tuple = tuple , partial = partial , native_seq_types = (tuple , list ),
415
415
zip = zip , _update = _update ,
416
416
_current_task = _current_task , _sleep_forever = _sleep_forever , / ):
417
417
# get current values & calculate slopes
418
- anim_params = tuple (
418
+ anim_params = [
419
419
(
420
420
org_value := getattr (obj , attr_name ),
421
421
is_seq := isinstance (org_value , native_seq_types ),
422
422
(
423
423
org_value := tuple (org_value ),
424
- slope := tuple ( goal_elem - org_elem for goal_elem , org_elem in zip (goal_value , org_value )) ,
424
+ slope := [ goal_elem - org_elem for goal_elem , org_elem in zip (goal_value , org_value )] ,
425
425
) if is_seq else (slope := goal_value - org_value ),
426
426
) and (attr_name , org_value , slope , is_seq , )
427
427
for attr_name , goal_value in animated_properties .items ()
428
- )
428
+ ]
429
429
430
430
try :
431
431
event = self .schedule_interval (
432
- partial (_update , obj , duration , transition , output_seq_type , anim_params , (yield _current_task )[0 ][0 ], [0 , ]),
432
+ partial (_update , obj , duration , transition , anim_params , (yield _current_task )[0 ][0 ], [0 , ]),
433
433
step ,
434
434
)
435
435
yield _sleep_forever
@@ -438,8 +438,7 @@ def _anim_attrs(
438
438
439
439
del _update
440
440
441
- def anim_attrs (self , obj , * , duration , step = 0 , transition = _linear , output_seq_type = tuple ,
442
- ** animated_properties ) -> Awaitable :
441
+ def anim_attrs (self , obj , * , duration , step = 0 , transition = _linear , ** animated_properties ) -> Awaitable :
443
442
'''
444
443
Animates attibutes of any object.
445
444
@@ -449,22 +448,14 @@ def anim_attrs(self, obj, *, duration, step=0, transition=_linear, output_seq_ty
449
448
450
449
obj = types.SimpleNamespace(x=0, size=(200, 300))
451
450
await clock.anim_attrs(obj, x=100, size=(400, 400), duration=2)
452
-
453
- The ``output_seq_type`` parameter.
454
-
455
- .. code-block::
456
-
457
- obj = types.SimpleNamespace(size=(200, 300))
458
- await clock.anim_attrs(obj, size=(400, 400), duration=2, output_seq_type=list)
459
- assert type(obj.size) is list
460
451
'''
461
- return self ._anim_attrs (obj , duration , step , transition , output_seq_type , animated_properties )
452
+ return self ._anim_attrs (obj , duration , step , transition , animated_properties )
462
453
463
- def anim_attrs_abbr (self , obj , * , d , s = 0 , t = _linear , output_seq_type = tuple , ** animated_properties ) -> Awaitable :
454
+ def anim_attrs_abbr (self , obj , * , d , s = 0 , t = _linear , ** animated_properties ) -> Awaitable :
464
455
'''
465
456
:meth:`anim_attrs` cannot animate attributes named ``step``, ``duration`` and ``transition`` but this one can.
466
457
'''
467
- return self ._anim_attrs (obj , d , s , t , output_seq_type , animated_properties )
458
+ return self ._anim_attrs (obj , d , s , t , animated_properties )
468
459
469
460
470
461
class _repeat_sleeping :
0 commit comments