-
Notifications
You must be signed in to change notification settings - Fork 0
/
obs_tween.py
/
obs_tween.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
#!/usr/bin/env python3
"""
OBS-TWEEN (https://github.com/MarioMey/obs-osc-pythonscript)
SceneItem position, scale, size and rotation interpolated transformation,
and source properties values change on-the-fly with duration, delay and ease type.
(ease equations taken from https://github.com/semitable/easing-functions)
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
"""
__author__ = "Mario Mey"
__contact__ = "[email protected]"
__credits__ = []
__date__ = "2021/08/13"
__deprecated__ = False
__license__ = "GPLv3"
__maintainer__ = "developer"
__status__ = "Production"
__version__ = "0.3"
import obspython as obs
import random, time, string, json, math
from contextlib import contextmanager
from easing_functions import (
LinearInOut,
QuadEaseInOut,
QuadEaseIn,
QuadEaseOut,
CubicEaseInOut,
CubicEaseIn,
CubicEaseOut,
QuarticEaseInOut,
QuarticEaseIn,
QuarticEaseOut,
QuinticEaseInOut,
QuinticEaseIn,
QuinticEaseOut,
SineEaseInOut,
SineEaseIn,
SineEaseOut,
CircularEaseIn,
CircularEaseInOut,
CircularEaseOut,
ExponentialEaseInOut,
ExponentialEaseIn,
ExponentialEaseOut,
ElasticEaseIn,
ElasticEaseInOut,
ElasticEaseOut,
BackEaseIn,
BackEaseInOut,
BackEaseOut,
BounceEaseIn,
BounceEaseInOut,
BounceEaseOut,
)
try:
from obs_api import (
th, c1, c2, c3, c4, c,
consola, thread, globalDict,
tobool, toint, tolist, tofloat,
)
import obs_api
except:
from obs_osc_api import(
th, c1, c2, c3, c4, c,
consola, thread, globalDict,
tobool, toint, tolist, tofloat
)
from contextlib import contextmanager, ExitStack
def get_scene_context(scene_name):
scenes_list = obs.obs_frontend_get_scenes()
return_scene = None
for scene in scenes_list:
name = obs.obs_source_get_name(scene)
if name == scene_name:
return_scene = obs.obs_scene_from_source(scene)
return return_scene, scenes_list
@contextmanager
def source_list_auto_release(source_list):
try:
yield source_list
finally:
obs.source_list_release(source_list)
@contextmanager
def source_auto_release(source_name):
source = obs.obs_get_source_by_name(source_name)
try:
yield source
finally:
obs.obs_source_release(source)
@contextmanager
def get_filter(source, filter_name):
filter_ = obs.obs_source_get_filter_by_name(source, filter_name)
try:
yield filter_
finally:
obs.obs_source_release(filter_)
@contextmanager
def new_settings():
newSettings = obs.obs_data_create()
try:
yield newSettings
finally:
obs.obs_data_release(newSettings)
def source_tween(unused_addr,
source_name,
filter_name=None, setting=None,
from_value=None, to_value=None,
duration=1000, delay=0,
ease_type='outQuad', fps=30,
extra=None, eval_=None,
private=False):
c2(f'source_tween(source_name="{source_name}",')
c2(f' filter_name={filter_name}, setting={setting},')
c2(f' from_value={from_value}, to_value={to_value},')
c2(f' duration={duration}, delay={delay}, ease_type={ease_type},')
c2(f' fps={fps}, extra={extra}), eval_={eval_})')
duration = toint(duration)
delay = toint(delay)
fps = toint(fps)
from_value = tofloat(from_value)
to_value = tofloat(to_value)
value = float()
with ExitStack() as stack:
if not private: source = stack.enter_context(source_auto_release(source_name))
else: source = getattr(obs_api, source_name)
if source:
filter_ = stack.enter_context(get_filter(source, filter_name))
if filter_:
sourceSettings = obs.obs_source_get_settings(filter_)
json_from_filter = obs.obs_data_get_json(sourceSettings)
settings_from_filter = json.loads(json_from_filter)
if setting not in settings_from_filter:
print(f'Setting {setting} no está seteada aún')
return
if from_value == None:
from_value = settings_from_filter[setting]
value = settings_from_filter[setting]
# Código único para que se ejecute un tween a la vez
code = ''.join(random.choice(string.ascii_letters) for i in range(10))
# Momento en que comienza el tween.
init_time = time.time()*1000
# Crea elemento en diccionario. Queda forever.
globalDict.tween_sources[source_name] = {
'source_name': source_name,
'filter_name': filter_name,
'setting': setting,
'value': value,
'code': code,
'init_time': init_time,
'extra': extra,
'eval_': eval_,
}
# TIENE QUE IR TH()
th(th_source_tween, [
source_name,
filter_name, setting,
from_value, to_value,
init_time, duration, delay, ease_type,
code, fps, extra, eval_, private])
else: print(f'Filter no existe: {filter_name}')
else: print(f'Source no existe: {source_name}')
def th_source_tween(
source_name,
filter_name, setting,
from_value, to_value,
init_time, duration, delay, ease_type,
code, fps, extra, eval_, private):
# Delay
if delay > 0:
time.sleep(delay/1000)
init_time += delay
with ExitStack() as stack:
if not private: source = stack.enter_context(source_auto_release(source_name))
# else: source = globals()[source_name]
else: source = getattr(obs_api, source_name)
if source:
filter_ = stack.enter_context(get_filter(source, filter_name))
if filter_:
# Loop
while init_time + duration > time.time()*1000:
# Si no está en la lista de tweens, muere tween.
if source_name not in globalDict.tween_sources:
return
# Si el código no es el mismo que el registrado, muere tween.
if code != globalDict.tween_sources[source_name]['code']:
return
elapsed_time = time.time()*1000 - init_time
value_change = None if to_value == None else to_value - from_value
# time, beginning position, change inposition, and duration
value = None if to_value == None else tween_eq(ease_type, elapsed_time, from_value, value_change, duration)
c4(f'TWEEN TRANSFORM - SOURCE')
c4(f' source_name="{source_name}", filter_name={filter_name},')
c4(f' setting={setting}, value={value}')
# Si hay modificaciones, las hace y guarda info del objeto
if value != None:
newSettings = stack.enter_context(new_settings())
obs.obs_data_set_double(newSettings, setting, value)
obs.obs_source_update(filter_, newSettings)
globalDict.tween_sources[source_name]['value'] = value
if eval_ != None:
eval(eval_)
if extra != None:
pass
time_sleep = 1 / fps
time.sleep(time_sleep)
# Si hay modificaciones, las hace y guarda info del objeto
if 'value' in locals() and value != None:
newSettings = stack.enter_context(new_settings())
obs.obs_data_set_double(newSettings, setting, to_value)
obs.obs_source_update(filter_, newSettings)
globalDict.tween_sources[source_name]['value'] = to_value
c4(f'TWEEN SOURCE TRANSFORM - FINISH')
c4(f' source_name="{source_name}", filter_name={filter_name}')
c4(f' setting={setting}, value={to_value}')
# Ningunea elementos propios del tween que termina
globalDict.tween_sources[source_name]['init_time'] = None
globalDict.tween_sources[source_name]['code'] = None
globalDict.tween_sources[source_name]['extra'] = None
globalDict.tween_sources[source_name]['eval_'] = None
# Para ejecutar algo al final
# TO DO
if eval_ != None:
eval(eval_)
c3(f'Terminó source_tween "{source_name}"')
else: print(f'Filter no existe: {filter_name}')
else: print(f'Source no existe: {source_name}')
def item_tween(unused_addr,
scene_name, item_name,
from_pos_y=None, to_pos_x=None,
from_pos_x=None, to_pos_y=None,
from_scl_x=None, to_scl_x=None,
from_scl_y=None, to_scl_y=None,
from_rot=None, to_rot=None,
from_width=None, to_width=None,
from_height=None, to_height=None,
alignment=None, visible=True,
duration=1000, delay=0,
ease_type='outQuad', fps=30,
extra=None, eval_=None,
private=False):
c2(f'item_tween(scene_name="{scene_name}", item_name="{item_name}",')
c2(f' duration={duration}, delay={delay}, ease_type={ease_type},')
c2(f' from_pos_x={from_pos_x}, from_pos_y={from_pos_y},')
c2(f' to_pos_x={to_pos_x}, to_pos_y={to_pos_y},')
c2(f' from_scl_x={from_scl_x}, from_scl_y={from_scl_y},')
c2(f' to_scl_x={to_scl_x}, to_scl_y={to_scl_y},')
c2(f' from_rot={from_rot},')
c2(f' to_rot={to_rot},')
c2(f' from_width={from_width}, from_height={from_height},')
c2(f' to_width={to_width}, to_height={to_height},')
c2(f' alignment={alignment}, visible={visible},')
c2(f' fps={fps}, extra={extra}), eval_={eval_})')
duration = toint(duration)
delay = toint(delay)
from_pos_x = toint(from_pos_x)
from_pos_y = toint(from_pos_y)
from_scl_x = tofloat(from_scl_x)
from_scl_y = tofloat(from_scl_y)
from_rot = toint(from_rot)
from_width = toint(from_width)
from_height = toint(from_height)
to_pos_x = toint(to_pos_x)
to_pos_y = toint(to_pos_y)
to_scl_x = tofloat(to_scl_x)
to_scl_y = tofloat(to_scl_y)
to_rot = tofloat(to_rot)
to_width = toint(to_width)
to_height = toint(to_height)
alignment = toint(alignment)
visible = tobool(visible)
fps = toint(fps)
scene, scenes_list = get_scene_context(scene_name)
if not scene:
obs.source_list_release(scenes_list)
return
with source_list_auto_release(scenes_list):
if item_name.startswith('id:'):
scene_item = obs.obs_scene_find_sceneitem_by_id(scene, int(item_name[3:]))
if scene_item:
item_id = int(item_name[3:])
else:
scene_item = obs.obs_scene_find_source(scene, item_name)
if scene_item:
item_id = obs.obs_sceneitem_get_id(scene_item)
if scene_item:
item_info = obs.obs_transform_info()
obs.obs_sceneitem_get_info(scene_item, item_info)
if from_pos_x == None: from_pos_x = item_info.pos.x
if from_pos_y == None: from_pos_y = item_info.pos.y
if from_scl_x == None: from_scl_x = item_info.scale.x
if from_scl_y == None: from_scl_y = item_info.scale.y
if from_rot == None: from_rot = item_info.rot
# Si modifica width o height, necesita medidas originales del source
if to_width != None or to_height != None:
with ExitStack() as stack:
try:
if item_name.startswith('id:'):
if not private:
source = obs.obs_sceneitem_get_source(scene_item)
else:
print(f'item_tween() sceneitem como "{item_name}" y "private=True" aún no es posible')
return
else:
if not private:
source = stack.enter_context(source_auto_release(item_name))
else:
source = getattr(obs_api, item_name)
crop = obs.obs_sceneitem_crop()
obs.obs_sceneitem_get_crop(scene_item, crop)
if to_width != None:
original_width = (obs.obs_source_get_width(source) - crop.left - crop.right) * item_info.scale.x
original_scl_x = item_info.scale.x
if from_width != None:
from_scl_x = (from_width * item_info.scale.x) / original_width
else:
from_width = original_width
from_scl_x = original_scl_x
to_scl_x = (to_width * item_info.scale.x) / original_width
if to_height != None:
original_height = (obs.obs_source_get_height(source) - crop.left - crop.right) * item_info.scale.y
original_scl_y = item_info.scale.y
if from_height != None:
from_scl_y = (from_height * item_info.scale.y) / original_height
else:
from_height = original_height
from_scl_y = original_scl_y
to_scl_y = (to_height * item_info.scale.y) / original_height
except:
print(f'item_tween() Item "{item_name}" mal definido valor de "private"')
return
# Código único para que se ejecute un tween a la vez
code = ''.join(random.choice(string.ascii_letters) for i in range(10))
# Momento en que comienza el tween.
init_time = time.time()*1000
# Crea elemento en diccionario. Queda forever.
globalDict.tween_sceneitems[item_id] = {
'scene_name': scene_name,
'item_name': item_name,
'code': code,
'init_time': init_time,
'pos_x': from_pos_x,
'pos_y': from_pos_y,
'scl_x': from_scl_x,
'scl_y': from_scl_y,
'rot': from_rot,
'width': from_width,
'height': from_height,
'alignment': alignment,
'visible': visible,
'extra': extra,
'eval_': eval_,
'private': private,
}
# Función en Thread
th(th_item_tween, [scene_name, item_name, scene_item,
item_info, item_id, code,
init_time, duration, delay, ease_type,
from_pos_x, from_pos_y, from_scl_x, from_scl_y, from_rot, from_width, from_height,
to_pos_x, to_pos_y, to_scl_x, to_scl_y, to_rot, to_width, to_height,
alignment, visible, fps, extra, eval_, private])
else:
print(f'item_tween() Item no existe: "{item_name}"')
def th_item_tween(scene_name, item_name, scene_item,
item_info, item_id, code,
init_time, duration, delay, ease_type,
from_pos_x, from_pos_y, from_scl_x, from_scl_y, from_rot, from_width, from_height,
to_pos_x, to_pos_y, to_scl_x, to_scl_y, to_rot, to_width, to_height,
alignment, visible, fps, extra, eval_, private):
# Delay
if delay > 0:
time.sleep(delay/1000)
init_time += delay
# Lo hace visible al comienzo o no
obs.obs_sceneitem_set_visible(scene_item, bool(visible))
# Loop
while init_time + duration > time.time()*1000:
# Si no está en la lista de tweens, muere tween.
if item_id not in globalDict.tween_sceneitems:
return
# Si el código no es el mismo que el registrado, muere tween.
if code != globalDict.tween_sceneitems[item_id]['code']:
return
elapsed_time = time.time()*1000 - init_time
# time, beginning position, change inposition, and duration
pos_x = None if to_pos_x == None else tween_eq(ease_type, elapsed_time, from_pos_x, to_pos_x, duration)
pos_y = None if to_pos_y == None else tween_eq(ease_type, elapsed_time, from_pos_y, to_pos_y, duration)
scl_x = None if to_scl_x == None else tween_eq(ease_type, elapsed_time, from_scl_x, to_scl_x, duration)
scl_y = None if to_scl_y == None else tween_eq(ease_type, elapsed_time, from_scl_y, to_scl_y, duration)
rot = None if to_rot == None else tween_eq(ease_type, elapsed_time, from_rot , to_rot , duration)
width = None if to_width == None else tween_eq(ease_type, elapsed_time, from_width, to_width, duration)
height = None if to_height == None else tween_eq(ease_type, elapsed_time, from_height, to_height, duration)
c4(f'TWEEN SCENEITEM TRANSFORM')
c4(f' scene_name="{scene_name}", item_name="{item_name}",')
c4(f' pos_x={pos_x}, pos_y={pos_y}, scl_x={scl_x}, scl_y={scl_y},')
c4(f' rot={rot}, width={width}, height={height}, alignment={alignment}, visible={visible})')
# Si hay modificaciones, las hace y guarda info del objeto
# Position
if pos_x != None:
item_info.pos.x = int(pos_x)
globalDict.tween_sceneitems[item_id]['pos_x'] = int(pos_x)
if pos_y != None:
item_info.pos.y = int(pos_y)
globalDict.tween_sceneitems[item_id]['pos_y'] = int(pos_y)
# Scale
if scl_x != None:
item_info.scale.x = scl_x
globalDict.tween_sceneitems[item_id]['scl_x'] = scl_x
if scl_y != None:
item_info.scale.y = scl_y
globalDict.tween_sceneitems[item_id]['scl_y'] = scl_y
# Size (Dummy)
if width != None:
globalDict.tween_sceneitems[item_id]['width'] = width
if height != None:
globalDict.tween_sceneitems[item_id]['height'] = height
# Rotation
if rot != None:
item_info.rot = rot
globalDict.tween_sceneitems[item_id]['rot'] = rot
# Alignment
if alignment != None:
item_info.alignment = alignment
globalDict.tween_sceneitems[item_id]['alignment'] = alignment
obs.obs_sceneitem_set_info(scene_item, item_info)
if eval_ != None:
eval(eval_)
if extra != None:
pass
time_sleep = 1 / fps
time.sleep(time_sleep)
# Si hay modificaciones, las hace y guarda info del objeto
if 'pos_x' in locals() and pos_x != None:
item_info.pos.x = int(to_pos_x)
globalDict.tween_sceneitems[item_id]['pos_x'] = int(to_pos_x)
if 'pos_y' in locals() and pos_y != None:
item_info.pos.y = int(to_pos_y)
globalDict.tween_sceneitems[item_id]['pos_y'] = int(to_pos_y)
if 'scl_x' in locals() and scl_x != None:
item_info.scale.x = to_scl_x
globalDict.tween_sceneitems[item_id]['scl_x'] = to_scl_x
if 'scl_y' in locals() and scl_y != None:
item_info.scale.y = to_scl_y
globalDict.tween_sceneitems[item_id]['scl_y'] = to_scl_y
if 'rot' in locals() and rot != None:
item_info.rot = to_rot
globalDict.tween_sceneitems[item_id]['rot'] = to_rot
if 'width' in locals() and width != None:
globalDict.tween_sceneitems[item_id]['width'] = to_width
if 'height' in locals() and height != None:
globalDict.tween_sceneitems[item_id]['height'] = to_height
if 'alignment' in locals() and alignment != None:
item_info.alignment = alignment
globalDict.tween_sceneitems[item_id]['alignment'] = alignment
obs.obs_sceneitem_set_info(scene_item, item_info)
c4(f'TWEEN ITEM TRANSFORM - FINISH')
c4(f' scene_name="{scene_name}", item_name="{item_name}",')
c4(f' pos_x={int(to_pos_x)}, pos_y={int(to_pos_y)}, scl_x={to_scl_x}, scl_y={to_scl_y},')
c4(f' rot={to_rot}, width={to_width}, height={to_height}, alignment={alignment}, visible={visible})')
# Ningunea elementos propios del tween que termina
globalDict.tween_sceneitems[item_id]['init_time'] = None
globalDict.tween_sceneitems[item_id]['code'] = None
globalDict.tween_sceneitems[item_id]['extra'] = None
globalDict.tween_sceneitems[item_id]['eval_'] = None
# Para ejecutar algo al final
# TO DO
if eval_ != None:
eval(eval_)
c3(f'Terminó item tween "{scene_name}" "{item_name}"')
# TWEEN - Ecuaciones
def tween_eq(ease_type, t, b, c, d):
#~ if t >= 0:
if ease_type in ['linear', 'LinearInOut']:
a = LinearInOut(b, c, d)
return a(t)
elif ease_type in ['inQuad', 'QuadEaseIn']:
a = QuadEaseIn(b, c, d)
return a(t)
elif ease_type in ['outQuad', 'QuadEaseOut']:
a = QuadEaseOut(b, c, d)
return a(t)
elif ease_type in ['inOutQuad', 'QuadEaseInOut']:
a = QuadEaseInOut(b, c, d)
return a(t)
elif ease_type in ['inCubic', 'CubicEaseIn']:
a = CubicEaseIn(b, c, d)
return a(t)
elif ease_type in ['outCubic', 'CubicEaseOut']:
a = CubicEaseOut(b, c, d)
return a(t)
elif ease_type in ['inOutCubic', 'CubicEaseInOut']:
a = CubicEaseInOut(b, c, d)
return a(t)
elif ease_type in ['inQuartic', 'QuarticEaseIn']:
a = QuarticEaseIn(b, c, d)
return a(t)
elif ease_type in ['outQuartic', 'QuarticEaseOut']:
a = QuarticEaseOut(b, c, d)
return a(t)
elif ease_type in ['inOutQuartic', 'QuarticEaseInOut']:
a = QuarticEaseInOut(b, c, d)
return a(t)
elif ease_type in ['inQuintic', 'QuinticEaseIn']:
a = QuinticEaseIn(b, c, d)
return a(t)
elif ease_type in ['outQuintic', 'QuinticEaseOut']:
a = QuinticEaseOut(b, c, d)
return a(t)
elif ease_type in ['inOutQuintic', 'QuinticEaseInOut']:
a = QuinticEaseInOut(b, c, d)
return a(t)
elif ease_type in ['inSine', 'SineEaseIn']:
a = SineEaseIn(b, c, d)
return a(t)
elif ease_type in ['outSine', 'SineEaseOut']:
a = SineEaseOut(b, c, d)
return a(t)
elif ease_type in ['inOutSine', 'SineEaseInOut']:
a = SineEaseInOut(b, c, d)
return a(t)
elif ease_type in ['inCircular', 'CircularEaseIn']:
a = CircularEaseIn(b, c, d)
return a(t)
elif ease_type in ['outCircular', 'CircularEaseOut']:
a = CircularEaseOut(b, c, d)
return a(t)
elif ease_type in ['inOutCircular', 'CircularEaseInOut']:
a = CircularEaseInOut(b, c, d)
return a(t)
elif ease_type in ['inExponential', 'ExponentialEaseIn']:
a = ExponentialEaseIn(b, c, d)
return a(t)
elif ease_type in ['outExponential', 'ExponentialEaseOut']:
a = ExponentialEaseOut(b, c, d)
return a(t)
elif ease_type in ['inOutExponential', 'ExponentialEaseInOut']:
a = ExponentialEaseInOut(b, c, d)
return a(t)
elif ease_type in ['inElastic', 'ElasticEaseIn']:
a = ElasticEaseIn(b, c, d)
return a(t)
elif ease_type in ['outElastic', 'ElasticEaseOut']:
a = ElasticEaseOut(b, c, d)
return a(t)
elif ease_type in ['inOutElastic', 'ElasticEaseInOut']:
a = ElasticEaseInOut(b, c, d)
return a(t)
elif ease_type in ['inBack', 'BackEaseIn']:
a = BackEaseIn(b, c, d)
return a(t)
elif ease_type in ['outBack', 'BackEaseOut']:
a = BackEaseOut(b, c, d)
return a(t)
elif ease_type in ['inOutBack', 'BackEaseInOut']:
a = BackEaseInOut(b, c, d)
return a(t)
elif ease_type in ['inBounce', 'BounceEaseIn']:
a = BounceEaseIn(b, c, d)
return a(t)
elif ease_type in ['outBounce', 'BounceEaseOut']:
a = BounceEaseOut(b, c, d)
return a(t)
elif ease_type in ['inOutBounce', 'BounceEaseInOut']:
a = BounceEaseInOut(b, c, d)
return a(t)
def write_tween_sceneitems():
while True:
with open("/home/mario/meytv/obs-scripts/tween_items_sources.watch", "w") as outfile:
new_dict = {
'sceneitems': globalDict.tween_sceneitems,
'sources': globalDict.tween_sources,
}
json.dump(
new_dict,
outfile,
default=str,
sort_keys=True,
indent=2,
ensure_ascii=False
)
time.sleep(.25) # 1fps
thread(write_tween_sceneitems)