-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbase_Base.js.html
More file actions
719 lines (588 loc) · 52.1 KB
/
base_Base.js.html
File metadata and controls
719 lines (588 loc) · 52.1 KB
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
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>base/Base.js - Documentation</title>
<script src="scripts/prettify/prettify.js"></script>
<script src="scripts/prettify/lang-css.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
<script src="scripts/nav.js" defer></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
<div class="navicon"></div>
</label>
<label for="nav-trigger" class="overlay"></label>
<nav >
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="BuiltinAssets.html">BuiltinAssets</a></li><li><a href="GlobalAPI.html">GlobalAPI</a><ul class='methods'><li data-type='method'><a href="GlobalAPI.html#gotoAndPlay">gotoAndPlay</a></li><li data-type='method'><a href="GlobalAPI.html#gotoAndStop">gotoAndStop</a></li><li data-type='method'><a href="GlobalAPI.html#gotoNextFrame">gotoNextFrame</a></li><li data-type='method'><a href="GlobalAPI.html#gotoPrevFrame">gotoPrevFrame</a></li><li data-type='method'><a href="GlobalAPI.html#hideCursor">hideCursor</a></li><li data-type='method'><a href="GlobalAPI.html#isKeyDown">isKeyDown</a></li><li data-type='method'><a href="GlobalAPI.html#isKeyJustPressed">isKeyJustPressed</a></li><li data-type='method'><a href="GlobalAPI.html#isMouseDown">isMouseDown</a></li><li data-type='method'><a href="GlobalAPI.html#keyIsDown">keyIsDown</a></li><li data-type='method'><a href="GlobalAPI.html#keyIsJustPressed">keyIsJustPressed</a></li><li data-type='method'><a href="GlobalAPI.html#onEvent">onEvent</a></li><li data-type='method'><a href="GlobalAPI.html#play">play</a></li><li data-type='method'><a href="GlobalAPI.html#playSound">playSound</a></li><li data-type='method'><a href="GlobalAPI.html#showCursor">showCursor</a></li><li data-type='method'><a href="GlobalAPI.html#stop">stop</a></li><li data-type='method'><a href="GlobalAPI.html#stopAllSounds">stopAllSounds</a></li><li data-type='method'><a href="GlobalAPI.html#stopSound">stopSound</a></li></ul></li><li><a href="paper.SelectionGUI.html">SelectionGUI</a><ul class='methods'><li data-type='method'><a href="paper.SelectionGUI.html#destroy">destroy</a></li><li data-type='method'><a href="paper.SelectionGUI.html#moveHandleAndRotate">moveHandleAndRotate</a></li><li data-type='method'><a href="paper.SelectionGUI.html#moveHandleAndScale">moveHandleAndScale</a></li></ul></li><li><a href="paper-paper.Selection.html">Selection</a></li><li><a href="SelectionWidget.html">SelectionWidget</a><ul class='methods'><li data-type='method'><a href="SelectionWidget.html#build">build</a></li><li data-type='method'><a href="SelectionWidget.html#finishTransformation">finishTransformation</a></li><li data-type='method'><a href="SelectionWidget.html#flipHorizontally">flipHorizontally</a></li><li data-type='method'><a href="SelectionWidget.html#flipVertically">flipVertically</a></li><li data-type='method'><a href="SelectionWidget.html#rotateSelection">rotateSelection</a></li><li data-type='method'><a href="SelectionWidget.html#scaleSelection">scaleSelection</a></li><li data-type='method'><a href="SelectionWidget.html#startTransformation">startTransformation</a></li><li data-type='method'><a href="SelectionWidget.html#transformSelection">transformSelection</a></li><li data-type='method'><a href="SelectionWidget.html#translateSelection">translateSelection</a></li><li data-type='method'><a href="SelectionWidget.html#updateTransformation">updateTransformation</a></li></ul></li><li><a href="Wick.AutoSave.html">AutoSave</a><ul class='methods'><li data-type='method'><a href="Wick.AutoSave.html#.addAutosaveToList">addAutosaveToList</a></li><li data-type='method'><a href="Wick.AutoSave.html#.delete">delete</a></li><li data-type='method'><a href="Wick.AutoSave.html#.deleteAutosaveData">deleteAutosaveData</a></li><li data-type='method'><a href="Wick.AutoSave.html#.generateAutosaveData">generateAutosaveData</a></li><li data-type='method'><a href="Wick.AutoSave.html#.generateProjectFromAutosaveData">generateProjectFromAutosaveData</a></li><li data-type='method'><a href="Wick.AutoSave.html#.getAutosavesList">getAutosavesList</a></li><li data-type='method'><a href="Wick.AutoSave.html#.load">load</a></li><li data-type='method'><a href="Wick.AutoSave.html#.readAutosaveData">readAutosaveData</a></li><li data-type='method'><a href="Wick.AutoSave.html#.removeAutosaveFromList">removeAutosaveFromList</a></li><li data-type='method'><a href="Wick.AutoSave.html#.save">save</a></li><li data-type='method'><a href="Wick.AutoSave.html#.updateAutosavesList">updateAutosavesList</a></li><li data-type='method'><a href="Wick.AutoSave.html#.writeAutosaveData">writeAutosaveData</a></li></ul></li><li><a href="Wick.Base.html">Base</a><ul class='methods'><li data-type='method'><a href="Wick.Base.html#.fromData">fromData</a></li><li data-type='method'><a href="Wick.Base.html#.import">import</a></li><li data-type='method'><a href="Wick.Base.html#addChild">addChild</a></li><li data-type='method'><a href="Wick.Base.html#copy">copy</a></li><li data-type='method'><a href="Wick.Base.html#deserialize">deserialize</a></li><li data-type='method'><a href="Wick.Base.html#export">export</a></li><li data-type='method'><a href="Wick.Base.html#getChild">getChild</a></li><li data-type='method'><a href="Wick.Base.html#getChildren">getChildren</a></li><li data-type='method'><a href="Wick.Base.html#getChildrenRecursive">getChildrenRecursive</a></li><li data-type='method'><a href="Wick.Base.html#getLinkedAssets">getLinkedAssets</a></li><li data-type='method'><a href="Wick.Base.html#insertChild">insertChild</a></li><li data-type='method'><a href="Wick.Base.html#removeChild">removeChild</a></li><li data-type='method'><a href="Wick.Base.html#serialize">serialize</a></li></ul></li><li><a href="Wick.Button.html">Button</a></li><li><a href="Wick.Clip.html">Clip</a><ul class='methods'><li data-type='method'><a href="Wick.Clip.html#addObjects">addObjects</a></li><li data-type='method'><a href="Wick.Clip.html#applySingleFramePosition">applySingleFramePosition</a></li><li data-type='method'><a href="Wick.Clip.html#applySyncPosition">applySyncPosition</a></li><li data-type='method'><a href="Wick.Clip.html#breakApart">breakApart</a></li><li data-type='method'><a href="Wick.Clip.html#circleHits">circleHits</a></li><li data-type='method'><a href="Wick.Clip.html#clone">clone</a></li><li data-type='method'><a href="Wick.Clip.html#convexHits">convexHits</a></li><li data-type='method'><a href="Wick.Clip.html#ensureActiveFrameIsContentful">ensureActiveFrameIsContentful</a></li><li data-type='method'><a href="Wick.Clip.html#gotoAndPlay">gotoAndPlay</a></li><li data-type='method'><a href="Wick.Clip.html#gotoAndStop">gotoAndStop</a></li><li data-type='method'><a href="Wick.Clip.html#gotoNextFrame">gotoNextFrame</a></li><li data-type='method'><a href="Wick.Clip.html#gotoPrevFrame">gotoPrevFrame</a></li><li data-type='method'><a href="Wick.Clip.html#hits">hits</a></li><li data-type='method'><a href="Wick.Clip.html#hitTest">hitTest</a></li><li data-type='method'><a href="Wick.Clip.html#play">play</a></li><li data-type='method'><a href="Wick.Clip.html#radiusAtPointInDirection">radiusAtPointInDirection</a></li><li data-type='method'><a href="Wick.Clip.html#rectangleHits">rectangleHits</a></li><li data-type='method'><a href="Wick.Clip.html#remove">remove</a></li><li data-type='method'><a href="Wick.Clip.html#removeClone">removeClone</a></li><li data-type='method'><a href="Wick.Clip.html#resetTimelinePosition">resetTimelinePosition</a></li><li data-type='method'><a href="Wick.Clip.html#setText">setText</a></li><li data-type='method'><a href="Wick.Clip.html#stop">stop</a></li><li data-type='method'><a href="Wick.Clip.html#updateTimelineForAnimationType">updateTimelineForAnimationType</a></li></ul></li><li><a href="Wick.Clipboard.html">Clipboard</a><ul class='methods'><li data-type='method'><a href="Wick.Clipboard.html#copyObjectsToClipboard">copyObjectsToClipboard</a></li><li data-type='method'><a href="Wick.Clipboard.html#pasteObjectsFromClipboard">pasteObjectsFromClipboard</a></li></ul></li><li><a href="Wick.FileCache.html">FileCache</a><ul class='methods'><li data-type='method'><a href="Wick.FileCache.html#.addFile">addFile</a></li><li data-type='method'><a href="Wick.FileCache.html#.clear">clear</a></li><li data-type='method'><a href="Wick.FileCache.html#.getAllFiles">getAllFiles</a></li><li data-type='method'><a href="Wick.FileCache.html#.getFile">getFile</a></li><li data-type='method'><a href="Wick.FileCache.html#.loadFilesFromLocalforage">loadFilesFromLocalforage</a></li><li data-type='method'><a href="Wick.FileCache.html#.removeFile">removeFile</a></li></ul></li><li><a href="Wick.Frame.html">Frame</a><ul class='methods'><li data-type='method'><a href="Wick.Frame.html#addClip">addClip</a></li><li data-type='method'><a href="Wick.Frame.html#addPath">addPath</a></li><li data-type='method'><a href="Wick.Frame.html#addTween">addTween</a></li><li data-type='method'><a href="Wick.Frame.html#applyClipSingleFramePositions">applyClipSingleFramePositions</a></li><li data-type='method'><a href="Wick.Frame.html#applyTweenTransforms">applyTweenTransforms</a></li><li data-type='method'><a href="Wick.Frame.html#containedWithin">containedWithin</a></li><li data-type='method'><a href="Wick.Frame.html#createTween">createTween</a></li><li data-type='method'><a href="Wick.Frame.html#cut">cut</a></li><li data-type='method'><a href="Wick.Frame.html#distanceFrom">distanceFrom</a></li><li data-type='method'><a href="Wick.Frame.html#extendAndPushOtherFrames">extendAndPushOtherFrames</a></li><li data-type='method'><a href="Wick.Frame.html#getActiveTween">getActiveTween</a></li><li data-type='method'><a href="Wick.Frame.html#getLinkedAssets">getLinkedAssets</a></li><li data-type='method'><a href="Wick.Frame.html#getRelativePlayheadPosition">getRelativePlayheadPosition</a></li><li data-type='method'><a href="Wick.Frame.html#getTweenAtCurrentPlayheadPosition">getTweenAtCurrentPlayheadPosition</a></li><li data-type='method'><a href="Wick.Frame.html#getTweenAtPosition">getTweenAtPosition</a></li><li data-type='method'><a href="Wick.Frame.html#inPosition">inPosition</a></li><li data-type='method'><a href="Wick.Frame.html#inRange">inRange</a></li><li data-type='method'><a href="Wick.Frame.html#isSoundPlaying">isSoundPlaying</a></li><li data-type='method'><a href="Wick.Frame.html#playSound">playSound</a></li><li data-type='method'><a href="Wick.Frame.html#remove">remove</a></li><li data-type='method'><a href="Wick.Frame.html#removeAllTweens">removeAllTweens</a></li><li data-type='method'><a href="Wick.Frame.html#removeClip">removeClip</a></li><li data-type='method'><a href="Wick.Frame.html#removePath">removePath</a></li><li data-type='method'><a href="Wick.Frame.html#removeSound">removeSound</a></li><li data-type='method'><a href="Wick.Frame.html#removeTween">removeTween</a></li><li data-type='method'><a href="Wick.Frame.html#seekTweenBehind">seekTweenBehind</a></li><li data-type='method'><a href="Wick.Frame.html#seekTweenInFront">seekTweenInFront</a></li><li data-type='method'><a href="Wick.Frame.html#shrinkAndPullOtherFrames">shrinkAndPullOtherFrames</a></li><li data-type='method'><a href="Wick.Frame.html#stopSound">stopSound</a></li><li data-type='method'><a href="Wick.Frame.html#updateClipTimelinesForAnimationType">updateClipTimelinesForAnimationType</a></li></ul></li><li><a href="Wick.GUIElement.Project.html">Project</a><ul class='methods'><li data-type='method'><a href="Wick.GUIElement.Project.html#_onMouseWheel">_onMouseWheel</a></li><li data-type='method'><a href="Wick.GUIElement.Project.html#checkForPlayheadAutoscroll">checkForPlayheadAutoscroll</a></li><li data-type='method'><a href="Wick.GUIElement.Project.html#closePopupMenu">closePopupMenu</a></li><li data-type='method'><a href="Wick.GUIElement.Project.html#createCanvasEvent">createCanvasEvent</a></li><li data-type='method'><a href="Wick.GUIElement.Project.html#createDocumentEvent">createDocumentEvent</a></li><li data-type='method'><a href="Wick.GUIElement.Project.html#dragAssetAtPosition">dragAssetAtPosition</a></li><li data-type='method'><a href="Wick.GUIElement.Project.html#draw">draw</a></li><li data-type='method'><a href="Wick.GUIElement.Project.html#markElementAsDrawn">markElementAsDrawn</a></li><li data-type='method'><a href="Wick.GUIElement.Project.html#onProjectModified">onProjectModified</a></li><li data-type='method'><a href="Wick.GUIElement.Project.html#onProjectSoftModified">onProjectSoftModified</a></li><li data-type='method'><a href="Wick.GUIElement.Project.html#openPopupMenu">openPopupMenu</a></li><li data-type='method'><a href="Wick.GUIElement.Project.html#removeAllEventListeners">removeAllEventListeners</a></li><li data-type='method'><a href="Wick.GUIElement.Project.html#resize">resize</a></li></ul></li><li><a href="Wick.GUIElement.Timeline.html">Timeline</a><ul class='methods'><li data-type='method'><a href="Wick.GUIElement.Timeline.html#draw">draw</a></li></ul></li><li><a href="Wick.GUIElement-Wick.GUIElement.Breadcrumbs.html">Breadcrumbs</a></li><li><a href="Wick.GUIElement-Wick.GUIElement.Button.html">Button</a></li><li><a href="Wick.History.html">History</a><ul class='methods'><li data-type='method'><a href="Wick.History.html#getObjectUUIDs">getObjectUUIDs</a></li><li data-type='method'><a href="Wick.History.html#loadSnapshot">loadSnapshot</a></li><li data-type='method'><a href="Wick.History.html#popState">popState</a></li><li data-type='method'><a href="Wick.History.html#pushState">pushState</a></li><li data-type='method'><a href="Wick.History.html#recoverState">recoverState</a></li><li data-type='method'><a href="Wick.History.html#reset">reset</a></li><li data-type='method'><a href="Wick.History.html#saveSnapshot">saveSnapshot</a></li></ul></li><li><a href="Wick.HTMLExport.html">HTMLExport</a><ul class='methods'><li data-type='method'><a href="Wick.HTMLExport.html#.bundleProject">bundleProject</a></li></ul></li><li><a href="Wick.HTMLPreview.html">HTMLPreview</a><ul class='methods'><li data-type='method'><a href="Wick.HTMLPreview.html#.previewProject">previewProject</a></li></ul></li><li><a href="Wick.ImageSequence.html">ImageSequence</a><ul class='methods'><li data-type='method'><a href="Wick.ImageSequence.html#.toPNGSequence">toPNGSequence</a></li></ul></li><li><a href="Wick.Layer.html">Layer</a><ul class='methods'><li data-type='method'><a href="Wick.Layer.html#activate">activate</a></li><li data-type='method'><a href="Wick.Layer.html#addFrame">addFrame</a></li><li data-type='method'><a href="Wick.Layer.html#addTween">addTween</a></li><li data-type='method'><a href="Wick.Layer.html#findGaps">findGaps</a></li><li data-type='method'><a href="Wick.Layer.html#getFrameAtPlayheadPosition">getFrameAtPlayheadPosition</a></li><li data-type='method'><a href="Wick.Layer.html#getFramesContainedWithin">getFramesContainedWithin</a></li><li data-type='method'><a href="Wick.Layer.html#getFramesInRange">getFramesInRange</a></li><li data-type='method'><a href="Wick.Layer.html#insertBlankFrame">insertBlankFrame</a></li><li data-type='method'><a href="Wick.Layer.html#move">move</a></li><li data-type='method'><a href="Wick.Layer.html#remove">remove</a></li><li data-type='method'><a href="Wick.Layer.html#removeFrame">removeFrame</a></li><li data-type='method'><a href="Wick.Layer.html#resolveGaps">resolveGaps</a></li><li data-type='method'><a href="Wick.Layer.html#resolveOverlap">resolveOverlap</a></li></ul></li><li><a href="Wick.Path.html">Path</a><ul class='methods'><li data-type='method'><a href="Wick.Path.html#.booleanOp">booleanOp</a></li><li data-type='method'><a href="Wick.Path.html#.createImagePath">createImagePath</a></li><li data-type='method'><a href="Wick.Path.html#.createImagePathSync">createImagePathSync</a></li><li data-type='method'><a href="Wick.Path.html#.intersect">intersect</a></li><li data-type='method'><a href="Wick.Path.html#.subtract">subtract</a></li><li data-type='method'><a href="Wick.Path.html#.unite">unite</a></li><li data-type='method'><a href="Wick.Path.html#flatten">flatten</a></li><li data-type='method'><a href="Wick.Path.html#getLinkedAssets">getLinkedAssets</a></li><li data-type='method'><a href="Wick.Path.html#remove">remove</a></li><li data-type='method'><a href="Wick.Path.html#setText">setText</a></li><li data-type='method'><a href="Wick.Path.html#updateJSON">updateJSON</a></li></ul></li><li><a href="Wick.Project.html">Project</a><ul class='methods'><li data-type='method'><a href="Wick.Project.html#addAsset">addAsset</a></li><li data-type='method'><a href="Wick.Project.html#addObject">addObject</a></li><li data-type='method'><a href="Wick.Project.html#breakApartSelection">breakApartSelection</a></li><li data-type='method'><a href="Wick.Project.html#cleanupUnusedAssets">cleanupUnusedAssets</a></li><li data-type='method'><a href="Wick.Project.html#copySelectionToClipboard">copySelectionToClipboard</a></li><li data-type='method'><a href="Wick.Project.html#createClipFromLayers">createClipFromLayers</a></li><li data-type='method'><a href="Wick.Project.html#createClipFromSelection">createClipFromSelection</a></li><li data-type='method'><a href="Wick.Project.html#createClipInstanceFromAsset">createClipInstanceFromAsset</a></li><li data-type='method'><a href="Wick.Project.html#createImagePathFromAsset">createImagePathFromAsset</a></li><li data-type='method'><a href="Wick.Project.html#createSVGInstanceFromAsset">createSVGInstanceFromAsset</a></li><li data-type='method'><a href="Wick.Project.html#createTween">createTween</a></li><li data-type='method'><a href="Wick.Project.html#cutSelectedFrames">cutSelectedFrames</a></li><li data-type='method'><a href="Wick.Project.html#cutSelectionToClipboard">cutSelectionToClipboard</a></li><li data-type='method'><a href="Wick.Project.html#deleteSelectedObjects">deleteSelectedObjects</a></li><li data-type='method'><a href="Wick.Project.html#destroy">destroy</a></li><li data-type='method'><a href="Wick.Project.html#distributeSelectionToLayers">distributeSelectionToLayers</a></li><li data-type='method'><a href="Wick.Project.html#doBooleanOperationOnSelection">doBooleanOperationOnSelection</a></li><li data-type='method'><a href="Wick.Project.html#duplicateSelection">duplicateSelection</a></li><li data-type='method'><a href="Wick.Project.html#errorOccured">errorOccured</a></li><li data-type='method'><a href="Wick.Project.html#extendFrames">extendFrames</a></li><li data-type='method'><a href="Wick.Project.html#extendFramesAndPushOtherFrames">extendFramesAndPushOtherFrames</a></li><li data-type='method'><a href="Wick.Project.html#focusTimelineOfParentClip">focusTimelineOfParentClip</a></li><li data-type='method'><a href="Wick.Project.html#focusTimelineOfSelectedClip">focusTimelineOfSelectedClip</a></li><li data-type='method'><a href="Wick.Project.html#generateAudioSequence">generateAudioSequence</a></li><li data-type='method'><a href="Wick.Project.html#generateAudioTrack">generateAudioTrack</a></li><li data-type='method'><a href="Wick.Project.html#generateImageSequence">generateImageSequence</a></li><li data-type='method'><a href="Wick.Project.html#generateSoundInfo">generateSoundInfo</a></li><li data-type='method'><a href="Wick.Project.html#getAllFrames">getAllFrames</a></li><li data-type='method'><a href="Wick.Project.html#getAllOnionSkinnedFrames">getAllOnionSkinnedFrames</a></li><li data-type='method'><a href="Wick.Project.html#getAssetByName">getAssetByName</a></li><li data-type='method'><a href="Wick.Project.html#getAssetByUUID">getAssetByUUID</a></li><li data-type='method'><a href="Wick.Project.html#getAssets">getAssets</a></li><li data-type='method'><a href="Wick.Project.html#getAudioInfo">getAudioInfo</a></li><li data-type='method'><a href="Wick.Project.html#getFonts">getFonts</a></li><li data-type='method'><a href="Wick.Project.html#getObjectByUUID">getObjectByUUID</a></li><li data-type='method'><a href="Wick.Project.html#hasFont">hasFont</a></li><li data-type='method'><a href="Wick.Project.html#importFile">importFile</a></li><li data-type='method'><a href="Wick.Project.html#initialize">initialize</a></li><li data-type='method'><a href="Wick.Project.html#inject">inject</a></li><li data-type='method'><a href="Wick.Project.html#insertBlankFrame">insertBlankFrame</a></li><li data-type='method'><a href="Wick.Project.html#isKeyDown">isKeyDown</a></li><li data-type='method'><a href="Wick.Project.html#isKeyJustPressed">isKeyJustPressed</a></li><li data-type='method'><a href="Wick.Project.html#loadAssets">loadAssets</a></li><li data-type='method'><a href="Wick.Project.html#moveSelectedFramesLeft">moveSelectedFramesLeft</a></li><li data-type='method'><a href="Wick.Project.html#moveSelectedFramesRight">moveSelectedFramesRight</a></li><li data-type='method'><a href="Wick.Project.html#moveSelection">moveSelection</a></li><li data-type='method'><a href="Wick.Project.html#mute">mute</a></li><li data-type='method'><a href="Wick.Project.html#objectIsMouseTarget">objectIsMouseTarget</a></li><li data-type='method'><a href="Wick.Project.html#onError">onError</a></li><li data-type='method'><a href="Wick.Project.html#pasteClipboardContents">pasteClipboardContents</a></li><li data-type='method'><a href="Wick.Project.html#play">play</a></li><li data-type='method'><a href="Wick.Project.html#playSound">playSound</a></li><li data-type='method'><a href="Wick.Project.html#playSoundFromAsset">playSoundFromAsset</a></li><li data-type='method'><a href="Wick.Project.html#prepareProjectForEditor">prepareProjectForEditor</a></li><li data-type='method'><a href="Wick.Project.html#recenter">recenter</a></li><li data-type='method'><a href="Wick.Project.html#redo">redo</a></li><li data-type='method'><a href="Wick.Project.html#removeAsset">removeAsset</a></li><li data-type='method'><a href="Wick.Project.html#resetCache">resetCache</a></li><li data-type='method'><a href="Wick.Project.html#resetTools">resetTools</a></li><li data-type='method'><a href="Wick.Project.html#resetZoomAndPan">resetZoomAndPan</a></li><li data-type='method'><a href="Wick.Project.html#runScheduledScripts">runScheduledScripts</a></li><li data-type='method'><a href="Wick.Project.html#scheduleScript">scheduleScript</a></li><li data-type='method'><a href="Wick.Project.html#selectAll">selectAll</a></li><li data-type='method'><a href="Wick.Project.html#shrinkFrames">shrinkFrames</a></li><li data-type='method'><a href="Wick.Project.html#shrinkFramesAndPullOtherFrames">shrinkFramesAndPullOtherFrames</a></li><li data-type='method'><a href="Wick.Project.html#stop">stop</a></li><li data-type='method'><a href="Wick.Project.html#stopAllSounds">stopAllSounds</a></li><li data-type='method'><a href="Wick.Project.html#stopSound">stopSound</a></li><li data-type='method'><a href="Wick.Project.html#tick">tick</a></li><li data-type='method'><a href="Wick.Project.html#tryToAutoCreateTween">tryToAutoCreateTween</a></li><li data-type='method'><a href="Wick.Project.html#undo">undo</a></li><li data-type='method'><a href="Wick.Project.html#unmute">unmute</a></li><li data-type='method'><a href="Wick.Project.html#zoomIn">zoomIn</a></li><li data-type='method'><a href="Wick.Project.html#zoomOut">zoomOut</a></li></ul></li><li><a href="Wick.Selection.html">Selection</a><ul class='methods'><li data-type='method'><a href="Wick.Selection.html#bringToFront">bringToFront</a></li><li data-type='method'><a href="Wick.Selection.html#clear">clear</a></li><li data-type='method'><a href="Wick.Selection.html#deselect">deselect</a></li><li data-type='method'><a href="Wick.Selection.html#deselectMultipleObjects">deselectMultipleObjects</a></li><li data-type='method'><a href="Wick.Selection.html#flipHorizontally">flipHorizontally</a></li><li data-type='method'><a href="Wick.Selection.html#flipVertically">flipVertically</a></li><li data-type='method'><a href="Wick.Selection.html#getLeftmostFrames">getLeftmostFrames</a></li><li data-type='method'><a href="Wick.Selection.html#getRightmostFrames">getRightmostFrames</a></li><li data-type='method'><a href="Wick.Selection.html#getSelectedObject">getSelectedObject</a></li><li data-type='method'><a href="Wick.Selection.html#getSelectedObjects">getSelectedObjects</a></li><li data-type='method'><a href="Wick.Selection.html#getSelectedObjectUUIDs">getSelectedObjectUUIDs</a></li><li data-type='method'><a href="Wick.Selection.html#isObjectSelected">isObjectSelected</a></li><li data-type='method'><a href="Wick.Selection.html#isSelectable">isSelectable</a></li><li data-type='method'><a href="Wick.Selection.html#moveBackwards">moveBackwards</a></li><li data-type='method'><a href="Wick.Selection.html#moveForwards">moveForwards</a></li><li data-type='method'><a href="Wick.Selection.html#select">select</a></li><li data-type='method'><a href="Wick.Selection.html#selectMultipleObjects">selectMultipleObjects</a></li><li data-type='method'><a href="Wick.Selection.html#sendToBack">sendToBack</a></li></ul></li><li><a href="Wick.SVGFile.html">SVGFile</a><ul class='methods'><li data-type='method'><a href="Wick.SVGFile.html#.fromSVGFile">fromSVGFile</a></li><li data-type='method'><a href="Wick.SVGFile.html#.toSVGFile">toSVGFile</a></li></ul></li><li><a href="Wick.Tickable.html">Tickable</a><ul class='methods'><li data-type='method'><a href="Wick.Tickable.html#_runFunction">_runFunction</a></li><li data-type='method'><a href="Wick.Tickable.html#addEventFn">addEventFn</a></li><li data-type='method'><a href="Wick.Tickable.html#addScript">addScript</a></li><li data-type='method'><a href="Wick.Tickable.html#getAvailableScripts">getAvailableScripts</a></li><li data-type='method'><a href="Wick.Tickable.html#getEventFns">getEventFns</a></li><li data-type='method'><a href="Wick.Tickable.html#getScript">getScript</a></li><li data-type='method'><a href="Wick.Tickable.html#hasScript">hasScript</a></li><li data-type='method'><a href="Wick.Tickable.html#onEvent">onEvent</a></li><li data-type='method'><a href="Wick.Tickable.html#removeScript">removeScript</a></li><li data-type='method'><a href="Wick.Tickable.html#runScript">runScript</a></li><li data-type='method'><a href="Wick.Tickable.html#scheduleScript">scheduleScript</a></li><li data-type='method'><a href="Wick.Tickable.html#scriptIsContentful">scriptIsContentful</a></li><li data-type='method'><a href="Wick.Tickable.html#tick">tick</a></li><li data-type='method'><a href="Wick.Tickable.html#updateScript">updateScript</a></li></ul></li><li><a href="Wick.Timeline.html">Timeline</a><ul class='methods'><li data-type='method'><a href="Wick.Timeline.html#addFrame">addFrame</a></li><li data-type='method'><a href="Wick.Timeline.html#addLayer">addLayer</a></li><li data-type='method'><a href="Wick.Timeline.html#addTween">addTween</a></li><li data-type='method'><a href="Wick.Timeline.html#advance">advance</a></li><li data-type='method'><a href="Wick.Timeline.html#deferFrameGapResolve">deferFrameGapResolve</a></li><li data-type='method'><a href="Wick.Timeline.html#forceFrame">forceFrame</a></li><li data-type='method'><a href="Wick.Timeline.html#getAllFrames">getAllFrames</a></li><li data-type='method'><a href="Wick.Timeline.html#getFrameByName">getFrameByName</a></li><li data-type='method'><a href="Wick.Timeline.html#getFramesAtPlayheadPosition">getFramesAtPlayheadPosition</a></li><li data-type='method'><a href="Wick.Timeline.html#getFramesInRange">getFramesInRange</a></li><li data-type='method'><a href="Wick.Timeline.html#gotoAndPlay">gotoAndPlay</a></li><li data-type='method'><a href="Wick.Timeline.html#gotoAndStop">gotoAndStop</a></li><li data-type='method'><a href="Wick.Timeline.html#gotoFrame">gotoFrame</a></li><li data-type='method'><a href="Wick.Timeline.html#gotoNextFrame">gotoNextFrame</a></li><li data-type='method'><a href="Wick.Timeline.html#gotoPrevFrame">gotoPrevFrame</a></li><li data-type='method'><a href="Wick.Timeline.html#makeTimelineInBounds">makeTimelineInBounds</a></li><li data-type='method'><a href="Wick.Timeline.html#moveLayer">moveLayer</a></li><li data-type='method'><a href="Wick.Timeline.html#play">play</a></li><li data-type='method'><a href="Wick.Timeline.html#removeLayer">removeLayer</a></li><li data-type='method'><a href="Wick.Timeline.html#resolveFrameGaps">resolveFrameGaps</a></li><li data-type='method'><a href="Wick.Timeline.html#resolveFrameOverlap">resolveFrameOverlap</a></li><li data-type='method'><a href="Wick.Timeline.html#stop">stop</a></li></ul></li><li><a href="Wick.Tools-Wick.Tools.Brush.html">Brush</a></li><li><a href="Wick.Tools-Wick.Tools.Cursor.html">Cursor</a></li><li><a href="Wick.Tools-Wick.Tools.Ellipse.html">Ellipse</a></li><li><a href="Wick.Tools-Wick.Tools.Eraser.html">Eraser</a></li><li><a href="Wick.Tools-Wick.Tools.Eyedropper.html">Eyedropper</a></li><li><a href="Wick.Tools-Wick.Tools.FillBucket.html">FillBucket</a></li><li><a href="Wick.Tools-Wick.Tools.Interact.html">Interact</a></li><li><a href="Wick.Tools-Wick.Tools.Line.html">Line</a></li><li><a href="Wick.Tools-Wick.Tools.None.html">None</a></li><li><a href="Wick.Tools-Wick.Tools.Pan.html">Pan</a></li><li><a href="Wick.Tools-Wick.Tools.Pencil.html">Pencil</a></li><li><a href="Wick.Tools-Wick.Tools.Rectangle.html">Rectangle</a></li><li><a href="Wick.Tools-Wick.Tools.Text.html">Text</a></li><li><a href="Wick.Tools-Wick.Tools.Zoom.html">Zoom</a></li><li><a href="Wick.Transformation.html">Transformation</a><ul class='methods'><li data-type='method'><a href="Wick.Transformation.html#copy">copy</a></li></ul></li><li><a href="Wick.Tween.html">Tween</a><ul class='methods'><li data-type='method'><a href="Wick.Tween.html#.interpolate">interpolate</a></li><li data-type='method'><a href="Wick.Tween.html#applyTransformsToClip">applyTransformsToClip</a></li><li data-type='method'><a href="Wick.Tween.html#getNextTween">getNextTween</a></li><li data-type='method'><a href="Wick.Tween.html#remove">remove</a></li><li data-type='method'><a href="Wick.Tween.html#restrictToFrameSize">restrictToFrameSize</a></li></ul></li><li><a href="Wick.View-Wick.View.Clip.html">Clip</a></li><li><a href="Wick.View-Wick.View.Frame.html">Frame</a></li><li><a href="Wick.View-Wick.View.Path.html">Path</a></li><li><a href="Wick.View-Wick.View.Selection.html">Selection</a></li><li><a href="Wick.WickFile.html">WickFile</a><ul class='methods'><li data-type='method'><a href="Wick.WickFile.html#.fromWickFile">fromWickFile</a></li><li data-type='method'><a href="Wick.WickFile.html#.generateMetaData">generateMetaData</a></li><li data-type='method'><a href="Wick.WickFile.html#.toWickFile">toWickFile</a></li></ul></li><li><a href="Wick.WickObjectFile.html">WickObjectFile</a><ul class='methods'><li data-type='method'><a href="Wick.WickObjectFile.html#.fromWickObjectFile">fromWickObjectFile</a></li><li data-type='method'><a href="Wick.WickObjectFile.html#.toWickObjectFile">toWickObjectFile</a></li></ul></li><li><a href="Wick.ZIPExport.html">ZIPExport</a></li><li><a href="WickObjectCache.html">WickObjectCache</a><ul class='methods'><li data-type='method'><a href="WickObjectCache.html#addObject">addObject</a></li><li data-type='method'><a href="WickObjectCache.html#clear">clear</a></li><li data-type='method'><a href="WickObjectCache.html#clearObjectToBeAutosaved">clearObjectToBeAutosaved</a></li><li data-type='method'><a href="WickObjectCache.html#getActiveObjects">getActiveObjects</a></li><li data-type='method'><a href="WickObjectCache.html#getAllObjects">getAllObjects</a></li><li data-type='method'><a href="WickObjectCache.html#getObjectByUUID">getObjectByUUID</a></li><li data-type='method'><a href="WickObjectCache.html#getObjectsNeedAutosaved">getObjectsNeedAutosaved</a></li><li data-type='method'><a href="WickObjectCache.html#markObjectToBeAutosaved">markObjectToBeAutosaved</a></li><li data-type='method'><a href="WickObjectCache.html#objectNeedsAutosave">objectNeedsAutosave</a></li><li data-type='method'><a href="WickObjectCache.html#removeObject">removeObject</a></li><li data-type='method'><a href="WickObjectCache.html#removeObjectByUUID">removeObjectByUUID</a></li><li data-type='method'><a href="WickObjectCache.html#removeTemporaryObjects">removeTemporaryObjects</a></li><li data-type='method'><a href="WickObjectCache.html#removeUnusedObjects">removeUnusedObjects</a></li></ul></li><li><a href="Wick-Wick.Asset.html">Asset</a></li><li><a href="Wick-Wick.AudioTrack.html">AudioTrack</a></li><li><a href="Wick-Wick.ClipAsset.html">ClipAsset</a></li><li><a href="Wick-Wick.Color.html">Color</a></li><li><a href="Wick-Wick.FileAsset.html">FileAsset</a></li><li><a href="Wick-Wick.FontAsset.html">FontAsset</a></li><li><a href="Wick-Wick.GIFAsset.html">GIFAsset</a></li><li><a href="Wick-Wick.GUIElement.html">GUIElement</a></li><li><a href="Wick-Wick.ImageAsset.html">ImageAsset</a></li><li><a href="Wick-Wick.SoundAsset.html">SoundAsset</a></li><li><a href="Wick-Wick.SVGAsset.html">SVGAsset</a></li><li><a href="Wick-Wick.Tool.html">Tool</a></li><li><a href="Wick-Wick.ToolSettings.html">ToolSettings</a></li><li><a href="Wick-Wick.View.html">View</a></li></ul><h3>Global</h3><ul><li><a href="global.html#type">type</a></li><li><a href="global.html#Wick">Wick</a></li></ul>
</nav>
<div id="main">
<h1 class="page-title">base/Base.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>/*
* Copyright 2020 WICKLETS LLC
*
* This file is part of Wick Engine.
*
* Wick Engine 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.
*
* Wick Engine 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 Wick Engine. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* The base class for all objects within the Wick Engine.
*/
Wick.Base = class {
/**
* Creates a Base object.
* @parm {string} identifier - (Optional) The identifier of the object. Defaults to null.
* @parm {string} name - (Optional) The name of the object. Defaults to null.
*/
constructor(args) {
/* One instance of each Wick.Base class is created so we can access
* a list of all possible properties of each class. This is used
* to clean up custom variables after projects are stopped. */
if (!Wick._originals[this.classname]) {
Wick._originals[this.classname] = {};
Wick._originals[this.classname] = new Wick[this.classname];
}
if (!args) args = {};
this._uuid = args.uuid || uuidv4();
this._identifier = args.identifier || null;
this._name = args.name || null;
this._view = null;
this.view = this._generateView();
this._guiElement = null;
this.guiElement = this._generateGUIElement();
this._classname = this.classname;
this._children = [];
this._childrenData = null;
this._parent = null;
// If this is a project, use this object, otherwise use the passed in project if provided.
this._project = this.classname === 'Project' ? this : args.project ? args.project : null;
this.needsAutosave = true;
this._cachedSerializeData = null;
this._temporary = false; // Defines if this object is "temporary"
Wick.ObjectCache.addObject(this);
}
/**
* @param {object} data - Serialized data to use to create a new object.
*/
static fromData(data, project) {
if (!data.classname) {
console.warn('Wick.Base.fromData(): data was missing, did you mean to deserialize something else?');
}
if (!Wick[data.classname]) {
console.warn('Tried to deserialize an object with no Wick class: ' + data.classname);
}
var object = new Wick[data.classname]({ uuid: data.uuid, project: project });
object.deserialize(data);
if (data.classname === 'Project') {
object.initialize();
}
return object;
}
/**
* Converts this Wick Base object into a plain javascript object contianing raw data (no references).
* @return {object} Plain JavaScript object representing this Wick Base object.
*/
serialize(args) {
// TEMPORARY: Force the cache to never be accessed.
// This is because the cache was causing issues in the tests, and the
// performance boost that came with the cache was not signifigant enough
// to be worth fixing the bugs over...
this.needsAutosave = true;
if (this.needsAutosave || !this._cachedSerializeData) {
// If the cache is outdated or does not exist, reserialize and cache.
var data = this._serialize(args);
this._cacheSerializeData(data);
return data;
} else {
// Otherwise, just read from the cache
return this._cachedSerializeData;
}
}
/**
* Parses serialized data representing Base Objects which have been serialized using the serialize function of their class.
* @param {object} data Serialized data that was returned by a Base Object's serialize function.
*/
deserialize(data) {
this._deserialize(data);
this._cacheSerializeData(data);
}
/* The internal serialize method that actually creates the data. Every class that inherits from Base must have one of these. */
_serialize(args) {
var data = {};
data.classname = this.classname;
data.identifier = this._identifier;
data.name = this._name;
data.uuid = this._uuid;
data.children = this.getChildren().map(child => { return child.uuid });
return data;
}
/* The internal deserialize method that actually reads the data. Every class that inherits from Base must have one of these. */
_deserialize(data) {
this._uuid = data.uuid;
this._identifier = data.identifier;
this._name = data.name;
this._children = [];
this._childrenData = data.children;
// Clear any custom attributes set by scripts
var compareObj = Wick._originals[this.classname];
for (var name in this) {
if (compareObj[name] === undefined) {
delete this[name];
}
}
}
_cacheSerializeData(data) {
this._cachedSerializeData = data;
this.needsAutosave = false;
}
/**
* Returns a copy of a Wick Base object.
* @return {Wick.Base} The object resulting from the copy
*/
copy() {
var data = this.serialize();
data.uuid = uuidv4();
var copy = Wick.Base.fromData(data);
copy._childrenData = null;
// Copy children
this.getChildren().forEach(child => {
copy.addChild(child.copy());
});
return copy;
}
/**
* Returns an object containing serialied data of this object, as well as all of its children.
* Use this to copy entire Wick.Base objects between projects, and to export individual Clips as files.
* @returns {object} The exported data.
*/
export () {
var copy = this.copy();
copy._project = this.project;
// the main object
var object = copy.serialize();
// children
var children = copy.getChildrenRecursive().map(child => {
return child.serialize();
});
// assets
var assets = [];
copy.getChildrenRecursive().concat(copy).forEach(child => {
child._project = copy._project;
child.getLinkedAssets().forEach(asset => {
assets.push(asset.serialize({ includeOriginalSource: true }));
});
});
return {
object: object,
children: children,
assets: assets,
};
}
/**
* Import data created using Wick.Base.export().
* @param {object} exportData - an object created from Wick.Base.export().
*/
static
import (exportData, project) {
if (!exportData) console.error('Wick.Base.import(): exportData is required');
if (!exportData.object) console.error('Wick.Base.import(): exportData is missing data');
if (!exportData.children) console.error('Wick.Base.import(): exportData is missing data');
// Import assets first in case the objects need them!
exportData.assets.forEach(assetData => {
// Don't import assets if they exist in the project already
// (Assets only get reimported when objects are pasted between projects)
if (project.getAssetByUUID(assetData.uuid)) {
return;
}
var asset = Wick.Base.fromData(assetData, project);
project.addAsset(asset);
});
var object = Wick.Base.fromData(exportData.object, project);
// Import children as well
exportData.children.forEach(childData => {
// Only need to call deserialize here, we just want the object to get added to ObjectCache
var child = Wick.Base.fromData(childData, project);
});
return object;
}
/**
* Marks the object as possibly changed, so that next time autosave happens, this object is written to the save.
* @type {boolean}
*/
set needsAutosave(needsAutosave) {
if (needsAutosave) {
Wick.ObjectCache.markObjectToBeAutosaved(this);
} else {
Wick.ObjectCache.clearObjectToBeAutosaved(this);
}
}
get needsAutosave() {
return Wick.ObjectCache.objectNeedsAutosave(this);
}
/**
* Signals if an object is removed from the project while playing.
* This is a temprary variable.
* @type {boolean}
*/
get removed () {
return typeof this._removed === 'undefined' ? false : this._removed;
}
set removed (bool) {
this._removed = bool;
}
/**
* Returns the classname of a Wick Base object.
* @type {string}
*/
get classname() {
return 'Base';
}
/**
* A marker if this object is temporary. Meaning it
* should be garbage collected after a play.
*/
get temporary() {
return this._temporary;
}
/**
* The uuid of a Wick Base object.
* @type {string}
*/
get uuid() {
return this._uuid;
}
/**
* Changes an object's uuid. This function should not be used consistently, as it creates an entire copy of the object
* in the object cache. Avoid using this if possible.
*/
set uuid(uuid) {
this._uuid = uuid;
Wick.ObjectCache.addObject(this);
}
/**
* The name of the object that is used to access the object through scripts. Must be a valid JS variable name.
* @type {string}
*/
get identifier() {
return this._identifier;
}
set identifier(identifier) {
// Treat empty string identifier as null
if (identifier === '' || identifier === null) {
this._identifier = null;
return;
}
// Make sure the identifier doesn't squash any attributes of the window
if (this._identifierNameExistsInWindowContext(identifier)) return;
// Make sure the identifier will not be squashed by Wick API functions
if (this._identiferNameIsPartOfWickAPI(identifier)) return;
// Make sure the identifier is a valid js variable name
if(!isVarName(identifier)) {
this.project && this.project.errorOccured('Identifier must be a valid variable name.');
return;
}
// Make sure the identifier is not a reserved word in js
if (reserved.check(identifier)) return;
// Ensure no objects with duplicate identifiers can exist
this._identifier = this._getUniqueIdentifier(identifier);
}
/**
* The name of the object.
* @type {string}
*/
get name() {
return this._name;
}
set name(name) {
if (typeof name !== 'string') return;
if (name === '') this._name = null;
this._name = name;
}
/**
* The Wick.View object that is used for rendering this object on the canvas.
*/
get view() {
return this._view;
}
set view(view) {
if (view) view.model = this;
this._view = view;
}
/**
* The object that is used for rendering this object in the timeline GUI.
*/
get guiElement() {
return this._guiElement;
}
set guiElement(guiElement) {
if (guiElement) guiElement.model = this;
this._guiElement = guiElement;
}
/**
* Returns a single child of this object with a given classname.
* @param {string} classname - the classname to use
*/
getChild(classname) {
return this.getChildren(classname)[0];
}
/**
* Gets all children with a given classname(s).
* @param {Array|string} classname - (optional) A string, or list of strings, of classnames.
*/
getChildren(classname) {
// Lazily generate children list from serialized data
if (this._childrenData) {
this._childrenData.forEach(uuid => {
this.addChild(Wick.ObjectCache.getObjectByUUID(uuid));
});
this._childrenData = null;
}
if (classname instanceof Array) {
let classNames = new Set(classname);
var children = [];
if (this._children !== undefined) {
children = this._children.filter(child => classNames.has(child.classname));
}
return children;
} else if (classname === undefined) {
// Retrieve all children if no classname was given
return Array.from(this._children);
} else {
// Retrieve children by classname
var children = this._children.filter(child => child.classname === classname);
return children || [];
}
}
/**
* Get an array of all children of this object, and the children of those children, recursively.
* @type {Wick.Base[]}
*/
getChildrenRecursive(level, original) {
var children = this.getChildren();
this.getChildren().forEach(child => {
children = children.concat(child.getChildrenRecursive(level + 1, original));
});
return children;
}
/**
* The parent of this object.
* @type {Wick.Base}
*/
get parent() {
return this._parent;
}
/**
* The parent Clip of this object.
* @type {Wick.Clip}
*/
get parentClip() {
return this._getParentByClassName('Clip');
}
/**
* The parent Layer of this object.
* @type {Wick.Layer}
*/
get parentLayer() {
return this._getParentByClassName('Layer');
}
/**
* The parent Frame of this object.
* @type {Wick.Frame}
*/
get parentFrame() {
return this._getParentByClassName('Frame');
}
/**
* The parent Timeline of this object.
* @type {Wick.Timeline}
*/
get parentTimeline() {
return this._getParentByClassName('Timeline');
}
/**
* The project that this object belongs to. Can be null if the object is not in a project.
* @type {Wick.Project}
*/
get project() {
if (this._project) {
return this._project;
} else if (this.parent) {
return this.parent.project
} else {
return null;
}
}
/**
* Check if an object is selected or not.
* @type {boolean}
*/
get isSelected() {
if (!this.project) return false;
return this.project.selection.isObjectSelected(this);
}
/**
* Add a child to this object.
* @param {Wick.Base} child - the child to add.
*/
addChild(child) {
var classname = child.classname;
if (!this._children) {
this._children = [];
}
child._parent = this;
child._setProject(this.project);
this._children.push(child);
}
/**
* Insert a child into this at specified index.
*
* The insertion is performed as if there is a dummy object placed
* at index, then the child is moved one index past the dummy,
* then the dummy is deleted. Therefore if the child starts out
* inside this._children below index, then insertChild returns true and
* this._children.indexOf(child) == index - 1. Otherwise, returns false and
* this._children.indexOf(child) == index.
*
* @param {Wick.Base} child - the child to add.
* @param {number} index - where to add the child
* @returns {boolean} - true if an item before index was moved
*/
insertChild(child, index) {
var classname = child.classname;
if (child._parent === this) {
let result = 0;
let old_index = this._children.indexOf(child);
if (old_index < index) {
index --;
result = 1;
}
this._children.splice(index, 0, this._children.splice(old_index, 1)[0]);
return result;
}
if (child._parent) {
child._parent.removeChild(child);
}
if (!this._children) {
this._children = [];
}
child._parent = this;
child._setProject(this.project);
this._children.splice(index, 0, child);
return 0;
}
/**
* Remove a child from this object.
* @param {Wick.Base} child - the child to remove.
*/
removeChild(child) {
if (!this._children) {
return;
}
child._parent = null;
child._project = null;
this._children = this._children.filter(seekChild => {
return seekChild !== child;
});
}
/**
* Assets attached to this object.
* @returns {Wick.Base[]}
*/
getLinkedAssets () {
// Implemented by Wick.Frame and Wick.Clip
return [];
}
_generateView() {
var viewClass = Wick.View[this.classname];
if (viewClass) {
return new viewClass(this);
} else {
return null;
}
}
_generateGUIElement() {
var guiElementClass = Wick.GUIElement[this.classname];
if (guiElementClass && guiElementClass !== Wick.Button) {
return new guiElementClass(this);
} else {
return null;
}
}
_getParentByClassName(classname) {
if (!this.parent) return null;
if (this.parent instanceof Wick[classname]) {
return this.parent;
} else {
if (!this.parent._getParentByClassName) return null;
return this.parent._getParentByClassName(classname);
}
}
_setProject(project) {
this._project = project;
this.getChildren().forEach(child => {
if (child instanceof Wick.Base) {
child._setProject(project);
}
});
}
_getUniqueIdentifier(identifier) {
if (!this.parent) return identifier;
var otherIdentifiers = this.parent.getChildren(['Clip', 'Frame', 'Button']).filter(child => {
return child !== this && child.identifier;
}).map(child => {
return child.identifier;
});
if (otherIdentifiers.indexOf(identifier) === -1) {
return identifier;
} else {
return this._getUniqueIdentifier(identifier + '_copy');
}
}
_identifierNameExistsInWindowContext(identifier) {
if (window[identifier]) {
return true;
} else {
return false;
}
}
_identiferNameIsPartOfWickAPI(identifier) {
var globalAPI = new GlobalAPI(this);
if (globalAPI[identifier]) {
return true;
} else {
return false;
}
}
}
</code></pre>
</article>
</section>
</div>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.11</a> on Sat Mar 01 2025 20:10:08 GMT-0300 (Brasilia Standard Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>
<script src="scripts/polyfill.js"></script>
<script src="scripts/linenumber.js"></script>
</body>
</html>