@clipkit/patterns 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +84 -0
- package/dist/anchor-default.d.ts +4 -0
- package/dist/anchor-default.d.ts.map +1 -0
- package/dist/anchor-default.js +34 -0
- package/dist/anchor-default.js.map +1 -0
- package/dist/bar-chart-row.d.ts +43 -0
- package/dist/bar-chart-row.d.ts.map +1 -0
- package/dist/bar-chart-row.js +143 -0
- package/dist/bar-chart-row.js.map +1 -0
- package/dist/beat-sync.d.ts +101 -0
- package/dist/beat-sync.d.ts.map +1 -0
- package/dist/beat-sync.js +145 -0
- package/dist/beat-sync.js.map +1 -0
- package/dist/camera-orbit.d.ts +22 -0
- package/dist/camera-orbit.d.ts.map +1 -0
- package/dist/camera-orbit.js +32 -0
- package/dist/camera-orbit.js.map +1 -0
- package/dist/cta-outro.d.ts +18 -0
- package/dist/cta-outro.d.ts.map +1 -0
- package/dist/cta-outro.js +44 -0
- package/dist/cta-outro.js.map +1 -0
- package/dist/data-scenes.d.ts +66 -0
- package/dist/data-scenes.d.ts.map +1 -0
- package/dist/data-scenes.js +188 -0
- package/dist/data-scenes.js.map +1 -0
- package/dist/flow-line.d.ts +27 -0
- package/dist/flow-line.d.ts.map +1 -0
- package/dist/flow-line.js +53 -0
- package/dist/flow-line.js.map +1 -0
- package/dist/glass-panel.d.ts +24 -0
- package/dist/glass-panel.d.ts.map +1 -0
- package/dist/glass-panel.js +32 -0
- package/dist/glass-panel.js.map +1 -0
- package/dist/header-bar.d.ts +36 -0
- package/dist/header-bar.d.ts.map +1 -0
- package/dist/header-bar.js +108 -0
- package/dist/header-bar.js.map +1 -0
- package/dist/hero-reveal.d.ts +17 -0
- package/dist/hero-reveal.d.ts.map +1 -0
- package/dist/hero-reveal.js +47 -0
- package/dist/hero-reveal.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +43 -0
- package/dist/index.js.map +1 -0
- package/dist/intro-card.d.ts +23 -0
- package/dist/intro-card.d.ts.map +1 -0
- package/dist/intro-card.js +123 -0
- package/dist/intro-card.js.map +1 -0
- package/dist/kinetic-headline.d.ts +18 -0
- package/dist/kinetic-headline.d.ts.map +1 -0
- package/dist/kinetic-headline.js +39 -0
- package/dist/kinetic-headline.js.map +1 -0
- package/dist/layers.d.ts +13 -0
- package/dist/layers.d.ts.map +1 -0
- package/dist/layers.js +19 -0
- package/dist/layers.js.map +1 -0
- package/dist/liquid-morph.d.ts +62 -0
- package/dist/liquid-morph.d.ts.map +1 -0
- package/dist/liquid-morph.js +113 -0
- package/dist/liquid-morph.js.map +1 -0
- package/dist/lit-surface.d.ts +38 -0
- package/dist/lit-surface.d.ts.map +1 -0
- package/dist/lit-surface.js +63 -0
- package/dist/lit-surface.js.map +1 -0
- package/dist/lower-third.d.ts +26 -0
- package/dist/lower-third.d.ts.map +1 -0
- package/dist/lower-third.js +101 -0
- package/dist/lower-third.js.map +1 -0
- package/dist/morph-shape.d.ts +42 -0
- package/dist/morph-shape.d.ts.map +1 -0
- package/dist/morph-shape.js +57 -0
- package/dist/morph-shape.js.map +1 -0
- package/dist/pie-card.d.ts +35 -0
- package/dist/pie-card.d.ts.map +1 -0
- package/dist/pie-card.js +168 -0
- package/dist/pie-card.js.map +1 -0
- package/dist/promo.d.ts +38 -0
- package/dist/promo.d.ts.map +1 -0
- package/dist/promo.js +61 -0
- package/dist/promo.js.map +1 -0
- package/dist/ranked-list.d.ts +38 -0
- package/dist/ranked-list.d.ts.map +1 -0
- package/dist/ranked-list.js +130 -0
- package/dist/ranked-list.js.map +1 -0
- package/dist/stat-block.d.ts +26 -0
- package/dist/stat-block.d.ts.map +1 -0
- package/dist/stat-block.js +92 -0
- package/dist/stat-block.js.map +1 -0
- package/dist/theme.d.ts +36 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +75 -0
- package/dist/theme.js.map +1 -0
- package/dist/tilted-showcase.d.ts +29 -0
- package/dist/tilted-showcase.d.ts.map +1 -0
- package/dist/tilted-showcase.js +106 -0
- package/dist/tilted-showcase.js.map +1 -0
- package/dist/trend-pill.d.ts +33 -0
- package/dist/trend-pill.d.ts.map +1 -0
- package/dist/trend-pill.js +83 -0
- package/dist/trend-pill.js.map +1 -0
- package/dist/zoom-rig.d.ts +27 -0
- package/dist/zoom-rig.d.ts.map +1 -0
- package/dist/zoom-rig.js +46 -0
- package/dist/zoom-rig.js.map +1 -0
- package/package.json +36 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for describing the origin of the Work and
|
|
141
|
+
reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Clipkit Contributors
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# @clipkit/patterns
|
|
2
|
+
|
|
3
|
+
> Authoring-time pattern library for ClipKit — composable motion-graphics units that emit primitive Source elements.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install @clipkit/patterns
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Patterns are TypeScript functions that take parameters and a named theme, returning arrays of primitive ClipKit protocol elements (text, shapes, groups). Use them to author data visualizations (stat blocks, bar charts, ranked lists), cinematic scenes (hero reveals, glass panels), and component units (lower thirds, tilted showcases). Each pattern is a reusable authoring-time abstraction; the runtime sees only the primitive elements it emits.
|
|
10
|
+
|
|
11
|
+
`promo()` is the sequence composer — it assembles multiple scene builders into a complete, renderable Source, handling timeline sequencing, crossfades, theme webfont registration, and shared camera + motion blur setup.
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { statBlock, barChartRow, promo } from '@clipkit/patterns';
|
|
17
|
+
|
|
18
|
+
// Define scenes as builders that receive composer-assigned timing and dimensions
|
|
19
|
+
const scenes = [
|
|
20
|
+
{
|
|
21
|
+
duration: 3,
|
|
22
|
+
build: (ctx) => {
|
|
23
|
+
const elements = [];
|
|
24
|
+
elements.push(...statBlock({
|
|
25
|
+
id: 'stat-1',
|
|
26
|
+
current: 2400,
|
|
27
|
+
previous: 1840,
|
|
28
|
+
label: 'Total views',
|
|
29
|
+
color: 'blue',
|
|
30
|
+
theme: 'mux',
|
|
31
|
+
x: 200,
|
|
32
|
+
y: 100,
|
|
33
|
+
width: 400,
|
|
34
|
+
time: ctx.time,
|
|
35
|
+
duration: ctx.duration,
|
|
36
|
+
layerBase: ctx.layer,
|
|
37
|
+
}));
|
|
38
|
+
return { type: 'group', id: ctx.id, elements };
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
// Compose into a renderable Source
|
|
44
|
+
const source = promo({
|
|
45
|
+
scenes,
|
|
46
|
+
theme: 'mux',
|
|
47
|
+
width: 1280,
|
|
48
|
+
height: 720,
|
|
49
|
+
});
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## API
|
|
53
|
+
|
|
54
|
+
**Data patterns** — single-unit visualizations, return `Element[]`:
|
|
55
|
+
- `statBlock(props)` — themed number + label + optional trend indicator
|
|
56
|
+
- `barChartRow(props)` — animated horizontal bar + value + label
|
|
57
|
+
- `rankedList(props)` — ranked items with positions and optional values
|
|
58
|
+
- `pieCard(props)` — pie chart segment visualization
|
|
59
|
+
- `headerBar(props)` — full-width header bar for data scenes
|
|
60
|
+
|
|
61
|
+
**Scene builders** — full-frame compositions that take `SceneCtx`:
|
|
62
|
+
- `statsScene`, `barsScene`, `rankingScene`, `pieScene` — pre-built data-dashboard layouts
|
|
63
|
+
|
|
64
|
+
**Component patterns** — reusable UI units:
|
|
65
|
+
- `introCard`, `lowerThird`, `tiltedShowcase`, `cameraOrbit`, `litSurface`, `heroReveal`, `glassPanel`, `ctaOutro`, `kineticHeadline`
|
|
66
|
+
|
|
67
|
+
**Composer**:
|
|
68
|
+
- `promo(opts)` — sequence scenes + theme into one renderable `Source`
|
|
69
|
+
|
|
70
|
+
**Theming**:
|
|
71
|
+
- `THEMES` — named bundles (mux, minimal, cinematic)
|
|
72
|
+
- `getPalette(theme, color)` — fetch color palette for a theme + color slot
|
|
73
|
+
- `getFonts(theme)` — fetch font family names for sans / mono / display
|
|
74
|
+
|
|
75
|
+
**Beat-sync utilities** — map @clipkit/music-analysis BeatMap to motion:
|
|
76
|
+
- `pulseToTempo`, `accentOnBeats`, `snapToBeat`, `revealOnBeat`, `slideOnBeat`
|
|
77
|
+
|
|
78
|
+
**Helpers**:
|
|
79
|
+
- `liquidMorph` — shape → path → shape transition with liquid blobs
|
|
80
|
+
- `trendPill`, `trendPct` — trend indicators
|
|
81
|
+
|
|
82
|
+
## License
|
|
83
|
+
|
|
84
|
+
Apache-2.0 · part of [ClipKit](https://clipkit.dev) · [source](https://github.com/clipkit-video/clipkit)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anchor-default.d.ts","sourceRoot":"","sources":["../src/anchor-default.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAajD,qFAAqF;AACrF,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,EAAE,CAGlE"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// centerAnchorDefault — re-assert the center anchor on composed pattern output.
|
|
2
|
+
//
|
|
3
|
+
// Clipkit patterns are authored CENTER-anchored: they position elements at
|
|
4
|
+
// x:W/2 / y:H/2 and rely on the anchor being 0.5. The runtime default anchor is
|
|
5
|
+
// now 0 (top-left) so that hand-authored x/y means the top-left corner (the CSS
|
|
6
|
+
// convention — see ANCHOR-CONVENTION-PLAN.md). To keep the patterns' layout
|
|
7
|
+
// unchanged, stamp an explicit x_anchor/y_anchor of 0.5 onto every element that
|
|
8
|
+
// doesn't set one, recursing into group children and group masks. Elements that
|
|
9
|
+
// set an anchor explicitly (e.g. a left-aligned logo with x_anchor:0) keep it.
|
|
10
|
+
//
|
|
11
|
+
// Applied by promo() — the composer create_promo and `clipkit new` both use.
|
|
12
|
+
function visit(el) {
|
|
13
|
+
const e = el;
|
|
14
|
+
if (e.x_anchor === undefined)
|
|
15
|
+
e.x_anchor = 0.5;
|
|
16
|
+
if (e.y_anchor === undefined)
|
|
17
|
+
e.y_anchor = 0.5;
|
|
18
|
+
if (e.type === 'group') {
|
|
19
|
+
if (Array.isArray(e.elements))
|
|
20
|
+
for (const c of e.elements)
|
|
21
|
+
visit(c);
|
|
22
|
+
const mask = e.mask;
|
|
23
|
+
if (mask && Array.isArray(mask.elements))
|
|
24
|
+
for (const c of mask.elements)
|
|
25
|
+
visit(c);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/** Mutate `elements` (recursively) to default any missing anchor to 0.5 (center). */
|
|
29
|
+
export function centerAnchorDefault(elements) {
|
|
30
|
+
for (const el of elements)
|
|
31
|
+
visit(el);
|
|
32
|
+
return elements;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=anchor-default.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anchor-default.js","sourceRoot":"","sources":["../src/anchor-default.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,EAAE;AACF,2EAA2E;AAC3E,gFAAgF;AAChF,gFAAgF;AAChF,4EAA4E;AAC5E,gFAAgF;AAChF,gFAAgF;AAChF,+EAA+E;AAC/E,EAAE;AACF,6EAA6E;AAI7E,SAAS,KAAK,CAAC,EAAW;IACxB,MAAM,CAAC,GAAG,EAA6B,CAAC;IACxC,IAAI,CAAC,CAAC,QAAQ,KAAK,SAAS;QAAE,CAAC,CAAC,QAAQ,GAAG,GAAG,CAAC;IAC/C,IAAI,CAAC,CAAC,QAAQ,KAAK,SAAS;QAAE,CAAC,CAAC,QAAQ,GAAG,GAAG,CAAC;IAC/C,IAAI,CAAC,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QACvB,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC;YAAE,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,QAAQ;gBAAE,KAAK,CAAC,CAAY,CAAC,CAAC;QAC/E,MAAM,IAAI,GAAG,CAAC,CAAC,IAA0C,CAAC;QAC1D,IAAI,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC;YAAE,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,QAAQ;gBAAE,KAAK,CAAC,CAAY,CAAC,CAAC;IAC/F,CAAC;AACH,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,mBAAmB,CAAC,QAAmB;IACrD,KAAK,MAAM,EAAE,IAAI,QAAQ;QAAE,KAAK,CAAC,EAAE,CAAC,CAAC;IACrC,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { Element, PathDef } from '@clipkit/protocol';
|
|
2
|
+
import { type ColorName, type ThemeName } from './theme.js';
|
|
3
|
+
export interface BarChartRowProps {
|
|
4
|
+
id: string;
|
|
5
|
+
/** Numeric value driving the count-up + bar width. */
|
|
6
|
+
value: number;
|
|
7
|
+
/** Maximum across the dataset — bar width = value/max × row width. */
|
|
8
|
+
max: number;
|
|
9
|
+
/**
|
|
10
|
+
* Previous-period value. If set, a trend pill is rendered to the right.
|
|
11
|
+
*/
|
|
12
|
+
previous?: number;
|
|
13
|
+
/** Right-side label (e.g. "Phone"). */
|
|
14
|
+
label: string;
|
|
15
|
+
/**
|
|
16
|
+
* Optional icon definition rendered on the left. Pass `{ viewBox, paths }`
|
|
17
|
+
* — typically the source data for an path shape.
|
|
18
|
+
*/
|
|
19
|
+
icon?: {
|
|
20
|
+
viewBox: [number, number, number, number];
|
|
21
|
+
paths: PathDef[];
|
|
22
|
+
};
|
|
23
|
+
color: ColorName;
|
|
24
|
+
theme?: ThemeName;
|
|
25
|
+
/** Top-left x of the row. */
|
|
26
|
+
x: number;
|
|
27
|
+
/** Top-left y of the row. */
|
|
28
|
+
y: number;
|
|
29
|
+
/** Row width — usually the body content width. */
|
|
30
|
+
width: number;
|
|
31
|
+
/** Row height (defaults to 168 to match the Mux look). */
|
|
32
|
+
height?: number;
|
|
33
|
+
time: number;
|
|
34
|
+
duration: number;
|
|
35
|
+
/**
|
|
36
|
+
* Index used for the cascading entrance stagger (row 0 enters first,
|
|
37
|
+
* row 1 a couple frames later, etc.). Pass i for the i-th row in a list.
|
|
38
|
+
*/
|
|
39
|
+
staggerIndex?: number;
|
|
40
|
+
layerBase: number;
|
|
41
|
+
}
|
|
42
|
+
export declare function barChartRow(props: BarChartRowProps): Element[];
|
|
43
|
+
//# sourceMappingURL=bar-chart-row.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bar-chart-row.d.ts","sourceRoot":"","sources":["../src/bar-chart-row.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAwB,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAGlF,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,sDAAsD;IACtD,KAAK,EAAE,MAAM,CAAC;IACd,sEAAsE;IACtE,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,IAAI,CAAC,EAAE;QAAE,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QAAC,KAAK,EAAE,OAAO,EAAE,CAAA;KAAE,CAAC;IACvE,KAAK,EAAE,SAAS,CAAC;IACjB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,6BAA6B;IAC7B,CAAC,EAAE,MAAM,CAAC;IACV,6BAA6B;IAC7B,CAAC,EAAE,MAAM,CAAC;IACV,kDAAkD;IAClD,KAAK,EAAE,MAAM,CAAC;IACd,0DAA0D;IAC1D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;CACnB;AAID,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,EAAE,CA+I9D"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
// BarChartRow — single horizontal data row with an animated background
|
|
2
|
+
// "measure" bar, top border, value, and optional icon + trend pill. The
|
|
3
|
+
// unit used in data-dashboard "views by device" scenes and similar.
|
|
4
|
+
//
|
|
5
|
+
// The measure bar animates its width property over 1.6s with
|
|
6
|
+
// ease-out-quart, approximating a heavily-overdamped
|
|
7
|
+
// spring({damping: 60}) — fast start, long slow tail. The value is plain
|
|
8
|
+
// text (the protocol has no text-content count-up).
|
|
9
|
+
import { getFonts, getPalette } from './theme.js';
|
|
10
|
+
import { trendPct, trendPill } from './trend-pill.js';
|
|
11
|
+
const FRAME = 1 / 30; // seconds per frame at 30 fps
|
|
12
|
+
export function barChartRow(props) {
|
|
13
|
+
const { id, value, max, previous, label, icon, color, x, y, width, time, duration, layerBase, } = props;
|
|
14
|
+
const theme = props.theme ?? 'mux';
|
|
15
|
+
const palette = getPalette(theme, color);
|
|
16
|
+
const fonts = getFonts(theme);
|
|
17
|
+
const height = props.height ?? 168;
|
|
18
|
+
const i = props.staggerIndex ?? 0;
|
|
19
|
+
const stagger = (10 + 8 * i) * FRAME;
|
|
20
|
+
const slide = [
|
|
21
|
+
{ type: 'fade-in', duration: 0.33, time: stagger },
|
|
22
|
+
{ type: 'slide-up-in', duration: 0.6, easing: 'ease-out-cubic', time: stagger },
|
|
23
|
+
];
|
|
24
|
+
const out = [];
|
|
25
|
+
// Animated measure bar — width grows 0 → (value/max) × row width.
|
|
26
|
+
const measurePct = max > 0 ? (value / max) * 100 : 0;
|
|
27
|
+
const measureFullW = (width * measurePct) / 100;
|
|
28
|
+
out.push({
|
|
29
|
+
id: `${id}-measure`,
|
|
30
|
+
type: 'shape',
|
|
31
|
+
layer: layerBase,
|
|
32
|
+
time: time + stagger + 10 * FRAME,
|
|
33
|
+
duration: duration - (stagger + 10 * FRAME),
|
|
34
|
+
shape: 'rectangle',
|
|
35
|
+
x,
|
|
36
|
+
y,
|
|
37
|
+
x_anchor: 0,
|
|
38
|
+
y_anchor: 0,
|
|
39
|
+
width: measureFullW,
|
|
40
|
+
height,
|
|
41
|
+
fill_color: palette.measure,
|
|
42
|
+
keyframe_animations: [
|
|
43
|
+
{
|
|
44
|
+
property: 'width',
|
|
45
|
+
keyframes: [
|
|
46
|
+
{ time: 0, value: 0 },
|
|
47
|
+
{ time: 1.6, value: measureFullW, easing: 'ease-out-quart' },
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
});
|
|
52
|
+
// Top border line.
|
|
53
|
+
out.push({
|
|
54
|
+
id: `${id}-border`,
|
|
55
|
+
type: 'shape',
|
|
56
|
+
layer: layerBase + 1,
|
|
57
|
+
time,
|
|
58
|
+
duration,
|
|
59
|
+
shape: 'rectangle',
|
|
60
|
+
x: x + width / 2,
|
|
61
|
+
y,
|
|
62
|
+
x_anchor: '50%',
|
|
63
|
+
y_anchor: '50%',
|
|
64
|
+
width,
|
|
65
|
+
height: 3,
|
|
66
|
+
fill_color: palette.accent,
|
|
67
|
+
animations: slide,
|
|
68
|
+
});
|
|
69
|
+
// Icon on the left, if provided.
|
|
70
|
+
if (icon) {
|
|
71
|
+
const iconAspect = icon.viewBox[2] / icon.viewBox[3];
|
|
72
|
+
const iconHeight = 70;
|
|
73
|
+
const iconWidth = iconHeight * iconAspect;
|
|
74
|
+
out.push({
|
|
75
|
+
id: `${id}-icon`,
|
|
76
|
+
type: 'shape',
|
|
77
|
+
layer: layerBase + 2,
|
|
78
|
+
time,
|
|
79
|
+
duration,
|
|
80
|
+
x: x + 70,
|
|
81
|
+
y: y + height / 2,
|
|
82
|
+
x_anchor: '50%',
|
|
83
|
+
y_anchor: '50%',
|
|
84
|
+
width: iconWidth,
|
|
85
|
+
height: iconHeight,
|
|
86
|
+
view_box: icon.viewBox,
|
|
87
|
+
paths: icon.paths,
|
|
88
|
+
animations: slide,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
// Value (plain text; the protocol has no text-content count-up).
|
|
92
|
+
out.push({
|
|
93
|
+
id: `${id}-value`,
|
|
94
|
+
type: 'text',
|
|
95
|
+
layer: layerBase + 3,
|
|
96
|
+
time: time + stagger,
|
|
97
|
+
duration: duration - stagger,
|
|
98
|
+
text: new Intl.NumberFormat('en-US').format(value),
|
|
99
|
+
x: x + 200,
|
|
100
|
+
y: y + height / 2,
|
|
101
|
+
x_anchor: 0,
|
|
102
|
+
font_family: fonts.sans,
|
|
103
|
+
font_size: 80,
|
|
104
|
+
font_weight: '300',
|
|
105
|
+
fill_color: palette.text,
|
|
106
|
+
animations: [{ type: 'fade-in', duration: 0.4 }],
|
|
107
|
+
});
|
|
108
|
+
// Right-side label.
|
|
109
|
+
out.push({
|
|
110
|
+
id: `${id}-label`,
|
|
111
|
+
type: 'text',
|
|
112
|
+
layer: layerBase + 4,
|
|
113
|
+
time: time + stagger + 5 * FRAME,
|
|
114
|
+
duration: duration - (stagger + 5 * FRAME),
|
|
115
|
+
text: label,
|
|
116
|
+
x: x + 900,
|
|
117
|
+
y: y + height / 2,
|
|
118
|
+
x_anchor: 0,
|
|
119
|
+
font_family: fonts.sans,
|
|
120
|
+
font_size: 36,
|
|
121
|
+
font_weight: '400',
|
|
122
|
+
fill_color: palette.text,
|
|
123
|
+
animations: [{ type: 'fade-in', duration: 0.4 }],
|
|
124
|
+
});
|
|
125
|
+
// Optional trend pill.
|
|
126
|
+
if (typeof previous === 'number') {
|
|
127
|
+
out.push(...trendPill({
|
|
128
|
+
id: `${id}-pill`,
|
|
129
|
+
layerBase: layerBase + 5,
|
|
130
|
+
time: time + stagger + 8 * FRAME,
|
|
131
|
+
duration: duration - (stagger + 8 * FRAME),
|
|
132
|
+
cx: x + width - 240,
|
|
133
|
+
cy: y + height / 2,
|
|
134
|
+
color,
|
|
135
|
+
theme,
|
|
136
|
+
delta: trendPct(value, previous),
|
|
137
|
+
width: 440,
|
|
138
|
+
height: 56,
|
|
139
|
+
}));
|
|
140
|
+
}
|
|
141
|
+
return out;
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=bar-chart-row.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bar-chart-row.js","sourceRoot":"","sources":["../src/bar-chart-row.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,wEAAwE;AACxE,oEAAoE;AACpE,EAAE;AACF,6DAA6D;AAC7D,qDAAqD;AACrD,yEAAyE;AACzE,oDAAoD;AAGpD,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAkC,MAAM,YAAY,CAAC;AAClF,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAuCtD,MAAM,KAAK,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,8BAA8B;AAEpD,MAAM,UAAU,WAAW,CAAC,KAAuB;IACjD,MAAM,EACJ,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,GACrF,GAAG,KAAK,CAAC;IACV,MAAM,KAAK,GAAG,KAAK,CAAC,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AS,EAAE,EAAE;QACb,WAAW,EAAE,KAAK;QAClB,UAAU,EAAE,OAAO,CAAC,IAAI;QACxB,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC;KACjD,CAAC,CAAC;IAEH,uBAAuB;IACvB,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACjC,GAAG,CAAC,IAAI,CACN,GAAG,SAAS,CAAC;YACX,EAAE,EAAE,GAAG,EAAE,OAAO;YAChB,SAAS,EAAE,SAAS,GAAG,CAAC;YACxB,IAAI,EAAE,IAAI,GAAG,OAAO,GAAG,CAAC,GAAG,KAAK;YAChC,QAAQ,EAAE,QAAQ,GAAG,CAAC,OAAO,GAAG,CAAC,GAAG,KAAK,CAAC;YAC1C,EAAE,EAAE,CAAC,GAAG,KAAK,GAAG,GAAG;YACnB,EAAE,EAAE,CAAC,GAAG,MAAM,GAAG,CAAC;YAClB,KAAK;YACL,KAAK;YACL,KAAK,EAAE,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;YAChC,KAAK,EAAE,GAAG;YACV,MAAM,EAAE,EAAE;SACX,CAAC,CACH,CAAC;IACJ,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { BeatMap } from '@clipkit/music-analysis';
|
|
2
|
+
import type { Easing, KeyframeAnimation } from '@clipkit/protocol';
|
|
3
|
+
export interface PulseToTempoOptions {
|
|
4
|
+
/** Resting value (the property's baseline). Default 1. */
|
|
5
|
+
baseline?: number;
|
|
6
|
+
/** Height of each beat pulse, added to `baseline`. Default 0.08. */
|
|
7
|
+
amp?: number;
|
|
8
|
+
/** How sharply each pulse decays before the next beat — higher = snappier,
|
|
9
|
+
* more percussive. Default 6. */
|
|
10
|
+
decay?: number;
|
|
11
|
+
/** Pulses per beat. 2 = eighth-notes, 0.5 = every other beat. Default 1. */
|
|
12
|
+
subdivision?: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A pure Tier-A expression that pulses on the beat — a sharp rise exactly on
|
|
16
|
+
* each beat that decays before the next. Needs only `bpm` + `phase`, so it works
|
|
17
|
+
* off a synthesized {@link beatGrid} as happily as a detected map. Drop the
|
|
18
|
+
* result on any numeric property (`scale`, `opacity`, `blur_radius`, …):
|
|
19
|
+
*
|
|
20
|
+
* ```ts
|
|
21
|
+
* { ...logo, scale: pulseToTempo(map, { amp: 0.06 }) }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function pulseToTempo(map: BeatMap, opts?: PulseToTempoOptions): {
|
|
25
|
+
expr: string;
|
|
26
|
+
};
|
|
27
|
+
export interface AccentOnBeatsOptions {
|
|
28
|
+
/** Property to drive. Default "scale". */
|
|
29
|
+
property?: string;
|
|
30
|
+
/** Sync to every beat or only bar downbeats. Default "beats". */
|
|
31
|
+
on?: 'beats' | 'downbeats';
|
|
32
|
+
/** Resting value between hits. Default 1. */
|
|
33
|
+
base?: number;
|
|
34
|
+
/** Peak offset from `base` at full strength. The actual peak scales with each
|
|
35
|
+
* marker's `strength`, so downbeats hit harder. Default 0.18. */
|
|
36
|
+
amp?: number;
|
|
37
|
+
/** Anticipation lead-in before the hit, seconds. Default 0.05. */
|
|
38
|
+
attack?: number;
|
|
39
|
+
/** Time to ease back to `base` after the hit, seconds. Default 0.2. */
|
|
40
|
+
settle?: number;
|
|
41
|
+
/** Easing for both the rise and the settle. Default "ease-out-cubic". */
|
|
42
|
+
easing?: Easing;
|
|
43
|
+
/** Ignore markers weaker than this (0..1). Default 0 (all). */
|
|
44
|
+
minStrength?: number;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Keyframes that punch a property on each beat — the discrete "hit" sync. Each
|
|
48
|
+
* marker gets an anticipation keyframe, a peak ON the beat (scaled by the
|
|
49
|
+
* marker's strength so downbeats land bigger), and a settle back to rest.
|
|
50
|
+
*
|
|
51
|
+
* Returns one {@link KeyframeAnimation}; push it onto an element's
|
|
52
|
+
* `keyframe_animations`. Times are in the element's local seconds — put the
|
|
53
|
+
* accented element at `time: 0` so they line up with the beat map's clock.
|
|
54
|
+
*
|
|
55
|
+
* ```ts
|
|
56
|
+
* { ...title, keyframe_animations: [accentOnBeats(map, { on: 'downbeats', amp: 0.22 })] }
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare function accentOnBeats(map: BeatMap, opts?: AccentOnBeatsOptions): KeyframeAnimation;
|
|
60
|
+
/** Snap a time (seconds) to the nearest beat — or downbeat — in the map, so an
|
|
61
|
+
* authored moment locks to the grid instead of drifting near it. */
|
|
62
|
+
export declare function snapToBeat(map: BeatMap, t: number, which?: 'beat' | 'downbeat'): number;
|
|
63
|
+
export interface RevealOnBeatOptions {
|
|
64
|
+
/** Fade-in seconds; the reveal is fully present ON `enter`. Default 0.28. */
|
|
65
|
+
fadeIn?: number;
|
|
66
|
+
/** Beat time to clear at; omit to stay to the end. */
|
|
67
|
+
exit?: number;
|
|
68
|
+
/** Fade-out seconds. Default 0.28. */
|
|
69
|
+
fadeOut?: number;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Opacity {expr} that is fully present ON beat `enter` and (optionally) fully
|
|
73
|
+
* CLEARED by beat `exit` — both edges land on a beat. On a shared boundary the
|
|
74
|
+
* old screen is gone exactly as the new one arrives: a clean cut, not a muddy
|
|
75
|
+
* overlap. Pair with {@link slideOnBeat} for a slide arriving on the same beat.
|
|
76
|
+
*/
|
|
77
|
+
export declare function revealOnBeat(enter: number, opts?: RevealOnBeatOptions): {
|
|
78
|
+
expr: string;
|
|
79
|
+
};
|
|
80
|
+
export interface SlideOnBeatOptions {
|
|
81
|
+
/** Start offset in px (element begins this far from `target`). Default 60. */
|
|
82
|
+
from?: number;
|
|
83
|
+
/** Travel seconds; the slide ARRIVES on `enter`. Default 0.45. */
|
|
84
|
+
dur?: number;
|
|
85
|
+
/** Beat time to push back out; omit to stay put. */
|
|
86
|
+
exit?: number;
|
|
87
|
+
/** Exit offset px (default = `from`) and seconds (default 0.4). */
|
|
88
|
+
exitTo?: number;
|
|
89
|
+
exitDur?: number;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* A coordinate {expr} for a slide that ARRIVES at `target` px on beat `enter`
|
|
93
|
+
* (coming from `target + from`), and optionally pushes back out so it has fully
|
|
94
|
+
* left BY beat `exit`. Use directly as an element's `x` or `y`. The arrival/
|
|
95
|
+
* departure — not a wobble — is the sync, so it reads on the beat without
|
|
96
|
+
* distracting while the element rests.
|
|
97
|
+
*/
|
|
98
|
+
export declare function slideOnBeat(target: number, enter: number, opts?: SlideOnBeatOptions): {
|
|
99
|
+
expr: string;
|
|
100
|
+
};
|
|
101
|
+
//# sourceMappingURL=beat-sync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"beat-sync.d.ts","sourceRoot":"","sources":["../src/beat-sync.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,OAAO,EAAU,MAAM,yBAAyB,CAAC;AAC/D,OAAO,KAAK,EAAE,MAAM,EAAY,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAM7E,MAAM,WAAW,mBAAmB;IAClC,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oEAAoE;IACpE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;sCACkC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4EAA4E;IAC5E,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAC1B,GAAG,EAAE,OAAO,EACZ,IAAI,GAAE,mBAAwB,GAC7B;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAWlB;AAID,MAAM,WAAW,oBAAoB;IACnC,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iEAAiE;IACjE,EAAE,CAAC,E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