Skip to content

armgit / fuobe

Public Imported from GitHub
0

The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.

Kinetic: every template redrawn as a moving poster, with its own type pairing, layered light and depth, and eight new templates

Adarsh9b6716ef0a30
diff --git a/next.config.ts b/next.config.ts
index 45a5aa7f..7d66c246 100644
--- a/next.config.ts
+++ b/next.config.ts
@@ -47,6 +47,10 @@ const nextConfig: NextConfig = {
// the background.
{ source: "/previews/:path*", has: [COVER_VERSION], headers: [{ key: "Cache-Control", value: "public, max-age=31536000, s-maxage=86400, immutable" }] },
{ source: "/previews/:path*", missing: [COVER_VERSION], headers: [{ key: "Cache-Control", value: "public, max-age=86400, stale-while-revalidate=604800" }] },
+ // The motion templates' own type faces (public/fonts): the pages ask for each with its content version (?v=), so
+ // the same rules as the covers.
+ { source: "/fonts/:path*", has: [COVER_VERSION], headers: [{ key: "Cache-Control", value: "public, max-age=31536000, s-maxage=86400, immutable" }] },
+ { source: "/fonts/:path*", missing: [COVER_VERSION], headers: [{ key: "Cache-Control", value: "public, max-age=86400, stale-while-revalidate=604800" }] },
// The pages' examples (public/examples): a published file is never replaced, and its display URL carries its
// version too. The same rules as the covers.
{ source: "/examples/:path*", has: [COVER_VERSION], headers: [{ key: "Cache-Control", value: "public, max-age=31536000, s-maxage=86400, immutable" }] },
diff --git a/public/fonts/kinetic/anton.woff2 b/public/fonts/kinetic/anton.woff2
new file mode 100644
index 00000000..6ab2a4e9
Binary files /dev/null and b/public/fonts/kinetic/anton.woff2 differ
diff --git a/public/fonts/kinetic/archivo-condensed.woff2 b/public/fonts/kinetic/archivo-condensed.woff2
new file mode 100644
index 00000000..046d9172
Binary files /dev/null and b/public/fonts/kinetic/archivo-condensed.woff2 differ
diff --git a/public/fonts/kinetic/archivo-expanded.woff2 b/public/fonts/kinetic/archivo-expanded.woff2
new file mode 100644
index 00000000..1cea0647
Binary files /dev/null and b/public/fonts/kinetic/archivo-expanded.woff2 differ
diff --git a/public/fonts/kinetic/bagel-fat.woff2 b/public/fonts/kinetic/bagel-fat.woff2
new file mode 100644
index 00000000..348779ad
Binary files /dev/null and b/public/fonts/kinetic/bagel-fat.woff2 differ
diff --git a/public/fonts/kinetic/ballet.woff2 b/public/fonts/kinetic/ballet.woff2
new file mode 100644
index 00000000..0d5d41ba
Binary files /dev/null and b/public/fonts/kinetic/ballet.woff2 differ
diff --git a/public/fonts/kinetic/big-shoulders.woff2 b/public/fonts/kinetic/big-shoulders.woff2
new file mode 100644
index 00000000..9fd9eeb0
Binary files /dev/null and b/public/fonts/kinetic/big-shoulders.woff2 differ
diff --git a/public/fonts/kinetic/bodoni-moda-italic.woff2 b/public/fonts/kinetic/bodoni-moda-italic.woff2
new file mode 100644
index 00000000..cd6dcec4
Binary files /dev/null and b/public/fonts/kinetic/bodoni-moda-italic.woff2 differ
diff --git a/public/fonts/kinetic/bodoni-moda.woff2 b/public/fonts/kinetic/bodoni-moda.woff2
new file mode 100644
index 00000000..3cc20618
Binary files /dev/null and b/public/fonts/kinetic/bodoni-moda.woff2 differ
diff --git a/public/fonts/kinetic/boldonse.woff2 b/public/fonts/kinetic/boldonse.woff2
new file mode 100644
index 00000000..d5a49016
Binary files /dev/null and b/public/fonts/kinetic/boldonse.woff2 differ
diff --git a/public/fonts/kinetic/bricolage.woff2 b/public/fonts/kinetic/bricolage.woff2
new file mode 100644
index 00000000..5fdc21b0
Binary files /dev/null and b/public/fonts/kinetic/bricolage.woff2 differ
diff --git a/public/fonts/kinetic/caveat.woff2 b/public/fonts/kinetic/caveat.woff2
new file mode 100644
index 00000000..8b6e6305
Binary files /dev/null and b/public/fonts/kinetic/caveat.woff2 differ
diff --git a/public/fonts/kinetic/dela-gothic.woff2 b/public/fonts/kinetic/dela-gothic.woff2
new file mode 100644
index 00000000..92450e5e
Binary files /dev/null and b/public/fonts/kinetic/dela-gothic.woff2 differ
diff --git a/public/fonts/kinetic/fraunces-display.woff2 b/public/fonts/kinetic/fraunces-display.woff2
new file mode 100644
index 00000000..c023cedd
Binary files /dev/null and b/public/fonts/kinetic/fraunces-display.woff2 differ
diff --git a/public/fonts/kinetic/fraunces-soft-italic.woff2 b/public/fonts/kinetic/fraunces-soft-italic.woff2
new file mode 100644
index 00000000..a802fc9b
Binary files /dev/null and b/public/fonts/kinetic/fraunces-soft-italic.woff2 differ
diff --git a/public/fonts/kinetic/fraunces-soft.woff2 b/public/fonts/kinetic/fraunces-soft.woff2
new file mode 100644
index 00000000..163ad4ee
Binary files /dev/null and b/public/fonts/kinetic/fraunces-soft.woff2 differ
diff --git a/public/fonts/kinetic/geist-mono.woff2 b/public/fonts/kinetic/geist-mono.woff2
new file mode 100644
index 00000000..6a07884c
Binary files /dev/null and b/public/fonts/kinetic/geist-mono.woff2 differ
diff --git a/public/fonts/kinetic/geist.woff2 b/public/fonts/kinetic/geist.woff2
new file mode 100644
index 00000000..5b6000be
Binary files /dev/null and b/public/fonts/kinetic/geist.woff2 differ
diff --git a/public/fonts/kinetic/gloock.woff2 b/public/fonts/kinetic/gloock.woff2
new file mode 100644
index 00000000..a877cb33
Binary files /dev/null and b/public/fonts/kinetic/gloock.woff2 differ
diff --git a/public/fonts/kinetic/instrument-sans.woff2 b/public/fonts/kinetic/instrument-sans.woff2
new file mode 100644
index 00000000..6e910432
Binary files /dev/null and b/public/fonts/kinetic/instrument-sans.woff2 differ
diff --git a/public/fonts/kinetic/instrument-serif-italic.woff2 b/public/fonts/kinetic/instrument-serif-italic.woff2
new file mode 100644
index 00000000..e4c65e3b
Binary files /dev/null and b/public/fonts/kinetic/instrument-serif-italic.woff2 differ
diff --git a/public/fonts/kinetic/instrument-serif.woff2 b/public/fonts/kinetic/instrument-serif.woff2
new file mode 100644
index 00000000..4743e82a
Binary files /dev/null and b/public/fonts/kinetic/instrument-serif.woff2 differ
diff --git a/public/fonts/kinetic/inter-tight.woff2 b/public/fonts/kinetic/inter-tight.woff2
new file mode 100644
index 00000000..59c50d89
Binary files /dev/null and b/public/fonts/kinetic/inter-tight.woff2 differ
diff --git a/public/fonts/kinetic/italiana.woff2 b/public/fonts/kinetic/italiana.woff2
new file mode 100644
index 00000000..6750f637
Binary files /dev/null and b/public/fonts/kinetic/italiana.woff2 differ
diff --git a/public/fonts/kinetic/league-gothic-condensed.woff2 b/public/fonts/kinetic/league-gothic-condensed.woff2
new file mode 100644
index 00000000..f2d606ba
Binary files /dev/null and b/public/fonts/kinetic/league-gothic-condensed.woff2 differ
diff --git a/public/fonts/kinetic/league-gothic.woff2 b/public/fonts/kinetic/league-gothic.woff2
new file mode 100644
index 00000000..85f41fb1
Binary files /dev/null and b/public/fonts/kinetic/league-gothic.woff2 differ
diff --git a/public/fonts/kinetic/licences/anton-OFL.txt b/public/fonts/kinetic/licences/anton-OFL.txt
new file mode 100644
index 00000000..efd0dd80
--- /dev/null
+++ b/public/fonts/kinetic/licences/anton-OFL.txt
@@ -0,0 +1,93 @@
+Copyright 2020 The Anton Project Authors (https://github.com/googlefonts/AntonFont.git)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+http://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/public/fonts/kinetic/licences/archivo-OFL.txt b/public/fonts/kinetic/licences/archivo-OFL.txt
new file mode 100644
index 00000000..8597481e
--- /dev/null
+++ b/public/fonts/kinetic/licences/archivo-OFL.txt
@@ -0,0 +1,93 @@
+Copyright 2020 The Archivo Project Authors (https://github.com/Omnibus-Type/Archivo)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+http://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/public/fonts/kinetic/licences/bagelfatone-OFL.txt b/public/fonts/kinetic/licences/bagelfatone-OFL.txt
new file mode 100644
index 00000000..2b307fb2
--- /dev/null
+++ b/public/fonts/kinetic/licences/bagelfatone-OFL.txt
@@ -0,0 +1,93 @@
+Copyright 2022 The Bagel Fat Project Authors (https://github.com/JAMO-TYPEFACE/BagelFat)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+http://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/public/fonts/kinetic/licences/ballet-OFL.txt b/public/fonts/kinetic/licences/ballet-OFL.txt
new file mode 100644
index 00000000..cda46aa5
--- /dev/null
+++ b/public/fonts/kinetic/licences/ballet-OFL.txt
@@ -0,0 +1,93 @@
+Copyright 2020 The Ballet Project Authors (https://github.com/Omnibus-Type/Ballet)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+https://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/public/fonts/kinetic/licences/bigshouldersdisplay-OFL.txt b/public/fonts/kinetic/licences/bigshouldersdisplay-OFL.txt
new file mode 100644
index 00000000..b5a4e0df
--- /dev/null
+++ b/public/fonts/kinetic/licences/bigshouldersdisplay-OFL.txt
@@ -0,0 +1,93 @@
+Copyright 2019 The Big Shoulders Project Authors (https://github.com/xotypeco/big_shoulders)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+http://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/public/fonts/kinetic/licences/bodonimoda-OFL.txt b/public/fonts/kinetic/licences/bodonimoda-OFL.txt
new file mode 100644
index 00000000..973cec73
--- /dev/null
+++ b/public/fonts/kinetic/licences/bodonimoda-OFL.txt
@@ -0,0 +1,93 @@
+Copyright 2020 The Bodoni Moda Project Authors (https://github.com/indestructible-type/Bodoni)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+https://openfontlicense.org/
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/public/fonts/kinetic/licences/boldonse-OFL.txt b/public/fonts/kinetic/licences/boldonse-OFL.txt
new file mode 100644
index 00000000..1890cb1c
--- /dev/null
+++ b/public/fonts/kinetic/licences/boldonse-OFL.txt
@@ -0,0 +1,93 @@
+Copyright 2024 The Boldonse Project Authors (https://github.com/googlefonts/boldonse)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+https://openfontlicense.org
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/public/fonts/kinetic/licences/bricolagegrotesque-OFL.txt b/public/fonts/kinetic/licences/bricolagegrotesque-OFL.txt
new file mode 100644
index 00000000..a397658a
--- /dev/null
+++ b/public/fonts/kinetic/licences/bricolagegrotesque-OFL.txt
@@ -0,0 +1,93 @@
+Copyright 2022 The Bricolage Grotesque Project Authors (https://github.com/ateliertriay/bricolage)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+https://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/public/fonts/kinetic/licences/caveat-OFL.txt b/public/fonts/kinetic/licences/caveat-OFL.txt
new file mode 100644
index 00000000..6e5220c9
--- /dev/null
+++ b/public/fonts/kinetic/licences/caveat-OFL.txt
@@ -0,0 +1,93 @@
+Copyright 2014 The Caveat Project Authors (https://github.com/googlefonts/caveat)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+http://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/public/fonts/kinetic/licences/delagothicone-OFL.txt b/public/fonts/kinetic/licences/delagothicone-OFL.txt
new file mode 100644
index 00000000..87fae845
--- /dev/null
+++ b/public/fonts/kinetic/licences/delagothicone-OFL.txt
@@ -0,0 +1,93 @@
+Copyright 2020 The Dela Gothic Project Authors (https://github.com/syakuzen/DelaGothic)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+https://openfontlicense.org
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/public/fonts/kinetic/licences/fraunces-OFL.txt b/public/fonts/kinetic/licences/fraunces-OFL.txt
new file mode 100644
index 00000000..22fa7ce5
--- /dev/null
+++ b/public/fonts/kinetic/licences/fraunces-OFL.txt
@@ -0,0 +1,93 @@
+Copyright 2018 The Fraunces Project Authors (https://github.com/undercasetype/Fraunces)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+http://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/public/fonts/kinetic/licences/geist-OFL.txt b/public/fonts/kinetic/licences/geist-OFL.txt
new file mode 100644
index 00000000..61f6f4b7
--- /dev/null
+++ b/public/fonts/kinetic/licences/geist-OFL.txt
@@ -0,0 +1,93 @@
+Copyright 2024 The Geist Project Authors (https://github.com/vercel/geist-font.git)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+https://openfontlicense.org
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
\ No newline at end of file
diff --git a/public/fonts/kinetic/licences/geistmono-OFL.txt b/public/fonts/kinetic/licences/geistmono-OFL.txt
new file mode 100644
index 00000000..61f6f4b7
--- /dev/null
+++ b/public/fonts/kinetic/licences/geistmono-OFL.txt
@@ -0,0 +1,93 @@
+Copyright 2024 The Geist Project Authors (https://github.com/vercel/geist-font.git)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+https://openfontlicense.org
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
\ No newline at end of file
diff --git a/public/fonts/kinetic/licences/gloock-OFL.txt b/public/fonts/kinetic/licences/gloock-OFL.txt
new file mode 100644
index 00000000..3a6f194d
--- /dev/null
+++ b/public/fonts/kinetic/licences/gloock-OFL.txt
@@ -0,0 +1,93 @@
+Copyright 2022 The Gloock Project Authors (https://github.com/duartp/gloock)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+https://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/public/fonts/kinetic/licences/instrumentsans-OFL.txt b/public/fonts/kinetic/licences/instrumentsans-OFL.txt
new file mode 100644
index 00000000..26bd2f95
--- /dev/null
+++ b/public/fonts/kinetic/licences/instrumentsans-OFL.txt
@@ -0,0 +1,93 @@
+Copyright 2022 The Instrument Sans Project Authors (https://github.com/Instrument/instrument-sans)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+https://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/public/fonts/kinetic/licences/instrumentserif-OFL.txt b/public/fonts/kinetic/licences/instrumentserif-OFL.txt
new file mode 100644
index 00000000..669ce791
--- /dev/null
+++ b/public/fonts/kinetic/licences/instrumentserif-OFL.txt
@@ -0,0 +1,93 @@
+Copyright 2022 The Instrument Serif Project Authors (https://github.com/Instrument/instrument-serif)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+https://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/public/fonts/kinetic/licences/intertight-OFL.txt b/public/fonts/kinetic/licences/intertight-OFL.txt
new file mode 100644
index 00000000..18d0da5d
--- /dev/null
+++ b/public/fonts/kinetic/licences/intertight-OFL.txt
@@ -0,0 +1,93 @@
+Copyright 2022 The Inter Project Authors (https://github.com/rsms/inter-tight)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+https://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/public/fonts/kinetic/licences/italiana-OFL.txt b/public/fonts/kinetic/licences/italiana-OFL.txt
new file mode 100644
index 00000000..76add94c
--- /dev/null
+++ b/public/fonts/kinetic/licences/italiana-OFL.txt
@@ -0,0 +1,93 @@
+Copyright (c) 2011, Santiago Orozco ([email protected]), with Reserved Font Name "Italiana".
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+http://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/public/fonts/kinetic/licences/leaguegothic-OFL.txt b/public/fonts/kinetic/licences/leaguegothic-OFL.txt
new file mode 100644
index 00000000..06b467db
--- /dev/null
+++ b/public/fonts/kinetic/licences/leaguegothic-OFL.txt
@@ -0,0 +1,93 @@
+Copyright 2010 The League Gothic Project Authors (https://github.com/theleagueof/league-gothic)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+https://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/public/fonts/kinetic/licences/manrope-OFL.txt b/public/fonts/kinetic/licences/manrope-OFL.txt
new file mode 100644
index 00000000..e271172a
--- /dev/null
+++ b/public/fonts/kinetic/licences/manrope-OFL.txt
@@ -0,0 +1,93 @@
+Copyright 2018 The Manrope Project Authors (https://github.com/googlefonts/manrope)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+http://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/public/fonts/kinetic/licences/monasans-OFL.txt b/public/fonts/kinetic/licences/monasans-OFL.txt
new file mode 100644
index 00000000..ccc02aab
--- /dev/null
+++ b/public/fonts/kinetic/licences/monasans-OFL.txt
@@ -0,0 +1,93 @@
+Copyright 2022 The Mona Sans Project Authors (https://github.com/github/mona-sans), with Reserved Font Name "Mona"
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+https://openfontlicense.org
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/public/fonts/kinetic/licences/outfit-OFL.txt b/public/fonts/kinetic/licences/outfit-OFL.txt
new file mode 100644
index 00000000..723cd447
--- /dev/null
+++ b/public/fonts/kinetic/licences/outfit-OFL.txt
@@ -0,0 +1,93 @@
+Copyright 2021 The Outfit Project Authors (https://github.com/Outfitio/Outfit-Fonts)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+https://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/public/fonts/kinetic/licences/spacemono-OFL.txt b/public/fonts/kinetic/licences/spacemono-OFL.txt
new file mode 100644
index 00000000..a72b0a78
--- /dev/null
+++ b/public/fonts/kinetic/licences/spacemono-OFL.txt
@@ -0,0 +1,93 @@
+Copyright 2016 The Space Mono Project Authors (https://github.com/googlefonts/spacemono)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+http://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/public/fonts/kinetic/licences/unbounded-OFL.txt b/public/fonts/kinetic/licences/unbounded-OFL.txt
new file mode 100644
index 00000000..1c7db283
--- /dev/null
+++ b/public/fonts/kinetic/licences/unbounded-OFL.txt
@@ -0,0 +1,93 @@
+Copyright 2022 The Unbounded Project Authors (https://github.com/googlefonts/unbounded)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+https://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/public/fonts/kinetic/licences/youngserif-OFL.txt b/public/fonts/kinetic/licences/youngserif-OFL.txt
new file mode 100644
index 00000000..b2a30e42
--- /dev/null
+++ b/public/fonts/kinetic/licences/youngserif-OFL.txt
@@ -0,0 +1,93 @@
+Copyright 2023 The Young Serif Project Authors (https://github.com/noirblancrouge/YoungSerif)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+https://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/public/fonts/kinetic/manrope.woff2 b/public/fonts/kinetic/manrope.woff2
new file mode 100644
index 00000000..fbd43c30
Binary files /dev/null and b/public/fonts/kinetic/manrope.woff2 differ
diff --git a/public/fonts/kinetic/mona-sans-expanded.woff2 b/public/fonts/kinetic/mona-sans-expanded.woff2
new file mode 100644
index 00000000..6d5d8968
Binary files /dev/null and b/public/fonts/kinetic/mona-sans-expanded.woff2 differ
diff --git a/public/fonts/kinetic/mona-sans.woff2 b/public/fonts/kinetic/mona-sans.woff2
new file mode 100644
index 00000000..b3e6f707
Binary files /dev/null and b/public/fonts/kinetic/mona-sans.woff2 differ
diff --git a/public/fonts/kinetic/outfit.woff2 b/public/fonts/kinetic/outfit.woff2
new file mode 100644
index 00000000..dcd8ca7a
Binary files /dev/null and b/public/fonts/kinetic/outfit.woff2 differ
diff --git a/public/fonts/kinetic/space-mono-bold.woff2 b/public/fonts/kinetic/space-mono-bold.woff2
new file mode 100644
index 00000000..48b723db
Binary files /dev/null and b/public/fonts/kinetic/space-mono-bold.woff2 differ
diff --git a/public/fonts/kinetic/space-mono.woff2 b/public/fonts/kinetic/space-mono.woff2
new file mode 100644
index 00000000..32b49be6
Binary files /dev/null and b/public/fonts/kinetic/space-mono.woff2 differ
diff --git a/public/fonts/kinetic/unbounded.woff2 b/public/fonts/kinetic/unbounded.woff2
new file mode 100644
index 00000000..2a5c2578
Binary files /dev/null and b/public/fonts/kinetic/unbounded.woff2 differ
diff --git a/public/fonts/kinetic/young-serif.woff2 b/public/fonts/kinetic/young-serif.woff2
new file mode 100644
index 00000000..04071a40
Binary files /dev/null and b/public/fonts/kinetic/young-serif.woff2 differ
diff --git a/public/previews/kinetic/photos/gold-gown.webp b/public/previews/kinetic/photos/gold-gown.webp
new file mode 100644
index 00000000..17e413c4
Binary files /dev/null and b/public/previews/kinetic/photos/gold-gown.webp differ
diff --git a/public/previews/kinetic/photos/night-lights.webp b/public/previews/kinetic/photos/night-lights.webp
new file mode 100644
index 00000000..6a282c8c
Binary files /dev/null and b/public/previews/kinetic/photos/night-lights.webp differ
diff --git a/public/previews/kinetic/photos/portrait-soft.webp b/public/previews/kinetic/photos/portrait-soft.webp
new file mode 100644
index 00000000..cb884612
Binary files /dev/null and b/public/previews/kinetic/photos/portrait-soft.webp differ
diff --git a/public/previews/kinetic/photos/red-dunes.webp b/public/previews/kinetic/photos/red-dunes.webp
new file mode 100644
index 00000000..fcaff41e
Binary files /dev/null and b/public/previews/kinetic/photos/red-dunes.webp differ
diff --git a/public/previews/templates/marketing/m2-line-reveal.jpg b/public/previews/templates/marketing/m2-line-reveal.jpg
index be0cfdd6..8a897a5b 100644
Binary files a/public/previews/templates/marketing/m2-line-reveal.jpg and b/public/previews/templates/marketing/m2-line-reveal.jpg differ
diff --git a/public/previews/templates/marketing/m2-line-reveal.mp4 b/public/previews/templates/marketing/m2-line-reveal.mp4
index 15c4bb15..c7dfdea4 100644
Binary files a/public/previews/templates/marketing/m2-line-reveal.mp4 and b/public/previews/templates/marketing/m2-line-reveal.mp4 differ
diff --git a/public/previews/templates/marketing/m2-midnight-drop.jpg b/public/previews/templates/marketing/m2-midnight-drop.jpg
new file mode 100644
index 00000000..c40a9892
Binary files /dev/null and b/public/previews/templates/marketing/m2-midnight-drop.jpg differ
diff --git a/public/previews/templates/marketing/m2-midnight-drop.mp4 b/public/previews/templates/marketing/m2-midnight-drop.mp4
new file mode 100644
index 00000000..41c99ac9
Binary files /dev/null and b/public/previews/templates/marketing/m2-midnight-drop.mp4 differ
diff --git a/public/previews/templates/marketing/m2-nocturne.jpg b/public/previews/templates/marketing/m2-nocturne.jpg
new file mode 100644
index 00000000..774b7f4b
Binary files /dev/null and b/public/previews/templates/marketing/m2-nocturne.jpg differ
diff --git a/public/previews/templates/marketing/m2-nocturne.mp4 b/public/previews/templates/marketing/m2-nocturne.mp4
new file mode 100644
index 00000000..57dff0d5
Binary files /dev/null and b/public/previews/templates/marketing/m2-nocturne.mp4 differ
diff --git a/public/previews/templates/marketing/m2-offer-badge.jpg b/public/previews/templates/marketing/m2-offer-badge.jpg
index a633ab58..b255f692 100644
Binary files a/public/previews/templates/marketing/m2-offer-badge.jpg and b/public/previews/templates/marketing/m2-offer-badge.jpg differ
diff --git a/public/previews/templates/marketing/m2-offer-badge.mp4 b/public/previews/templates/marketing/m2-offer-badge.mp4
index 43366893..b69cb0e4 100644
Binary files a/public/previews/templates/marketing/m2-offer-badge.mp4 and b/public/previews/templates/marketing/m2-offer-badge.mp4 differ
diff --git a/public/previews/templates/marketing/m2-prism-stage.jpg b/public/previews/templates/marketing/m2-prism-stage.jpg
new file mode 100644
index 00000000..f4bbb7d1
Binary files /dev/null and b/public/previews/templates/marketing/m2-prism-stage.jpg differ
diff --git a/public/previews/templates/marketing/m2-prism-stage.mp4 b/public/previews/templates/marketing/m2-prism-stage.mp4
new file mode 100644
index 00000000..875d41be
Binary files /dev/null and b/public/previews/templates/marketing/m2-prism-stage.mp4 differ
diff --git a/public/previews/templates/marketing/m2-retro-starburst.jpg b/public/previews/templates/marketing/m2-retro-starburst.jpg
index b5b4e100..331eb657 100644
Binary files a/public/previews/templates/marketing/m2-retro-starburst.jpg and b/public/previews/templates/marketing/m2-retro-starburst.jpg differ
diff --git a/public/previews/templates/marketing/m2-retro-starburst.mp4 b/public/previews/templates/marketing/m2-retro-starburst.mp4
index ec8df6cc..4ae6f7a5 100644
Binary files a/public/previews/templates/marketing/m2-retro-starburst.mp4 and b/public/previews/templates/marketing/m2-retro-starburst.mp4 differ
diff --git a/public/previews/templates/marketing/m2-season-finale.jpg b/public/previews/templates/marketing/m2-season-finale.jpg
new file mode 100644
index 00000000..fa68307b
Binary files /dev/null and b/public/previews/templates/marketing/m2-season-finale.jpg differ
diff --git a/public/previews/templates/marketing/m2-season-finale.mp4 b/public/previews/templates/marketing/m2-season-finale.mp4
new file mode 100644
index 00000000..7c088655
Binary files /dev/null and b/public/previews/templates/marketing/m2-season-finale.mp4 differ
diff --git a/public/previews/templates/marketing/mm-marquee.jpg b/public/previews/templates/marketing/mm-marquee.jpg
new file mode 100644
index 00000000..a2d1c2a5
Binary files /dev/null and b/public/previews/templates/marketing/mm-marquee.jpg differ
diff --git a/public/previews/templates/marketing/mm-marquee.mp4 b/public/previews/templates/marketing/mm-marquee.mp4
new file mode 100644
index 00000000..746e21b4
Binary files /dev/null and b/public/previews/templates/marketing/mm-marquee.mp4 differ
diff --git a/public/previews/templates/marketing/mm-runway-titles.jpg b/public/previews/templates/marketing/mm-runway-titles.jpg
new file mode 100644
index 00000000..c202b939
Binary files /dev/null and b/public/previews/templates/marketing/mm-runway-titles.jpg differ
diff --git a/public/previews/templates/marketing/mm-runway-titles.mp4 b/public/previews/templates/marketing/mm-runway-titles.mp4
new file mode 100644
index 00000000..507188ed
Binary files /dev/null and b/public/previews/templates/marketing/mm-runway-titles.mp4 differ
diff --git a/public/previews/templates/marketing/ms-big-number.jpg b/public/previews/templates/marketing/ms-big-number.jpg
index ee1dcaf8..0fc2c57c 100644
Binary files a/public/previews/templates/marketing/ms-big-number.jpg and b/public/previews/templates/marketing/ms-big-number.jpg differ
diff --git a/public/previews/templates/marketing/ms-big-number.mp4 b/public/previews/templates/marketing/ms-big-number.mp4
index fa38d96b..94677d98 100644
Binary files a/public/previews/templates/marketing/ms-big-number.mp4 and b/public/previews/templates/marketing/ms-big-number.mp4 differ
diff --git a/public/previews/templates/marketing/ms-dashboard-zoom.jpg b/public/previews/templates/marketing/ms-dashboard-zoom.jpg
index 2f1a25dd..6759e0d8 100644
Binary files a/public/previews/templates/marketing/ms-dashboard-zoom.jpg and b/public/previews/templates/marketing/ms-dashboard-zoom.jpg differ
diff --git a/public/previews/templates/marketing/ms-dashboard-zoom.mp4 b/public/previews/templates/marketing/ms-dashboard-zoom.mp4
index ed9f67dd..f0329096 100644
Binary files a/public/previews/templates/marketing/ms-dashboard-zoom.mp4 and b/public/previews/templates/marketing/ms-dashboard-zoom.mp4 differ
diff --git a/public/previews/templates/marketing/ms-end-card.jpg b/public/previews/templates/marketing/ms-end-card.jpg
index 4911ecd1..5d7151cf 100644
Binary files a/public/previews/templates/marketing/ms-end-card.jpg and b/public/previews/templates/marketing/ms-end-card.jpg differ
diff --git a/public/previews/templates/marketing/ms-end-card.mp4 b/public/previews/templates/marketing/ms-end-card.mp4
index 4de79053..170d2fc0 100644
Binary files a/public/previews/templates/marketing/ms-end-card.mp4 and b/public/previews/templates/marketing/ms-end-card.mp4 differ
diff --git a/public/previews/templates/marketing/ms-feature-cards.jpg b/public/previews/templates/marketing/ms-feature-cards.jpg
index 5f9d3b0c..3f35ddf8 100644
Binary files a/public/previews/templates/marketing/ms-feature-cards.jpg and b/public/previews/templates/marketing/ms-feature-cards.jpg differ
diff --git a/public/previews/templates/marketing/ms-feature-cards.mp4 b/public/previews/templates/marketing/ms-feature-cards.mp4
index 5658a970..c01bc2db 100644
Binary files a/public/previews/templates/marketing/ms-feature-cards.mp4 and b/public/previews/templates/marketing/ms-feature-cards.mp4 differ
diff --git a/public/previews/templates/marketing/ms-five-star-quote.jpg b/public/previews/templates/marketing/ms-five-star-quote.jpg
index b3b164a4..3fa77c68 100644
Binary files a/public/previews/templates/marketing/ms-five-star-quote.jpg and b/public/previews/templates/marketing/ms-five-star-quote.jpg differ
diff --git a/public/previews/templates/marketing/ms-five-star-quote.mp4 b/public/previews/templates/marketing/ms-five-star-quote.mp4
index c93bacb9..8954bc17 100644
Binary files a/public/previews/templates/marketing/ms-five-star-quote.mp4 and b/public/previews/templates/marketing/ms-five-star-quote.mp4 differ
diff --git a/public/previews/templates/marketing/ms-kind-words.jpg b/public/previews/templates/marketing/ms-kind-words.jpg
new file mode 100644
index 00000000..a5c6b29c
Binary files /dev/null and b/public/previews/templates/marketing/ms-kind-words.jpg differ
diff --git a/public/previews/templates/marketing/ms-kind-words.mp4 b/public/previews/templates/marketing/ms-kind-words.mp4
new file mode 100644
index 00000000..553fd0d4
Binary files /dev/null and b/public/previews/templates/marketing/ms-kind-words.mp4 differ
diff --git a/public/previews/templates/marketing/ms-kinetic-headline.jpg b/public/previews/templates/marketing/ms-kinetic-headline.jpg
index 6c473728..42ca08ce 100644
Binary files a/public/previews/templates/marketing/ms-kinetic-headline.jpg and b/public/previews/templates/marketing/ms-kinetic-headline.jpg differ
diff --git a/public/previews/templates/marketing/ms-kinetic-headline.mp4 b/public/previews/templates/marketing/ms-kinetic-headline.mp4
index 2013d30b..bbcf3c10 100644
Binary files a/public/previews/templates/marketing/ms-kinetic-headline.mp4 and b/public/previews/templates/marketing/ms-kinetic-headline.mp4 differ
diff --git a/public/previews/templates/marketing/ms-logo-sting.jpg b/public/previews/templates/marketing/ms-logo-sting.jpg
index 12593f0e..f43ed6bb 100644
Binary files a/public/previews/templates/marketing/ms-logo-sting.jpg and b/public/previews/templates/marketing/ms-logo-sting.jpg differ
diff --git a/public/previews/templates/marketing/ms-logo-sting.mp4 b/public/previews/templates/marketing/ms-logo-sting.mp4
index f3324fd9..64f6bbe4 100644
Binary files a/public/previews/templates/marketing/ms-logo-sting.mp4 and b/public/previews/templates/marketing/ms-logo-sting.mp4 differ
diff --git a/public/previews/templates/marketing/ms-stat-stack.jpg b/public/previews/templates/marketing/ms-stat-stack.jpg
new file mode 100644
index 00000000..324bbc85
Binary files /dev/null and b/public/previews/templates/marketing/ms-stat-stack.jpg differ
diff --git a/public/previews/templates/marketing/ms-stat-stack.mp4 b/public/previews/templates/marketing/ms-stat-stack.mp4
new file mode 100644
index 00000000..a910e7bf
Binary files /dev/null and b/public/previews/templates/marketing/ms-stat-stack.mp4 differ
diff --git a/public/previews/templates/marketing/thumbs/m2-line-reveal.jpg b/public/previews/templates/marketing/thumbs/m2-line-reveal.jpg
index ee819d5f..b8a8e695 100644
Binary files a/public/previews/templates/marketing/thumbs/m2-line-reveal.jpg and b/public/previews/templates/marketing/thumbs/m2-line-reveal.jpg differ
diff --git a/public/previews/templates/marketing/thumbs/m2-midnight-drop.jpg b/public/previews/templates/marketing/thumbs/m2-midnight-drop.jpg
new file mode 100644
index 00000000..e6b31f84
Binary files /dev/null and b/public/previews/templates/marketing/thumbs/m2-midnight-drop.jpg differ
diff --git a/public/previews/templates/marketing/thumbs/m2-nocturne.jpg b/public/previews/templates/marketing/thumbs/m2-nocturne.jpg
new file mode 100644
index 00000000..75dc20a1
Binary files /dev/null and b/public/previews/templates/marketing/thumbs/m2-nocturne.jpg differ
diff --git a/public/previews/templates/marketing/thumbs/m2-offer-badge.jpg b/public/previews/templates/marketing/thumbs/m2-offer-badge.jpg
index ff33c9f4..ed3a6fe1 100644
Binary files a/public/previews/templates/marketing/thumbs/m2-offer-badge.jpg and b/public/previews/templates/marketing/thumbs/m2-offer-badge.jpg differ
diff --git a/public/previews/templates/marketing/thumbs/m2-prism-stage.jpg b/public/previews/templates/marketing/thumbs/m2-prism-stage.jpg
new file mode 100644
index 00000000..07d68193
Binary files /dev/null and b/public/previews/templates/marketing/thumbs/m2-prism-stage.jpg differ
diff --git a/public/previews/templates/marketing/thumbs/m2-retro-starburst.jpg b/public/previews/templates/marketing/thumbs/m2-retro-starburst.jpg
index e60c16bf..2e864002 100644
Binary files a/public/previews/templates/marketing/thumbs/m2-retro-starburst.jpg and b/public/previews/templates/marketing/thumbs/m2-retro-starburst.jpg differ
diff --git a/public/previews/templates/marketing/thumbs/m2-season-finale.jpg b/public/previews/templates/marketing/thumbs/m2-season-finale.jpg
new file mode 100644
index 00000000..0496f5e4
Binary files /dev/null and b/public/previews/templates/marketing/thumbs/m2-season-finale.jpg differ
diff --git a/public/previews/templates/marketing/thumbs/mm-marquee.jpg b/public/previews/templates/marketing/thumbs/mm-marquee.jpg
new file mode 100644
index 00000000..f939b839
Binary files /dev/null and b/public/previews/templates/marketing/thumbs/mm-marquee.jpg differ
diff --git a/public/previews/templates/marketing/thumbs/mm-runway-titles.jpg b/public/previews/templates/marketing/thumbs/mm-runway-titles.jpg
new file mode 100644
index 00000000..9a47007c
Binary files /dev/null and b/public/previews/templates/marketing/thumbs/mm-runway-titles.jpg differ
diff --git a/public/previews/templates/marketing/thumbs/ms-big-number.jpg b/public/previews/templates/marketing/thumbs/ms-big-number.jpg
index 0f2641e7..682ef950 100644
Binary files a/public/previews/templates/marketing/thumbs/ms-big-number.jpg and b/public/previews/templates/marketing/thumbs/ms-big-number.jpg differ
diff --git a/public/previews/templates/marketing/thumbs/ms-dashboard-zoom.jpg b/public/previews/templates/marketing/thumbs/ms-dashboard-zoom.jpg
index ade89139..70c7fe83 100644
Binary files a/public/previews/templates/marketing/thumbs/ms-dashboard-zoom.jpg and b/public/previews/templates/marketing/thumbs/ms-dashboard-zoom.jpg differ
diff --git a/public/previews/templates/marketing/thumbs/ms-end-card.jpg b/public/previews/templates/marketing/thumbs/ms-end-card.jpg
index 8d5f579d..ad12b8e6 100644
Binary files a/public/previews/templates/marketing/thumbs/ms-end-card.jpg and b/public/previews/templates/marketing/thumbs/ms-end-card.jpg differ
diff --git a/public/previews/templates/marketing/thumbs/ms-feature-cards.jpg b/public/previews/templates/marketing/thumbs/ms-feature-cards.jpg
index c4913a66..3e7e144d 100644
Binary files a/public/previews/templates/marketing/thumbs/ms-feature-cards.jpg and b/public/previews/templates/marketing/thumbs/ms-feature-cards.jpg differ
diff --git a/public/previews/templates/marketing/thumbs/ms-five-star-quote.jpg b/public/previews/templates/marketing/thumbs/ms-five-star-quote.jpg
index 95675144..e9d02dff 100644
Binary files a/public/previews/templates/marketing/thumbs/ms-five-star-quote.jpg and b/public/previews/templates/marketing/thumbs/ms-five-star-quote.jpg differ
diff --git a/public/previews/templates/marketing/thumbs/ms-kind-words.jpg b/public/previews/templates/marketing/thumbs/ms-kind-words.jpg
new file mode 100644
index 00000000..54fae553
Binary files /dev/null and b/public/previews/templates/marketing/thumbs/ms-kind-words.jpg differ
diff --git a/public/previews/templates/marketing/thumbs/ms-kinetic-headline.jpg b/public/previews/templates/marketing/thumbs/ms-kinetic-headline.jpg
index 622f55e7..84ea0abf 100644
Binary files a/public/previews/templates/marketing/thumbs/ms-kinetic-headline.jpg and b/public/previews/templates/marketing/thumbs/ms-kinetic-headline.jpg differ
diff --git a/public/previews/templates/marketing/thumbs/ms-logo-sting.jpg b/public/previews/templates/marketing/thumbs/ms-logo-sting.jpg
index 038f0828..ebb36304 100644
Binary files a/public/previews/templates/marketing/thumbs/ms-logo-sting.jpg and b/public/previews/templates/marketing/thumbs/ms-logo-sting.jpg differ
diff --git a/public/previews/templates/marketing/thumbs/ms-stat-stack.jpg b/public/previews/templates/marketing/thumbs/ms-stat-stack.jpg
new file mode 100644
index 00000000..003acf8f
Binary files /dev/null and b/public/previews/templates/marketing/thumbs/ms-stat-stack.jpg differ
diff --git a/scripts/kinetic/build-fonts.py b/scripts/kinetic/build-fonts.py
new file mode 100644
index 00000000..4db99d4e
--- /dev/null
+++ b/scripts/kinetic/build-fonts.py
@@ -0,0 +1,119 @@
+"""Builds Kinetic Motion's self-hosted type faces.
+
+Each face in scripts/kinetic/fonts.json is cut from its SIL OFL source font: variable axes pinned or narrowed to the
+instance the type pairings use (so canvas text gets the right optical size, width and softness), then subset to the
+Latin range in "subset" and saved as WOFF2 in public/fonts/kinetic/, with each family's licence next to it.
+The script also writes src/lib/motion/type/faces.generated.ts (the faces, their files and versions).
+
+ python scripts/kinetic/build-fonts.py <folder with the Google Fonts "ofl/<family>/" sources>
+
+Needs fontTools and brotli (pip install fonttools brotli).
+"""
+
+import hashlib
+import io
+import json
+import shutil
+import sys
+from pathlib import Path
+
+from fontTools import subset
+from fontTools.ttLib import TTFont
+from fontTools.varLib import instancer
+
+ROOT = Path(__file__).resolve().parents[2]
+MANIFEST = ROOT / "scripts" / "kinetic" / "fonts.json"
+OUT = ROOT / "public" / "fonts" / "kinetic"
+GENERATED = ROOT / "src" / "lib" / "motion" / "type" / "faces.generated.ts"
+
+
+def unicodes(spec: str) -> list[int]:
+ out: list[int] = []
+ for part in spec.split(","):
+ part = part.strip().upper().removeprefix("U+")
+ if "-" in part:
+ a, b = part.split("-")
+ out.extend(range(int(a, 16), int(b, 16) + 1))
+ else:
+ out.append(int(part, 16))
+ return out
+
+
+def build(src_root: Path) -> None:
+ manifest = json.loads(MANIFEST.read_text(encoding="utf-8"))
+ codepoints = unicodes(manifest["subset"])
+ OUT.mkdir(parents=True, exist_ok=True)
+ (OUT / "licences").mkdir(exist_ok=True)
+ rows = []
+ for face in manifest["faces"]:
+ src = src_root / face["src"]
+ font = TTFont(src, lazy=False)
+ axes = face.get("axes")
+ if axes and "fvar" in font:
+ limits = {tag: (tuple(v) if isinstance(v, list) else v) for tag, v in axes.items()}
+ font = instancer.instantiateVariableFont(font, limits, updateFontNames=False)
+ # Round-trip so every table is plain again before subsetting.
+ buf = io.BytesIO()
+ font.save(buf)
+ buf.seek(0)
+ font = TTFont(buf, lazy=False)
+ options = subset.Options()
+ options.flavor = "woff2"
+ options.layout_features = ["*"]
+ options.name_IDs = ["*"]
+ options.name_legacy = True
+ options.name_languages = ["*"]
+ options.notdef_outline = True
+ options.glyph_names = False
+ options.hinting = False
+ options.desubroutinize = True
+ sub = subset.Subsetter(options)
+ sub.populate(unicodes=codepoints)
+ sub.subset(font)
+ target = OUT / f"{face['id']}.woff2"
+ font.flavor = "woff2"
+ font.save(target)
+ data = target.read_bytes()
+ licence_dir = face["src"].split("/")[0]
+ shutil.copyfile(src_root / licence_dir / "OFL.txt", OUT / "licences" / f"{licence_dir}-OFL.txt")
+ rows.append(
+ {
+ "id": face["id"],
+ "family": face["family"],
+ "style": face["style"],
+ "weight": face["weight"],
+ "file": f"/fonts/kinetic/{face['id']}.woff2",
+ "v": hashlib.sha256(data).hexdigest()[:8],
+ "bytes": len(data),
+ "licence": f"/fonts/kinetic/licences/{licence_dir}-OFL.txt",
+ }
+ )
+ print(f"{face['id']:28} {len(data) / 1024:7.1f} KB")
+ lines = [
+ "// Generated by scripts/kinetic/build-fonts.py from scripts/kinetic/fonts.json. Do not edit by hand.",
+ "",
+ 'import type { KineticFace } from "./faces";',
+ "",
+ f"export const KINETIC_UNICODE_RANGE = {json.dumps(manifest['subset'])};",
+ "",
+ "export const KINETIC_FACES: readonly KineticFace[] = [",
+ ]
+ for r in rows:
+ lines.append(
+ " { "
+ + f'id: {json.dumps(r["id"])}, family: {json.dumps(r["family"])}, style: {json.dumps(r["style"])}, '
+ + f'weight: [{r["weight"][0]}, {r["weight"][1]}], file: {json.dumps(r["file"])}, v: {json.dumps(r["v"])}, '
+ + f'bytes: {r["bytes"]}, licence: {json.dumps(r["licence"])}'
+ + " },"
+ )
+ lines += ["];", ""]
+ GENERATED.parent.mkdir(parents=True, exist_ok=True)
+ GENERATED.write_text("\n".join(lines), encoding="utf-8", newline="\n")
+ total = sum(r["bytes"] for r in rows)
+ print(f"{len(rows)} faces, {total / 1024:.0f} KB in all")
+
+
+if __name__ == "__main__":
+ if len(sys.argv) != 2:
+ sys.exit(__doc__)
+ build(Path(sys.argv[1]))
diff --git a/scripts/kinetic/fonts.json b/scripts/kinetic/fonts.json
new file mode 100644
index 00000000..7c76566d
--- /dev/null
+++ b/scripts/kinetic/fonts.json
@@ -0,0 +1,38 @@
+{
+ "subset": "U+0020-007E,U+00A0-00FF,U+0100-017F,U+0192,U+0218-021B,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+20A0-20C0,U+2100-2122,U+2190-2199,U+2212,U+2215,U+2605-2606,U+2713,U+FEFF,U+FFFD",
+ "faces": [
+ { "id": "anton", "family": "Kinetic Anton", "style": "normal", "weight": [400, 400], "src": "anton/Anton-Regular.ttf" },
+ { "id": "league-gothic", "family": "Kinetic League Gothic", "style": "normal", "weight": [400, 400], "src": "leaguegothic/LeagueGothic[wdth].ttf", "axes": { "wdth": 100 } },
+ { "id": "league-gothic-condensed", "family": "Kinetic League Gothic Condensed", "style": "normal", "weight": [400, 400], "src": "leaguegothic/LeagueGothic[wdth].ttf", "axes": { "wdth": 75 } },
+ { "id": "instrument-serif", "family": "Kinetic Instrument Serif", "style": "normal", "weight": [400, 400], "src": "instrumentserif/InstrumentSerif-Regular.ttf" },
+ { "id": "instrument-serif-italic", "family": "Kinetic Instrument Serif", "style": "italic", "weight": [400, 400], "src": "instrumentserif/InstrumentSerif-Italic.ttf" },
+ { "id": "geist-mono", "family": "Kinetic Geist Mono", "style": "normal", "weight": [400, 600], "src": "geistmono/GeistMono[wght].ttf", "axes": { "wght": [400, 600] } },
+ { "id": "big-shoulders", "family": "Kinetic Big Shoulders Display", "style": "normal", "weight": [600, 900], "src": "bigshouldersdisplay/BigShouldersDisplay[wght].ttf", "axes": { "wght": [600, 900] } },
+ { "id": "archivo-expanded", "family": "Kinetic Archivo Expanded", "style": "normal", "weight": [600, 900], "src": "archivo/Archivo[wdth,wght].ttf", "axes": { "wdth": 125, "wght": [600, 900] } },
+ { "id": "archivo-condensed", "family": "Kinetic Archivo Condensed", "style": "normal", "weight": [700, 900], "src": "archivo/Archivo[wdth,wght].ttf", "axes": { "wdth": 62, "wght": [700, 900] } },
+ { "id": "instrument-sans", "family": "Kinetic Instrument Sans", "style": "normal", "weight": [400, 700], "src": "instrumentsans/InstrumentSans[wdth,wght].ttf", "axes": { "wdth": 100, "wght": [400, 700] } },
+ { "id": "unbounded", "family": "Kinetic Unbounded", "style": "normal", "weight": [500, 900], "src": "unbounded/Unbounded[wght].ttf", "axes": { "wght": [500, 900] } },
+ { "id": "boldonse", "family": "Kinetic Boldonse", "style": "normal", "weight": [400, 400], "src": "boldonse/Boldonse-Regular.ttf" },
+ { "id": "inter-tight", "family": "Kinetic Inter Tight", "style": "normal", "weight": [300, 600], "src": "intertight/InterTight[wght].ttf", "axes": { "wght": [300, 600] } },
+ { "id": "bodoni-moda", "family": "Kinetic Bodoni Moda Display", "style": "normal", "weight": [400, 700], "src": "bodonimoda/BodoniModa[opsz,wght].ttf", "axes": { "opsz": 22, "wght": [400, 700] } },
+ { "id": "bodoni-moda-italic", "family": "Kinetic Bodoni Moda Display", "style": "italic", "weight": [400, 700], "src": "bodonimoda/BodoniModa-Italic[opsz,wght].ttf", "axes": { "opsz": 22, "wght": [400, 700] } },
+ { "id": "italiana", "family": "Kinetic Italiana", "style": "normal", "weight": [400, 400], "src": "italiana/Italiana-Regular.ttf" },
+ { "id": "fraunces-soft", "family": "Kinetic Fraunces Soft", "style": "normal", "weight": [300, 600], "src": "fraunces/Fraunces[SOFT,WONK,opsz,wght].ttf", "axes": { "opsz": 144, "SOFT": 100, "WONK": 0, "wght": [300, 600] } },
+ { "id": "fraunces-soft-italic", "family": "Kinetic Fraunces Soft", "style": "italic", "weight": [300, 600], "src": "fraunces/Fraunces-Italic[SOFT,WONK,opsz,wght].ttf", "axes": { "opsz": 144, "SOFT": 100, "WONK": 0, "wght": [300, 600] } },
+ { "id": "fraunces-display", "family": "Kinetic Fraunces Display", "style": "normal", "weight": [700, 900], "src": "fraunces/Fraunces[SOFT,WONK,opsz,wght].ttf", "axes": { "opsz": 144, "SOFT": 0, "WONK": 0, "wght": [700, 900] } },
+ { "id": "manrope", "family": "Kinetic Manrope", "style": "normal", "weight": [400, 700], "src": "manrope/Manrope[wght].ttf", "axes": { "wght": [400, 700] } },
+ { "id": "young-serif", "family": "Kinetic Young Serif", "style": "normal", "weight": [400, 400], "src": "youngserif/YoungSerif-Regular.ttf" },
+ { "id": "bricolage", "family": "Kinetic Bricolage Display", "style": "normal", "weight": [600, 800], "src": "bricolagegrotesque/BricolageGrotesque[opsz,wdth,wght].ttf", "axes": { "opsz": 96, "wdth": 100, "wght": [600, 800] } },
+ { "id": "outfit", "family": "Kinetic Outfit", "style": "normal", "weight": [400, 600], "src": "outfit/Outfit[wght].ttf", "axes": { "wght": [400, 600] } },
+ { "id": "geist", "family": "Kinetic Geist", "style": "normal", "weight": [400, 600], "src": "geist/Geist[wght].ttf", "axes": { "wght": [400, 600] } },
+ { "id": "mona-sans", "family": "Kinetic Mona Sans", "style": "normal", "weight": [600, 900], "src": "monasans/MonaSans[wdth,wght].ttf", "axes": { "wdth": 100, "wght": [600, 900] } },
+ { "id": "mona-sans-expanded", "family": "Kinetic Mona Sans Expanded", "style": "normal", "weight": [600, 900], "src": "monasans/MonaSans[wdth,wght].ttf", "axes": { "wdth": 125, "wght": [600, 900] } },
+ { "id": "dela-gothic", "family": "Kinetic Dela Gothic One", "style": "normal", "weight": [400, 400], "src": "delagothicone/DelaGothicOne-Regular.ttf" },
+ { "id": "bagel-fat", "family": "Kinetic Bagel Fat One", "style": "normal", "weight": [400, 400], "src": "bagelfatone/BagelFatOne-Regular.ttf" },
+ { "id": "caveat", "family": "Kinetic Caveat", "style": "normal", "weight": [500, 700], "src": "caveat/Caveat[wght].ttf", "axes": { "wght": [500, 700] } },
+ { "id": "ballet", "family": "Kinetic Ballet", "style": "normal", "weight": [400, 400], "src": "ballet/Ballet[opsz].ttf", "axes": { "opsz": 72 } },
+ { "id": "space-mono", "family": "Kinetic Space Mono", "style": "normal", "weight": [400, 400], "src": "spacemono/SpaceMono-Regular.ttf" },
+ { "id": "space-mono-bold", "family": "Kinetic Space Mono", "style": "normal", "weight": [700, 700], "src": "spacemono/SpaceMono-Bold.ttf" },
+ { "id": "gloock", "family": "Kinetic Gloock", "style": "normal", "weight": [400, 400], "src": "gloock/Gloock-Regular.ttf" }
+ ]
+}
diff --git a/src/app/dev/kinetic-covers/covers.tsx b/src/app/dev/kinetic-covers/covers.tsx
index 08e5f953..75f41637 100644
--- a/src/app/dev/kinetic-covers/covers.tsx
+++ b/src/app/dev/kinetic-covers/covers.tsx
@@ -8,7 +8,7 @@ import { loadMotionInputs } from "@/components/motion/inputs";
import { drawFrame, renderClip } from "@/components/motion/render";
import { TEMPLATES } from "@/lib/catalog/marketing";
import type { Recipe } from "@/lib/motion/recipe";
-import { loadScene } from "@/lib/motion/registry";
+import { loadScene, sceneFamilies } from "@/lib/motion/registry";
import { SHOWCASES, showcaseRecipe } from "@/lib/motion/showcase";
import { exportSize } from "@/lib/motion/sizes";
@@ -30,7 +30,7 @@ const b64 = async (b: Blob) => {
async function prepare(recipe: Recipe) {
const inputs = await loadMotionInputs({ logo: recipe.brand.logo, product: recipe.media?.product });
- await fontsReady([recipe.brand.fonts.heading, recipe.brand.fonts.body], { strict: true, text: Object.values(recipe.fields).join(" ") + recipe.brand.name });
+ await fontsReady([recipe.brand.fonts.heading, recipe.brand.fonts.body, ...sceneFamilies(recipe.scene)], { strict: true, text: Object.values(recipe.fields).join(" ") + recipe.brand.name });
const scene = await loadScene(recipe.scene);
return { inputs, scene };
}
diff --git a/src/components/ads/render.ts b/src/components/ads/render.ts
index fe206b98..7bdbc46a 100644
--- a/src/components/ads/render.ts
+++ b/src/components/ads/render.ts
@@ -91,7 +91,22 @@ function oldstyle(family: string, weight: number): boolean {
return out;
}
-/** A text's width in a CSS font; `measureText.oldstyle` tells whether a face's default figures are old-style. */
+/** Where a text's ink lies when drawn at (0, 0) with textBaseline "top": its top and bottom, its left and right. */
+function box(text: string, font: string): { top: number; bottom: number; left: number; right: number } {
+ measureCtx ??= document.createElement("canvas").getContext("2d");
+ if (!measureCtx) return { top: 0, bottom: 10, left: 0, right: text.length * 10 };
+ measureCtx.font = font;
+ const base = measureCtx.textBaseline;
+ measureCtx.textBaseline = "top";
+ const m = measureCtx.measureText(text);
+ measureCtx.textBaseline = base;
+ return { top: -m.actualBoundingBoxAscent, bottom: m.actualBoundingBoxDescent, left: -m.actualBoundingBoxLeft, right: m.actualBoundingBoxRight };
+}
+
+/**
+ * A text's width in a CSS font; `measureText.oldstyle` tells whether a face's default figures are old-style, and
+ * `measureText.box` where its ink lies (for clips and alignment that hug the letters).
+ */
export const measureText = Object.assign(
(text: string, font: string) => {
measureCtx ??= document.createElement("canvas").getContext("2d");
@@ -99,7 +114,7 @@ export const measureText = Object.assign(
measureCtx.font = font;
return measureCtx.measureText(text).width;
},
- { oldstyle },
+ { oldstyle, box },
);
function rounded(ctx: CanvasRenderingContext2D, x: number, y: number, w: number, h: number, r: number) {
diff --git a/src/components/marketing/end-card-motion.tsx b/src/components/marketing/end-card-motion.tsx
index 611435ca..746a0f5d 100644
--- a/src/components/marketing/end-card-motion.tsx
+++ b/src/components/marketing/end-card-motion.tsx
@@ -12,7 +12,7 @@ import { VariantPicker, type VariantChoice } from "@/components/motion/variant-p
import { END_CARD } from "@/lib/catalog/marketing";
import type { Engine } from "@/lib/catalog/types";
import { DEFAULT_EXPORT, type Recipe } from "@/lib/motion/recipe";
-import { loadScene } from "@/lib/motion/registry";
+import { loadScene, sceneFamilies } from "@/lib/motion/registry";
import { END_CARD_VARIANT_NAMES, END_CARD_VARIANTS, type EndCardVariant } from "@/lib/motion/scenes/end-card/shared";
import type { SizeSpec } from "@/lib/motion/sizes";
import type { EndCardInput } from "./end-card";
@@ -81,7 +81,7 @@ export function useEndCardMotion(card: EndCardInput, colors: readonly string[],
/** Renders a recipe's clip here, in the brand's own fonts (a font that didn't load stops it). */
export async function renderRecipe(recipe: Recipe, inputs: MotionInputs, o: { formats: ("mp4" | "webm")[]; signal?: AbortSignal; onProgress?: (done: number, total: number) => void }): Promise<RenderResult> {
- await fontsReady([recipe.brand.fonts.heading, recipe.brand.fonts.body], { strict: true, text: [...Object.values(recipe.fields), recipe.brand.name].join(" ") });
+ await fontsReady([recipe.brand.fonts.heading, recipe.brand.fonts.body, ...sceneFamilies(recipe.scene)], { strict: true, text: [...Object.values(recipe.fields), recipe.brand.name].join(" ") });
const scene = await loadScene(recipe.scene);
return renderClip(scene, recipe, { sources: inputs.sources, logo: inputs.logo, images: inputs.images, outlines: inputs.outlines, measure: measureText, formats: o.formats, signal: o.signal, onProgress: (d, n) => o.onProgress?.(d, n) });
}
diff --git a/src/components/marketing/end-card.ts b/src/components/marketing/end-card.ts
index 8e5854b6..b17c8049 100644
--- a/src/components/marketing/end-card.ts
+++ b/src/components/marketing/end-card.ts
@@ -1,5 +1,5 @@
import { END_CARD } from "@/lib/catalog/marketing";
-import { endCardRest, restNodes, type EndCardContent, type TextBlock } from "@/lib/motion/scenes/end-card/shared";
+import { cardField, endCardRest, restNodes, type EndCardContent, type TextBlock } from "@/lib/motion/scenes/end-card/shared";
import { designSize } from "@/lib/motion/sizes";
import type { AdPlan, AdTheme, Measure, TextBox } from "../ads/layout";
import { ensureFont, loadImage, measureText } from "../ads/render";
@@ -82,7 +82,7 @@ export async function renderEndCard(canvas: HTMLCanvasElement, input: EndCardInp
const rest = endCardRest({ theme: input.theme, content: input.content, logo: logo ? { w: logo.naturalWidth || 400, h: logo.naturalHeight || 120 } : null, measure: measureText, size, colors: input.colors });
const images = new Map<string, CanvasImageSource>();
if (logo) images.set("logo", logo);
- drawDisplayList(ctx, { w: size.w, h: size.h, background: input.theme.accent, nodes: restNodes(rest) }, { images });
+ drawDisplayList(ctx, { w: size.w, h: size.h, background: input.theme.accent, nodes: [...cardField(rest, 7, input.content.brand), ...restNodes(rest)] }, { images });
}
/** The full-size card as a PNG, ready to upload. */
diff --git a/src/components/marketing/kinetic-template.tsx b/src/components/marketing/kinetic-template.tsx
index eaff0bff..897e9b53 100644
--- a/src/components/marketing/kinetic-template.tsx
+++ b/src/components/marketing/kinetic-template.tsx
@@ -10,10 +10,12 @@ import { KINETIC_FEATURE, MadeStrip } from "@/components/motion/made-strip";
import { MotionPlayer, useMotionInputs, usePlan, useScene } from "@/components/motion/player";
import { phaseLine, useMotionSave } from "@/components/motion/save";
import { MediaSlot, type SlotValue } from "@/components/studio/media-slot";
+import { preloadKineticFaces } from "@/components/motion/kinetic-fonts";
import { RunPlaceChip } from "@/components/studio/run-place-chip";
import { useIsOwner } from "@/lib/api";
import type { BrandKit, MarketingTemplate } from "@/lib/catalog/marketing";
-import { SHOWCASE_PRODUCT_THUMBS, SHOWCASE_PRODUCTS } from "@/lib/motion/showcase";
+import { sceneFamilies } from "@/lib/motion/registry";
+import { SHOWCASE_PHOTOS, SHOWCASE_PRODUCT_THUMBS, SHOWCASE_PRODUCTS } from "@/lib/motion/showcase";
import type { SizePreset } from "@/lib/motion/sizes";
import { initialState, ownFiles, templateLengths, templateRecipe, templateSizes, templateWords, type TemplateBrand, type TemplateState } from "@/lib/motion/template";
import { IN_BROWSER } from "@/lib/run-place";
@@ -36,17 +38,29 @@ const PREVIEW_WIDTH: Record<SizePreset, string> = {
"16:9": "max-w-full",
};
-const SAMPLES: { id: keyof typeof SHOWCASE_PRODUCTS; label: string }[] = [
- { id: "perfume", label: "Sample: perfume bottle" },
- { id: "heel", label: "Sample: red heel" },
- { id: "serum", label: "Sample: serum bottle" },
- { id: "nightSerum", label: "Sample: night serum" },
- { id: "lipstick", label: "Sample: lipstick" },
- { id: "card", label: "Sample: metal card" },
- { id: "headphones", label: "Sample: headphones" },
-];
+/** Fuobe's own sample pictures, by the kind of picture a template shows (a small tile each; a piece gets the full one). */
+const product = (id: keyof typeof SHOWCASE_PRODUCTS, label: string) => ({ url: SHOWCASE_PRODUCTS[id], thumb: SHOWCASE_PRODUCT_THUMBS[id], label });
+const SAMPLES: Record<"product" | "photo", { url: string; thumb: string; label: string }[]> = {
+ product: [
+ product("perfume", "Sample: perfume bottle"),
+ product("heel", "Sample: red heel"),
+ product("serum", "Sample: serum bottle"),
+ product("nightSerum", "Sample: night serum"),
+ product("lipstick", "Sample: lipstick"),
+ product("card", "Sample: metal card"),
+ product("headphones", "Sample: headphones"),
+ ],
+ photo: [
+ { url: SHOWCASE_PHOTOS.portrait, thumb: SHOWCASE_PHOTOS.portrait, label: "Sample: portrait" },
+ { url: SHOWCASE_PHOTOS.gown, thumb: SHOWCASE_PHOTOS.gown, label: "Sample: gold gown" },
+ { url: SHOWCASE_PHOTOS.dunes, thumb: SHOWCASE_PHOTOS.dunes, label: "Sample: red dress in the dunes" },
+ { url: SHOWCASE_PHOTOS.night, thumb: SHOWCASE_PHOTOS.night, label: "Sample: evening lights" },
+ ],
+};
-export function PicturePicker({ value, onChange, owner }: { value: string | null | undefined; onChange: (url: string | null) => void; owner: boolean }) {
+export function PicturePicker({ kind = "product", value, onChange, owner }: { kind?: "product" | "photo"; value: string | null | undefined; onChange: (url: string | null) => void; owner: boolean }) {
+ const samples = SAMPLES[kind];
+ const fallback = samples[0].url;
const [own, setOwn] = useState<SlotValue | null>(null);
const [product, setProduct] = useState<ProductChoice | null>(null);
const tile = (on: boolean) => cn("relative size-14 shrink-0 overflow-hidden rounded-xl bg-muted outline-none focus-visible:ring-2 focus-visible:ring-ring", on && "ring-2 ring-primary ring-offset-2 ring-offset-background");
@@ -54,10 +68,10 @@ export function PicturePicker({ value, onChange, owner }: { value: string | null
<div className="min-w-0">
<p className="mb-1.5 text-[12px] font-medium text-muted-foreground">Picture</p>
<div role="group" aria-label="Picture" className="flex min-w-0 flex-wrap items-center gap-2">
- {SAMPLES.map((s) => (
- <button key={s.id} type="button" aria-pressed={value === SHOWCASE_PRODUCTS[s.id]} aria-label={s.label} onClick={() => onChange(SHOWCASE_PRODUCTS[s.id])} className={tile(value === SHOWCASE_PRODUCTS[s.id])}>
+ {samples.map((s) => (
+ <button key={s.url} type="button" aria-pressed={value === s.url} aria-label={s.label} onClick={() => onChange(s.url)} className={tile(value === s.url)}>
{/* eslint-disable-next-line @next/next/no-img-element */}
- <img src={SHOWCASE_PRODUCT_THUMBS[s.id]} alt="" className="size-full object-contain p-1" />
+ <img src={s.thumb} alt="" className={cn("size-full", kind === "photo" ? "object-cover" : "object-contain p-1")} />
</button>
))}
{owner ? (
@@ -65,7 +79,7 @@ export function PicturePicker({ value, onChange, owner }: { value: string | null
value={product}
onChange={(p) => {
setProduct(p);
- onChange(p?.images[0] ?? SHOWCASE_PRODUCTS.perfume);
+ onChange(p?.images[0] ?? fallback);
}}
/>
) : (
@@ -75,12 +89,12 @@ export function PicturePicker({ value, onChange, owner }: { value: string | null
value={own}
onChange={(v) => {
setOwn(v);
- if (!v) onChange(SHOWCASE_PRODUCTS.perfume);
+ if (!v) onChange(fallback);
else if (!v.uploading && v.ref.startsWith("/api/files/")) onChange(v.ref);
}}
/>
)}
- <p className="min-w-0 basis-full text-[11px] text-muted-foreground">A cut-out on a clear background traces best; a photo gets a frame.</p>
+ <p className="min-w-0 basis-full text-[11px] text-muted-foreground">{kind === "photo" ? "A photo fills its panel; the middle stays in view." : "A cut-out on a clear background traces best; a photo gets a frame."}</p>
</div>
</div>
);
@@ -109,6 +123,8 @@ export function KineticTemplate({ template: t, onClose, kitId, onKit }: { templa
const recipe = useMemo(() => templateRecipe(t, state), [t, state]);
const inputs = useMotionInputs(recipe);
const scene = useScene(recipe.scene);
+ // The template's own faces are asked for while the page renders, so the first frame already has its type.
+ preloadKineticFaces(sceneFamilies(recipe.scene));
const plan = usePlan(scene, recipe, inputs);
const sizes = templateSizes(t);
const lengths = templateLengths(t);
@@ -157,7 +173,7 @@ export function KineticTemplate({ template: t, onClose, kitId, onKit }: { templa
<div className="min-w-0 space-y-4">
<TemplateFields fields={fields} values={state.fields} onChange={(key, value) => setState((s) => ({ ...s, fields: { ...s.fields, [key]: value } }))} overflow={overflow} />
- {t.picture === "product" && <PicturePicker value={state.product} onChange={(url) => setState((s) => ({ ...s, product: url }))} owner={owner} />}
+ {t.picture && <PicturePicker kind={t.picture} value={state.product} onChange={(url) => setState((s) => ({ ...s, product: url }))} owner={owner} />}
{owner ? (
<OwnerBrand
value={state.brand}
diff --git a/src/components/motion/draw.ts b/src/components/motion/draw.ts
index 3ffa7a6b..f920f4c9 100644
--- a/src/components/motion/draw.ts
+++ b/src/components/motion/draw.ts
@@ -1,8 +1,9 @@
"use client";
-import { IDENTITY, multiply, type ClipShape, type DisplayList, type DisplayNode, type Gradient, type Matrix, type Paint, type Stroke } from "@/lib/motion/display";
+import { IDENTITY, multiply, type Box, type ClipShape, type DisplayList, type DisplayNode, type GrainNode, type Gradient, type GroupNode, type Matrix, type Paint, type Stroke } from "@/lib/motion/display";
import { cssFilter, GRAIN_GAIN, GRAIN_TILE, grainOffset, grainScale, grainTile, gradePixels, type Finish } from "@/lib/motion/finish";
import type { LogoInfo, LogoPath } from "@/lib/motion/scene";
+import { GRAIN_SIZE, grainPick, grainTile as filmGrainTile } from "@/lib/motion/fx/finish";
/**
* The only code that turns a Kinetic Motion display list into canvas calls: the live preview, the export and the covers
@@ -102,6 +103,202 @@ function layerFor(target: AnyCanvas, depth: number): { canvas: AnyCanvas; ctx: C
return { canvas: c, ctx: c.getContext("2d") as Ctx };
}
+// ---------------------------------------------------------------------------
+// Soft blur for `soften`: the canvas's gaussian where it filters, else halved step by step and scaled back up with
+// smoothing (Safari has no canvas filter). Cached groups pay for it once.
+
+const scratch: AnyCanvas[] = [];
+function scratchCanvas(i: number, w: number, h: number): { canvas: AnyCanvas; ctx: Ctx } {
+ let c = scratch[i];
+ if (!c || c.width < w || c.height < h) c = scratch[i] = makeCanvas(Math.max(w, c?.width ?? 0), Math.max(h, c?.height ?? 0));
+ const ctx = c.getContext("2d") as Ctx;
+ ctx.setTransform(1, 0, 0, 1, 0, 0);
+ ctx.globalAlpha = 1;
+ ctx.globalCompositeOperation = "source-over";
+ ctx.clearRect(0, 0, w, h);
+ return { canvas: c, ctx };
+}
+
+/**
+ * Blur a region of a canvas in place, as a gaussian of `r` pixels (a CSS blur's radius). Where the canvas filters,
+ * the browser's own gaussian does it on a copy; elsewhere (Safari) the region is halved step by step to about a
+ * 3.5 r box and scaled back up with smoothing, which looks the same at a glance. Both run once per cached bitmap.
+ */
+export function softenRegion(target: AnyCanvas, box: { x: number; y: number; w: number; h: number }, r: number): void {
+ if (r < 0.5 || box.w < 1 || box.h < 1) return;
+ const tctx0 = target.getContext("2d") as Ctx;
+ if (canFilter(tctx0)) {
+ const copy = scratchCanvas(0, box.w, box.h);
+ copy.ctx.drawImage(target, box.x, box.y, box.w, box.h, 0, 0, box.w, box.h);
+ tctx0.save();
+ tctx0.setTransform(1, 0, 0, 1, 0, 0);
+ tctx0.globalAlpha = 1;
+ tctx0.globalCompositeOperation = "source-over";
+ tctx0.clearRect(box.x, box.y, box.w, box.h);
+ tctx0.beginPath();
+ tctx0.rect(box.x, box.y, box.w, box.h);
+ tctx0.clip();
+ tctx0.filter = `blur(${r}px)`;
+ tctx0.drawImage(copy.canvas, 0, 0, box.w, box.h, box.x, box.y, box.w, box.h);
+ tctx0.filter = "none";
+ tctx0.restore();
+ return;
+ }
+ const levels = Math.max(1, Math.min(8, Math.round(Math.log2(3.5 * r))));
+ const sizes: [number, number][] = [[box.w, box.h]];
+ for (let i = 1; i <= levels; i++) sizes.push([Math.max(1, Math.ceil(sizes[i - 1][0] / 2)), Math.max(1, Math.ceil(sizes[i - 1][1] / 2))]);
+ const tctx = target.getContext("2d") as Ctx;
+ let prev: { canvas: AnyCanvas; x: number; y: number; w: number; h: number } = { canvas: target, x: box.x, y: box.y, w: box.w, h: box.h };
+ const chain: AnyCanvas[] = [];
+ for (let i = 1; i <= levels; i++) {
+ const [w, h] = sizes[i];
+ const s = scratchCanvas(i, w, h);
+ s.ctx.imageSmoothingEnabled = true;
+ s.ctx.imageSmoothingQuality = "low";
+ s.ctx.drawImage(prev.canvas, prev.x, prev.y, prev.w, prev.h, 0, 0, w, h);
+ chain.push(s.canvas);
+ prev = { canvas: s.canvas, x: 0, y: 0, w, h };
+ }
+ for (let i = levels - 1; i >= 1; i--) {
+ const [w, h] = sizes[i];
+ const [sw, sh] = sizes[i + 1];
+ const c = chain[i - 1];
+ const ctx = c.getContext("2d") as Ctx;
+ ctx.save();
+ ctx.setTransform(1, 0, 0, 1, 0, 0);
+ ctx.clearRect(0, 0, w, h);
+ ctx.imageSmoothingEnabled = true;
+ ctx.imageSmoothingQuality = "high";
+ ctx.drawImage(chain[i], 0, 0, sw, sh, 0, 0, w, h);
+ ctx.restore();
+ }
+ tctx.save();
+ tctx.setTransform(1, 0, 0, 1, 0, 0);
+ tctx.globalAlpha = 1;
+ tctx.globalCompositeOperation = "source-over";
+ tctx.clearRect(box.x, box.y, box.w, box.h);
+ tctx.imageSmoothingEnabled = true;
+ tctx.imageSmoothingQuality = "high";
+ tctx.drawImage(chain[0], 0, 0, sizes[1][0], sizes[1][1], box.x, box.y, box.w, box.h);
+ tctx.restore();
+}
+
+// Cached groups: drawn once into a bitmap per key and scale, then placed with the group's transform.
+interface Cached {
+ canvas: AnyCanvas;
+ pad: number;
+ k: number;
+ pixels: number;
+}
+const cached = new Map<string, Cached>();
+let cachedPixels = 0;
+const CACHE_PIXELS = 48e6;
+
+/** Forget every cached bitmap (fonts arrived, so letters drawn with a stand-in face must be drawn again). */
+export function clearMotionCache(): void {
+ cached.clear();
+ cachedPixels = 0;
+}
+if (typeof document !== "undefined") document.fonts?.addEventListener?.("loadingdone", clearMotionCache);
+
+const hasMissingImage = (nodes: readonly DisplayNode[], src: Sources): boolean => nodes.some((c) => (c.type === "image" && !src.images.has(c.src)) || (c.type === "group" && hasMissingImage(c.children, src)));
+
+function drawCached(ctx: Ctx, n: GroupNode, gm: Matrix, a: number, src: Sources, depth: number): boolean {
+ const c = n.cache!;
+ if (hasMissingImage(n.children, src)) return false;
+ const det = Math.sqrt(Math.abs(gm[0] * gm[3] - gm[1] * gm[2]));
+ if (!(det > 0)) return true;
+ // Quarter-octave buckets, so a scale animation reuses a few bitmaps instead of making one a frame.
+ const k = 2 ** (Math.round(Math.log2(det) * 4) / 4);
+ const key = `${c.key}|${k.toFixed(4)}|${n.soften ?? 0}`;
+ let hit = cached.get(key);
+ if (hit) {
+ cached.delete(key);
+ cached.set(key, hit);
+ } else {
+ const pad = 2;
+ const w = Math.min(4096, Math.ceil(c.bounds.w * k) + 2 * pad);
+ const h = Math.min(4096, Math.ceil(c.bounds.h * k) + 2 * pad);
+ if (w <= 2 * pad || h <= 2 * pad) return true;
+ const canvas = makeCanvas(w, h);
+ const l = canvas.getContext("2d") as Ctx;
+ const base: Matrix = [k, 0, 0, k, pad - c.bounds.x * k, pad - c.bounds.y * k];
+ l.save();
+ if (n.clip) {
+ setMatrix(l, base);
+ clipTo(l, n.clip);
+ }
+ for (const child of n.children) drawNode(l, child, base, 1, src, depth + 1);
+ l.restore();
+ if (n.soften) softenRegion(canvas, { x: 0, y: 0, w, h }, n.soften * k);
+ hit = { canvas, pad, k, pixels: w * h };
+ cached.set(key, hit);
+ cachedPixels += hit.pixels;
+ for (const [old, v] of cached) {
+ if (cachedPixels <= CACHE_PIXELS || cached.size <= 1) break;
+ cached.delete(old);
+ cachedPixels -= v.pixels;
+ }
+ }
+ ctx.save();
+ setMatrix(ctx, gm);
+ ctx.globalAlpha = a;
+ ctx.globalCompositeOperation = n.blend ?? "source-over";
+ ctx.imageSmoothingEnabled = true;
+ const scale = 1 / hit.k;
+ ctx.drawImage(hit.canvas, c.bounds.x - hit.pad * scale, c.bounds.y - hit.pad * scale, hit.canvas.width * scale, hit.canvas.height * scale);
+ ctx.restore();
+ return true;
+}
+
+// Grain tiles: made once per seed and tile from the pure noise (fx/finish.ts).
+const filmGrainTiles = new Map<string, AnyCanvas>();
+function filmGrainCanvas(seed: number, tile: number): AnyCanvas {
+ const key = `${seed}|${tile}`;
+ let c = filmGrainTiles.get(key);
+ if (!c) {
+ const v = filmGrainTile(seed, tile);
+ c = makeCanvas(GRAIN_SIZE, GRAIN_SIZE);
+ const g = c.getContext("2d") as Ctx;
+ const img = g.createImageData(GRAIN_SIZE, GRAIN_SIZE);
+ for (let i = 0; i < v.length; i++) {
+ img.data[i * 4] = img.data[i * 4 + 1] = img.data[i * 4 + 2] = v[i];
+ img.data[i * 4 + 3] = 255;
+ }
+ g.putImageData(img, 0, 0);
+ if (filmGrainTiles.size > 24) filmGrainTiles.clear();
+ filmGrainTiles.set(key, c);
+ }
+ return c;
+}
+
+function drawGrain(ctx: Ctx, n: GrainNode, m: Matrix, alpha: number) {
+ const a = alpha * n.amount * (n.opacity ?? 1);
+ if (a <= 0.001) return;
+ const pick = grainPick(n.seed, n.frame);
+ const tile = filmGrainCanvas(n.seed, pick.tile);
+ const span = GRAIN_SIZE * n.size;
+ ctx.save();
+ setMatrix(ctx, m);
+ ctx.beginPath();
+ ctx.rect(n.x, n.y, n.w, n.h);
+ ctx.clip();
+ ctx.globalAlpha = a;
+ ctx.globalCompositeOperation = n.blend;
+ ctx.imageSmoothingEnabled = false;
+ const ox = n.x - ((pick.ox * n.size) % span);
+ const oy = n.y - ((pick.oy * n.size) % span);
+ for (let y = oy; y < n.y + n.h; y += span) for (let x = ox; x < n.x + n.w; x += span) ctx.drawImage(tile, x, y, span, span);
+ ctx.restore();
+}
+
+const sizeOf = (img: CanvasImageSource): { w: number; h: number } => {
+ const i = img as unknown as { naturalWidth?: number; naturalHeight?: number; videoWidth?: number; videoHeight?: number; width?: unknown; height?: unknown };
+ const w = i.naturalWidth || i.videoWidth || (typeof i.width === "number" ? i.width : 0);
+ const h = i.naturalHeight || i.videoHeight || (typeof i.height === "number" ? i.height : 0);
+ return { w, h };
+};
+
function paintOf(ctx: Ctx, p: Paint): string | CanvasGradient {
if (typeof p === "string") return p;
const g: Gradient = p;
@@ -151,6 +348,14 @@ function stroke(ctx: Ctx, s: Stroke, length: number, draw: () => void) {
ctx.setLineDash([]);
}
+const clampBox = (b: { x: number; y: number; w: number; h: number }, W: number, H: number) => {
+ const x0 = Math.max(0, Math.floor(b.x));
+ const y0 = Math.max(0, Math.floor(b.y));
+ const x1 = Math.min(W, Math.ceil(b.x + b.w));
+ const y1 = Math.min(H, Math.ceil(b.y + b.h));
+ return { x: x0, y: y0, w: Math.max(0, x1 - x0), h: Math.max(0, y1 - y0) };
+};
+
/** The device-pixel box of a design-unit box under a matrix (clamped to the canvas). */
function deviceBox(m: Matrix, b: { x: number; y: number; w: number; h: number }, W: number, H: number) {
const pts = [
@@ -173,10 +378,17 @@ function drawNode(ctx: Ctx, n: DisplayNode, m: Matrix, alpha: number, src: Sourc
const gm = n.transform ? multiply(m, n.transform) : m;
const a = alpha * (n.opacity ?? 1);
if (a <= 0.001) return;
- const bounds = n.isolate ?? n.mask?.bounds;
- if (bounds) {
+ if (n.cache && !n.mask && !n.isolate && drawCached(ctx, n, gm, a, src, depth)) return;
+ const filter = !!n.blur && canFilter(ctx);
+ // Our own blur where asked for (soften), and where the canvas can't filter.
+ const soft = n.soften ?? (n.blur && !filter ? n.blur : 0);
+ const bounds: Box | undefined = n.isolate ?? n.mask?.bounds ?? (soft ? n.cache?.bounds : undefined);
+ if (bounds || soft) {
const target = ctx.canvas as AnyCanvas;
- const box = deviceBox(gm, bounds, target.width, target.height);
+ const det = Math.sqrt(Math.abs(gm[0] * gm[3] - gm[1] * gm[2]));
+ const spread = soft ? Math.ceil(soft * det * 3) : 0;
+ const raw = bounds ? deviceBox(gm, bounds, target.width, target.height) : { x: 0, y: 0, w: target.width, h: target.height };
+ const box = soft && bounds ? clampBox({ x: raw.x - spread, y: raw.y - spread, w: raw.w + 2 * spread, h: raw.h + 2 * spread }, target.width, target.height) : raw;
if (!box.w || !box.h) return;
const layer = layerFor(target, depth);
const l = layer.ctx;
@@ -192,16 +404,17 @@ function drawNode(ctx: Ctx, n: DisplayNode, m: Matrix, alpha: number, src: Sourc
setMatrix(l, gm);
clipTo(l, n.clip);
}
- if (n.blur && canFilter(l)) l.filter = `blur(${n.blur * Math.sqrt(Math.abs(gm[0] * gm[3] - gm[1] * gm[2]))}px)`;
+ if (filter) l.filter = `blur(${n.blur! * det}px)`;
for (const c of n.children) drawNode(l, c, gm, 1, src, depth + 1);
l.filter = "none";
if (n.mask) {
setMatrix(l, gm);
l.globalCompositeOperation = "destination-in";
l.fillStyle = paintOf(l, n.mask);
- l.fillRect(bounds.x, bounds.y, bounds.w, bounds.h);
+ l.fillRect(n.mask.bounds.x, n.mask.bounds.y, n.mask.bounds.w, n.mask.bounds.h);
}
l.restore();
+ if (soft) softenRegion(layer.canvas, box, soft * det);
ctx.save();
ctx.setTransform(1, 0, 0, 1, 0, 0);
ctx.globalAlpha = a;
@@ -216,7 +429,7 @@ function drawNode(ctx: Ctx, n: DisplayNode, m: Matrix, alpha: number, src: Sourc
clipTo(ctx, n.clip);
}
if (n.blend) ctx.globalCompositeOperation = n.blend;
- if (n.blur && canFilter(ctx)) ctx.filter = `blur(${n.blur * Math.sqrt(Math.abs(gm[0] * gm[3] - gm[1] * gm[2]))}px)`;
+ if (filter) ctx.filter = `blur(${n.blur! * Math.sqrt(Math.abs(gm[0] * gm[3] - gm[1] * gm[2]))}px)`;
for (const c of n.children) drawNode(ctx, c, gm, a, src, depth);
ctx.restore();
return;
@@ -281,8 +494,18 @@ function drawNode(ctx: Ctx, n: DisplayNode, m: Matrix, alpha: number, src: Sourc
ctx.globalAlpha = ra;
ctx.font = r.font;
ctx.direction = r.dir ?? "ltr";
- ctx.fillStyle = paintOf(ctx, r.fill);
- ctx.fillText(r.text, r.x, r.y);
+ const shown = r.shown ?? r.text;
+ if (r.fill !== "transparent") {
+ ctx.fillStyle = paintOf(ctx, r.fill);
+ ctx.fillText(shown, r.x, r.y);
+ }
+ if (r.stroke) {
+ ctx.strokeStyle = paintOf(ctx, r.stroke.paint);
+ ctx.lineWidth = r.stroke.width;
+ ctx.lineJoin = "round";
+ ctx.setLineDash([]);
+ ctx.strokeText(shown, r.x, r.y);
+ }
}
ctx.direction = "ltr";
return;
@@ -308,9 +531,15 @@ function drawNode(ctx: Ctx, n: DisplayNode, m: Matrix, alpha: number, src: Sourc
ctx.globalAlpha = alpha * (n.opacity ?? 1);
ctx.imageSmoothingEnabled = n.smoothing ?? true;
ctx.imageSmoothingQuality = "high";
- ctx.drawImage(img, n.x, n.y, n.w, n.h);
+ if (n.crop) {
+ const { w, h } = sizeOf(img);
+ if (w && h) ctx.drawImage(img, n.crop.x * w, n.crop.y * h, n.crop.w * w, n.crop.h * h, n.x, n.y, n.w, n.h);
+ } else ctx.drawImage(img, n.x, n.y, n.w, n.h);
return;
}
+ case "grain":
+ drawGrain(ctx, n, m, alpha);
+ return;
}
}
diff --git a/src/components/motion/fonts.ts b/src/components/motion/fonts.ts
index 9f11836f..c2142ad1 100644
--- a/src/components/motion/fonts.ts
+++ b/src/components/motion/fonts.ts
@@ -1,6 +1,8 @@
"use client";
import { ensureFont } from "@/components/ads/render";
+import { isKineticFamily } from "@/lib/motion/type/faces";
+import { loadKineticFaces } from "./kinetic-fonts";
/**
* The brand's fonts, ready to draw with. The preview draws as soon as it can (a fallback face until the brand font
@@ -10,14 +12,17 @@ import { ensureFont } from "@/components/ads/render";
export const FONT_NOT_LOADED = "Your brand font didn't load. Check your connection and try again.";
-const WEIGHTS = [400, 500, 700, 800];
+/** Every weight a template sets brand type in (the end card's product line and call to action are 600). */
+export const FONT_WEIGHTS = [400, 500, 600, 700, 800];
+const WEIGHTS = FONT_WEIGHTS;
const SYSTEM = /^(system-ui|arial|helvetica|georgia|times new roman|sans-serif|serif|verdana|tahoma|trebuchet ms|courier new)$/i;
-/** Loads `families` (Google Fonts, 400–800); with `strict`, throws FONT_NOT_LOADED unless each is really there. */
+/** Loads `families` (Kinetic's own faces, else Google Fonts, 400–800); with `strict`, throws FONT_NOT_LOADED unless each is really there. */
export async function fontsReady(families: (string | undefined)[], opts: { strict?: boolean; text?: string } = {}): Promise<void> {
if (typeof document === "undefined") return;
const list = [...new Set(families.filter((f): f is string => !!f?.trim()).map((f) => f.trim()))];
- await Promise.all(list.map((f) => ensureFont(f, opts.strict ? 8000 : 2500)));
+ // Kinetic's own faces come from Fuobe itself; brand fonts from the web-font service.
+ await Promise.all([loadKineticFaces(list.filter(isKineticFamily)), ...list.filter((f) => !isKineticFamily(f)).map((f) => ensureFont(f, opts.strict ? 8000 : 2500))]);
const sample = opts.text?.trim() || "Aa";
await Promise.all(list.flatMap((f) => WEIGHTS.map((w) => document.fonts.load(`${w} 32px "${f}"`, sample).catch(() => []))));
if (!opts.strict) return;
diff --git a/src/components/motion/kinetic-fonts.ts b/src/components/motion/kinetic-fonts.ts
new file mode 100644
index 00000000..7ad30cf9
--- /dev/null
+++ b/src/components/motion/kinetic-fonts.ts
@@ -0,0 +1,41 @@
+"use client";
+
+import { preload } from "react-dom";
+import { faceUrl, facesOf, KINETIC_UNICODE_RANGE, type FontStyle, type KineticFace } from "@/lib/motion/type/faces";
+
+/**
+ * Kinetic's own faces in the page: each is registered once (FontFace, self-hosted WOFF2), only when a template uses it,
+ * and preloaded while the page renders so its first frame already has the right type.
+ */
+
+const registered = new Map<string, Promise<void>>();
+
+function register(face: KineticFace): Promise<void> {
+ let p = registered.get(face.id);
+ if (!p) {
+ p = (async () => {
+ if (typeof document === "undefined" || typeof FontFace === "undefined") return;
+ const weight = face.weight[0] === face.weight[1] ? String(face.weight[0]) : `${face.weight[0]} ${face.weight[1]}`;
+ const ff = new FontFace(face.family, `url(${faceUrl(face)}) format("woff2")`, { weight, style: face.style, display: "block", unicodeRange: KINETIC_UNICODE_RANGE });
+ document.fonts.add(ff);
+ await ff.load();
+ })().catch(() => {
+ // Let a later call try again.
+ registered.delete(face.id);
+ });
+ registered.set(face.id, p);
+ }
+ return p;
+}
+
+type Wanted = string | { family: string; style?: FontStyle } | null | undefined;
+
+/** Load the Kinetic faces these families need (others are ignored: brand fonts load through their own path). */
+export async function loadKineticFaces(families: Iterable<Wanted>): Promise<void> {
+ await Promise.all(facesOf(families).map(register));
+}
+
+/** Ask the browser to fetch these faces early (call while rendering a template's page). */
+export function preloadKineticFaces(families: Iterable<Wanted>): void {
+ for (const f of facesOf(families)) preload(faceUrl(f), { as: "font", type: "font/woff2", crossOrigin: "anonymous" });
+}
diff --git a/src/components/motion/player.tsx b/src/components/motion/player.tsx
index 5f24ced4..b49d97b4 100644
--- a/src/components/motion/player.tsx
+++ b/src/components/motion/player.tsx
@@ -4,7 +4,7 @@ import { Pause, Play, Repeat } from "lucide-react";
import { useEffect, useMemo, useRef, useState } from "react";
import { measureText } from "@/components/ads/render";
import type { Recipe } from "@/lib/motion/recipe";
-import { loadScene } from "@/lib/motion/registry";
+import { loadScene, sceneFamilies } from "@/lib/motion/registry";
import type { LogoInfo, Outline, Scene, ScenePlan } from "@/lib/motion/scene";
import { previewSize, type SizeSpec } from "@/lib/motion/sizes";
import { cn } from "@/lib/utils";
@@ -38,20 +38,21 @@ export function useMotionInputs(recipe: Recipe | null): MotionInputs {
const productUrl = recipe?.media?.product || null;
const heading = recipe?.brand.fonts.heading;
const body = recipe?.brand.fonts.body;
+ const faces = sceneFamilies(recipe?.scene).join("|");
const text = recipe ? Object.values(recipe.fields).join(" ") : "";
const [state, setState] = useState<MotionInputs>({ ready: false, sources: EMPTY_SOURCES, logo: null, version: 0 });
useEffect(() => {
let live = true;
void (async () => {
const loaded = await loadMotionInputs({ logo: logoUrl, product: productUrl });
- await fontsReady([heading, body], { text }).catch(() => undefined);
+ await fontsReady([heading, body, ...(faces ? faces.split("|") : [])], { text }).catch(() => undefined);
if (!live) return;
setState((s) => ({ ready: true, ...loaded, version: s.version + 1 }));
})();
return () => {
live = false;
};
- }, [logoUrl, productUrl, heading, body, text]);
+ }, [logoUrl, productUrl, heading, body, faces, text]);
return state;
}
diff --git a/src/lib/catalog/marketing.ts b/src/lib/catalog/marketing.ts
index 1a364be5..d05100a1 100644
--- a/src/lib/catalog/marketing.ts
+++ b/src/lib/catalog/marketing.ts
@@ -340,8 +340,8 @@ export interface MarketingTemplate {
fields?: TemplateField[];
/** Its quick choices (2 to 4 groups). */
easy?: EasyGroup[];
- /** It shows a picture: the product (a cut-out traces best), else the logo. */
- picture?: "product";
+ /** It shows a picture: the product (a cut-out traces best), else the logo; or a photo that fills its panel. */
+ picture?: "product" | "photo";
/** Its length range when it differs from the format's (seconds). */
lengths?: { min: number; max: number; default: number };
}
@@ -419,10 +419,14 @@ export const TEMPLATES: MarketingTemplate[] = [
// Motion · 2D
t("m2-sticker-pop", "Sticker Pop", "motion-2d", { scene: "collage", hue: 330, hue2: 60 }, "Flat 2D animation: the product pops in as a die-cut sticker, bouncy squash and stretch, doodled stars and sparkles burst around it on a flat colour background", { duration: 5 }),
t("m2-paper-parade", "Paper Parade", "motion-2d", { scene: "collage", hue: 30, hue2: 200 }, "Paper cut-out animation: layered paper shapes slide in like a theatre set and the product rises from behind them, gentle stop-motion jitter", { duration: 5 }),
- t("m2-line-reveal", "Line-Art Reveal", "motion-2d", { scene: "kinetic", hue: 160, hue2: 160 }, "A single continuous line draws the outline of the product, then the real product fills in inside it, clean minimal background", code("marketing/line-reveal", [field("headline", "Headline", 60, 2), field("cta", "Call to action", 30)], { picture: "product", aspect: "9:16", easy: [PACE, LOOK, { id: "line", label: "Line", choices: [{ id: "fine", label: "Fine" }, { id: "bold", label: "Bold" }] }] })),
+ t("m2-line-reveal", "Line-Art Reveal", "motion-2d", { scene: "kinetic", hue: 160, hue2: 160 }, "A single continuous line draws the outline of the product, then the real product fills in inside it, clean minimal background", code("marketing/line-reveal", [field("headline", "Headline", 60, 2), field("cta", "Call to action", 30), field("website", "Web address", 40), field("note", "Corner note", 24, 1, "A small fact for the corner, e.g. Collection 07 or Est. 2019")], { picture: "product", aspect: "9:16", easy: [PACE, LOOK, { id: "line", label: "Line", choices: [{ id: "fine", label: "Fine" }, { id: "bold", label: "Bold" }] }] })),
t("m2-comic-panels", "Comic Panels", "motion-2d", { scene: "split", hue: 50, hue2: 0 }, "Pop-art comic panels flip one after another, each showing the product from a new angle with halftone dots and bold outlines", { duration: 5 }),
- t("m2-retro-starburst", "Retro Starburst", "motion-2d", { scene: "burst", hue: 25, hue2: 330 }, "A rotating retro starburst background in warm colours while the product spins slowly in the centre, groovy 70s motion graphics", code("marketing/starburst", [field("headline", "Headline", 40, 2), field("badge", "Badge", 12, 2)], { picture: "product", aspect: "9:16" })),
- t("m2-offer-badge", "Offer Badge", "motion-2d", { scene: "badge", hue: 350, hue2: 40 }, "A starburst offer badge pops and turns, the product slides in under it and the call to action follows", code("marketing/offer-badge", [field("offer", "Offer", 14, 2), field("headline", "Headline", 40, 2), field("cta", "Call to action", 24)], { picture: "product", aspect: "9:16" })),
+ t("m2-retro-starburst", "Retro Starburst", "motion-2d", { scene: "burst", hue: 25, hue2: 330 }, "A rotating retro starburst background in warm colours while the product spins slowly in the centre, groovy 70s motion graphics", code("marketing/starburst", [field("headline", "Headline", 40, 2), field("badge", "Badge", 12, 2), field("website", "Web address", 40), field("note", "Corner note", 24, 1, "A small fact for the corner, e.g. Collection 07 or Est. 2019")], { picture: "product", aspect: "9:16" })),
+ t("m2-offer-badge", "Offer Badge", "motion-2d", { scene: "badge", hue: 350, hue2: 40 }, "A starburst offer badge pops and turns, the product slides in under it and the call to action follows", code("marketing/offer-badge", [field("offer", "Offer", 14, 2), field("headline", "Headline", 40, 2), field("cta", "Call to action", 24), field("website", "Web address", 40), field("note", "Corner note", 24, 1, "A small fact for the corner, e.g. Collection 07 or Est. 2019")], { picture: "product", aspect: "9:16" })),
+ t("m2-midnight-drop", "Midnight Drop", "motion-2d", { scene: "kinetic", hue: 15, hue2: 0, dark: true }, "A launch countdown: the drop's name cuts in huge, the countdown flips into place tile by tile and the time and call to action follow on a dark field of moving light", code("marketing/drop-countdown", [field("headline", "Drop name", 28, 2), field("count", "Countdown", 12, 1, "Type it as it should read, e.g. 03:12:45"), field("when", "When", 32), field("cta", "Call to action", 24), field("website", "Web address", 40), field("note", "Corner note", 24, 1, "A small fact for the corner, e.g. Collection 07 or Est. 2019")], { aspect: "9:16" })),
+ t("m2-nocturne", "Nocturne", "motion-2d", { scene: "noir", hue: 40, hue2: 270, dark: true }, "A fragrance reveal: ribbons of light cross a night field, the bottle rises into a pool of light and a fine serif name settles over it", code("marketing/fragrance-reveal", [field("headline", "Name", 40, 2), field("line", "Line", 60, 2), field("cta", "Call to action", 24), field("website", "Web address", 40), field("note", "Corner note", 24, 1, "A small fact for the corner, e.g. Collection 07 or Est. 2019")], { picture: "product", aspect: "9:16" })),
+ t("m2-season-finale", "Season Finale", "motion-2d", { scene: "type", hue: 8, hue2: 30 }, "An editorial sale poster: a fashion photo, the sale in huge condensed type that bleeds off the frame, the offer on a highlighter and a tilted pill", code("marketing/editorial-sale", [field("headline", "Headline", 24, 2), field("offer", "Offer", 28, 2), field("cta", "Call to action", 24), field("website", "Web address", 40), field("note", "Corner note", 24, 1, "A small fact for the corner, e.g. Collection 07 or Est. 2019")], { picture: "photo", aspect: "4:5" })),
+ t("m2-prism-stage", "Prism Stage", "motion-2d", { scene: "pedestal", hue: 150, hue2: 45, dark: true }, "A glass product spotlight: the product stands on a glass plinth inside rings of light while its name and a short line set beside it", code("marketing/glass-spotlight", [field("headline", "Headline", 40, 2), field("line", "Line", 60, 2), field("cta", "Call to action", 24), field("website", "Web address", 40), field("note", "Corner note", 24, 1, "A small fact for the corner, e.g. Collection 07 or Est. 2019")], { picture: "product", aspect: "4:5" })),
t("m2-grid-shuffle", "Grid Shuffle", "motion-2d", { scene: "cards", hue: 200, hue2: 280 }, "A Swiss-style grid of colour tiles shuffles and slides; one tile opens to reveal the product, crisp geometric transitions", { duration: 5 }),
// Motion · hypermotion
@@ -440,17 +444,21 @@ export const TEMPLATES: MarketingTemplate[] = [
t("mm-riso-loop", "Riso Loop", "motion-mixed", { scene: "type", hue: 350, hue2: 210 }, "Risograph-print look with grain and slight misregistration; the product cycles through two-colour duotone frames"),
t("mm-y2k-desktop", "Y2K Desktop", "motion-mixed", { scene: "cards", hue: 190, hue2: 300 }, "A Y2K computer desktop: pop-up windows, chrome icons and a cursor open a window that shows the product"),
t("mm-clay-diorama", "Clay Diorama", "motion-mixed", { scene: "pedestal", hue: 20, hue2: 140 }, "Claymation diorama: tiny clay props and a little set animate in stop motion around the real product"),
+ t("mm-marquee", "Marquee", "motion-mixed", { scene: "noir", hue: 280, hue2: 30, dark: true }, "An event announcement: a night photo, the event's name lit up in big warm type, the date, the place and the call to action set on the grid", code("marketing/announcement", [field("headline", "Event", 32, 2), field("when", "When", 40), field("place", "Where", 48), field("cta", "Call to action", 24), field("website", "Web address", 40), field("note", "Corner note", 24, 1, "A small fact for the corner, e.g. Collection 07 or Est. 2019")], { picture: "photo", aspect: "9:16" })),
+ t("mm-runway-titles", "Runway Titles", "motion-mixed", { scene: "model", hue: 40, hue2: 20 }, "Fashion lookbook titles: a full-bleed editorial photo, a giant title cut in letter by letter with a script word laid over it and tiny facts in the corners", code("marketing/lookbook", [field("headline", "Title", 28, 2), field("accent", "Script word", 20), field("line", "Line", 48), field("website", "Web address", 40), field("note", "Corner note", 24, 1, "A small fact for the corner, e.g. Collection 07 or Est. 2019")], { picture: "photo", aspect: "4:5" })),
t("mm-halftone-collage", "Halftone Collage", "motion-mixed", { scene: "split", hue: 0, hue2: 50 }, "Halftone street-poster collage: cut-out shapes and the product slide in with punchy, rhythmic cuts"),
// Motion · SaaS
- t("ms-feature-cards", "Feature Cards", "motion-saas", { scene: "cards", hue: 250, hue2: 200 }, "Clean SaaS motion design: rounded feature cards fly in and stack, each one highlighting a benefit, soft gradients and smooth easing", code("marketing/feature-cards", [field("headline", "Headline", 60, 2), field("point1", "First benefit", 60, 2), field("point2", "Second benefit", 60, 2), field("point3", "Third benefit", 60, 2)], { aspect: "4:5" })),
- t("ms-kinetic-headline", "Kinetic Headline", "motion-saas", { scene: "kinetic", hue: 210, hue2: 260 }, "Kinetic typography: the product's promise types itself out word by word with confident motion, then resolves to the logo", code("marketing/kinetic-headline", [field("headline", "Headline", 90, 3, "Put *stars* round a word to highlight it"), field("cta", "Call to action", 24), field("website", "Web address", 40)], { aspect: "9:16", easy: [PACE, LOOK, { id: "align", label: "Align", choices: [{ id: "centre", label: "Centred" }, { id: "left", label: "Left" }] }] })),
+ t("ms-feature-cards", "Feature Cards", "motion-saas", { scene: "cards", hue: 250, hue2: 200 }, "Clean SaaS motion design: rounded feature cards fly in and stack, each one highlighting a benefit, soft gradients and smooth easing", code("marketing/feature-cards", [field("headline", "Headline", 60, 2), field("point1", "First benefit", 60, 2), field("point2", "Second benefit", 60, 2), field("point3", "Third benefit", 60, 2), field("website", "Web address", 40), field("note", "Corner note", 24, 1, "A small fact for the corner, e.g. Collection 07 or Est. 2019")], { aspect: "4:5" })),
+ t("ms-kinetic-headline", "Kinetic Headline", "motion-saas", { scene: "kinetic", hue: 210, hue2: 260 }, "Kinetic typography: the product's promise types itself out word by word with confident motion, then resolves to the logo", code("marketing/kinetic-headline", [field("headline", "Headline", 90, 3, "Put *stars* round a word to highlight it"), field("cta", "Call to action", 24), field("website", "Web address", 40), field("note", "Corner note", 24, 1, "A small fact for the corner, e.g. Collection 07 or Est. 2019")], { aspect: "9:16", easy: [PACE, LOOK, { id: "align", label: "Align", choices: [{ id: "centre", label: "Centred" }, { id: "left", label: "Left" }] }] })),
t("ms-device-float", "Device Float", "motion-saas", { scene: "float", hue: 220, hue2: 170 }, "A laptop and a phone float in a soft gradient space showing the app's interface, the camera drifts slowly between them", { duration: 5 }),
- t("ms-dashboard-zoom", "Dashboard Zoom", "motion-saas", { scene: "cards", hue: 160, hue2: 220, dark: true }, "The camera pushes into a sleek dark dashboard; charts animate up and a key number counts to its value", code("marketing/stat-dashboard", [field("stat", "Key number", 16, 1, "Type it as it should read, e.g. $1,284,000"), field("label", "What it measures", 60, 2)], { aspect: "4:5" })),
- t("ms-logo-sting", "Logo Sting", "motion-saas", { scene: "burst", hue: 270, hue2: 210 }, "A short logo sting: geometric shapes converge and click together into the brand mark with a light flare", code("marketing/logo-sting", [field("tagline", "Line under the logo", 60, 2)], { aspect: "4:5" })),
- t("ms-big-number", "Big Number", "motion-saas", { scene: "headline", hue: 230, hue2: 260, dark: true }, "One huge stat fills the frame and counts up to its value, a caption rises under it, and it ends on the logo", code("marketing/big-number", [field("stat", "The number", 12, 1, "Type it as it should read, e.g. 3× or 98%"), field("caption", "Caption", 60, 3)], { aspect: "4:5" })),
- t("ms-five-star-quote", "Five-Star Quote", "motion-saas", { scene: "stars", hue: 45, hue2: 30 }, "Five stars fill one by one, then a customer's words set line by line with their name", code("marketing/quote", [field("quote", "Quote", 180, 5, "Their words exactly, with your own quotation marks"), field("name", "Name", 48, 2)], { aspect: "4:5" })),
- t("ms-end-card", "Logo End Card", "motion-saas", { scene: "headline", hue: 160, hue2: 45, dark: true }, "An animated end card: the logo draws on, the line rises and the call-to-action pill pops", code("end-card/draw-on", [field("product", "Line", 60, 2), field("cta", "Call to action", 24), field("website", "Web address", 40)], { aspect: "9:16", duration: 2.5, lengths: { min: 2, max: 3, default: 2.5 }, easy: [{ id: "style", label: "Style", scene: "end-card", choices: [{ id: "draw-on", label: "Draw-on" }, { id: "rise", label: "Rise" }, { id: "iris", label: "Iris" }, { id: "split", label: "Split" }, { id: "glint", label: "Glint" }] }, { id: "mark", label: "Mark", choices: [{ id: "logo", label: "Logo" }, { id: "name", label: "Name" }] }] })),
+ t("ms-dashboard-zoom", "Dashboard Zoom", "motion-saas", { scene: "cards", hue: 160, hue2: 220, dark: true }, "The camera pushes into a sleek dark dashboard; charts animate up and a key number counts to its value", code("marketing/stat-dashboard", [field("stat", "Key number", 16, 1, "Type it as it should read, e.g. $1,284,000"), field("label", "What it measures", 60, 2), field("website", "Web address", 40), field("note", "Corner note", 24, 1, "A small fact for the corner, e.g. Collection 07 or Est. 2019")], { aspect: "4:5" })),
+ t("ms-logo-sting", "Logo Sting", "motion-saas", { scene: "burst", hue: 270, hue2: 210 }, "A short logo sting: geometric shapes converge and click together into the brand mark with a light flare", code("marketing/logo-sting", [field("tagline", "Line under the logo", 60, 2), field("website", "Web address", 40), field("note", "Corner note", 24, 1, "A small fact for the corner, e.g. Collection 07 or Est. 2019")], { aspect: "4:5" })),
+ t("ms-big-number", "Big Number", "motion-saas", { scene: "headline", hue: 230, hue2: 260, dark: true }, "One huge stat fills the frame and counts up to its value, a caption rises under it, and it ends on the logo", code("marketing/big-number", [field("stat", "The number", 12, 1, "Type it as it should read, e.g. 3× or 98%"), field("caption", "Caption", 60, 3), field("website", "Web address", 40), field("note", "Corner note", 24, 1, "A small fact for the corner, e.g. Collection 07 or Est. 2019")], { aspect: "4:5" })),
+ t("ms-five-star-quote", "Five-Star Quote", "motion-saas", { scene: "stars", hue: 45, hue2: 30 }, "Five stars fill one by one, then a customer's words set line by line with their name", code("marketing/quote", [field("quote", "Quote", 180, 5, "Their words exactly, with your own quotation marks"), field("name", "Name", 48, 2), field("website", "Web address", 40), field("note", "Corner note", 24, 1, "A small fact for the corner, e.g. Collection 07 or Est. 2019")], { picture: "photo", aspect: "4:5" })),
+ t("ms-stat-stack", "Stat Stack", "motion-saas", { scene: "headline", hue: 220, hue2: 15 }, "Three big numbers stacked on an editorial grid, each rolling up to its value with its label, the brand signing off at the foot", code("marketing/stat-stack", [field("stat1", "First number", 10, 1, "Type it as it should read, e.g. 98%"), field("label1", "What it measures", 40), field("stat2", "Second number", 10), field("label2", "What it measures", 40), field("stat3", "Third number", 10), field("label3", "What it measures", 40), field("website", "Web address", 40), field("note", "Corner note", 24, 1, "A small fact for the corner, e.g. Collection 07 or Est. 2019")], { aspect: "4:5" })),
+ t("ms-kind-words", "Kind Words", "motion-saas", { scene: "stars", hue: 210, hue2: 40 }, "A testimonial carousel: three customers' words slide through one after another on cards, each with its stars and name", code("marketing/testimonials", [field("quote1", "First quote", 120, 3), field("name1", "Name", 40), field("quote2", "Second quote", 120, 3), field("name2", "Name", 40), field("quote3", "Third quote", 120, 3), field("name3", "Name", 40), field("website", "Web address", 40), field("note", "Corner note", 24, 1, "A small fact for the corner, e.g. Collection 07 or Est. 2019")], { aspect: "4:5" })),
+ t("ms-end-card", "Logo End Card", "motion-saas", { scene: "headline", hue: 160, hue2: 45, dark: true }, "An animated end card: the logo draws on, the line rises and the call-to-action pill pops", code("end-card/draw-on", [field("product", "Line", 60, 2), field("cta", "Call to action", 24), field("website", "Web address", 40)], { aspect: "9:16", duration: 4, lengths: { min: 2, max: 5, default: 4 }, easy: [{ id: "style", label: "Style", scene: "end-card", choices: [{ id: "draw-on", label: "Draw-on" }, { id: "rise", label: "Rise" }, { id: "iris", label: "Iris" }, { id: "split", label: "Split" }, { id: "glint", label: "Glint" }] }, { id: "mark", label: "Mark", choices: [{ id: "logo", label: "Logo" }, { id: "name", label: "Name" }] }] })),
// UGC · talking head
t("ugc-honest-review", "Honest Review", "ugc-talking", { scene: "selfie", hue: 25, hue2: 200 }, "A relaxed, honest review straight to the phone camera: what they liked, one small catch and why they'd still buy it again", { setting: "bedroom" }),
diff --git a/src/lib/motion/color.ts b/src/lib/motion/color.ts
new file mode 100644
index 00000000..385f16f0
--- /dev/null
+++ b/src/lib/motion/color.ts
@@ -0,0 +1,232 @@
+/**
+ * Colour for Kinetic looks (pure): OKLab maths, and the palette a look derives from a brand kit's two colours.
+ *
+ * - Every derived colour stays on the brand's hues: tonal steps move lightness only, in OKLab, so the hue a person
+ * chose never shifts. Contrast is fixed the same way (lightness moves, never the hue).
+ * - `paper` is a warm off-white tinted toward the brand; `night` is the brand's hue near black. Large fields are never
+ * pure white or pure black.
+ * - Gradients between two colours are sampled in OKLab (a canvas blends in sRGB, which goes muddy in the middle).
+ */
+
+export interface Lab {
+ L: number;
+ a: number;
+ b: number;
+}
+
+const HEX = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i;
+
+function rgbOf(hex: string): [number, number, number] {
+ const m = HEX.exec(hex.trim());
+ if (!m) return [0, 0, 0];
+ const h = m[1].length === 3 ? [...m[1]].map((c) => c + c).join("") : m[1];
+ return [0, 2, 4].map((i) => parseInt(h.slice(i, i + 2), 16) / 255) as [number, number, number];
+}
+
+const toLinear = (c: number) => (c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4);
+const toGamma = (c: number) => (c <= 0.0031308 ? 12.92 * c : 1.055 * c ** (1 / 2.4) - 0.055);
+
+/** sRGB hex to OKLab. */
+export function toLab(hex: string): Lab {
+ const [r, g, b] = rgbOf(hex).map(toLinear);
+ const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);
+ const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);
+ const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);
+ return { L: 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s, a: 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s, b: 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s };
+}
+
+function labToLinear({ L, a, b }: Lab): [number, number, number] {
+ const l = (L + 0.3963377774 * a + 0.2158037573 * b) ** 3;
+ const m = (L - 0.1055613458 * a - 0.0638541728 * b) ** 3;
+ const s = (L - 0.0894841775 * a - 1.291485548 * b) ** 3;
+ return [4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s, -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s, -0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s];
+}
+
+const inGamut = (c: [number, number, number]) => c.every((v) => v >= -1e-4 && v <= 1 + 1e-4);
+
+/** OKLab to sRGB hex; out-of-gamut colours lose chroma (keeping lightness and hue) until they fit. */
+export function fromLab(lab: Lab): string {
+ let c = labToLinear(lab);
+ if (!inGamut(c)) {
+ let lo = 0;
+ let hi = 1;
+ for (let i = 0; i < 24; i++) {
+ const k = (lo + hi) / 2;
+ if (inGamut(labToLinear({ L: lab.L, a: lab.a * k, b: lab.b * k }))) lo = k;
+ else hi = k;
+ }
+ c = labToLinear({ L: lab.L, a: lab.a * lo, b: lab.b * lo });
+ }
+ return `#${c.map((v) => Math.round(Math.min(1, Math.max(0, toGamma(Math.min(1, Math.max(0, v))))) * 255).toString(16).padStart(2, "0")).join("")}`;
+}
+
+/** Two colours mixed in OKLab (p = 0: a, 1: b). */
+export function mixOk(a: string, b: string, p: number): string {
+ const x = toLab(a);
+ const y = toLab(b);
+ return fromLab({ L: x.L + (y.L - x.L) * p, a: x.a + (y.a - x.a) * p, b: x.b + (y.b - x.b) * p });
+}
+
+/** The colour at OKLab lightness L, same hue (chroma kept where it fits). */
+export function withLightness(hex: string, L: number): string {
+ const c = toLab(hex);
+ return fromLab({ L: Math.min(1, Math.max(0, L)), a: c.a, b: c.b });
+}
+
+/** Chroma (colourfulness) in OKLab. */
+export const chroma = (hex: string): number => {
+ const c = toLab(hex);
+ return Math.hypot(c.a, c.b);
+};
+
+/** WCAG relative luminance and contrast ratio. */
+export function luminanceOf(hex: string): number {
+ const [r, g, b] = rgbOf(hex).map(toLinear);
+ return 0.2126 * r + 0.7152 * g + 0.0722 * b;
+}
+export function contrastOf(a: string, b: string): number {
+ const x = luminanceOf(a);
+ const y = luminanceOf(b);
+ return (Math.max(x, y) + 0.05) / (Math.min(x, y) + 0.05);
+}
+
+/**
+ * `fg` moved in lightness only until it reaches `min` contrast against `bg`: away from `bg` first (darker on a light
+ * ground), the other way when that can't reach it (a mid-tone ground), else whichever end reads best.
+ */
+export function ensureContrast(fg: string, bg: string, min: number): string {
+ if (contrastOf(fg, bg) >= min) return fg;
+ const L = toLab(fg).L;
+ const search = (darker: boolean): string | null => {
+ let lo = darker ? 0 : L;
+ let hi = darker ? L : 1;
+ // The lightness nearest the original that passes.
+ for (let i = 0; i < 30; i++) {
+ const mid = (lo + hi) / 2;
+ const ok = contrastOf(withLightness(fg, mid), bg) >= min;
+ if (darker) {
+ if (ok) lo = mid;
+ else hi = mid;
+ } else if (ok) hi = mid;
+ else lo = mid;
+ }
+ const out = withLightness(fg, darker ? lo : hi);
+ return contrastOf(out, bg) >= min ? out : null;
+ };
+ const first = toLab(bg).L > 0.6;
+ const found = search(first) ?? search(!first);
+ if (found) return found;
+ return contrastOf("#0b0b0c", bg) >= contrastOf("#fbfaf7", bg) ? "#0b0b0c" : "#fbfaf7";
+}
+
+/** `n` gradient stops from a to b sampled in OKLab (for a canvas gradient that stays clean in the middle). */
+export function okStops(a: string, b: string, n = 5, from = 0, to = 1): { at: number; color: string }[] {
+ return Array.from({ length: n }, (_, i) => ({ at: from + ((to - from) * i) / (n - 1), color: mixOk(a, b, i / (n - 1)) }));
+}
+
+export type Look = "brand" | "light" | "dark";
+
+export interface KineticPalette {
+ look: Look;
+ ground: string;
+ /** The hero colour (the strongest contrast against the ground). */
+ ink: string;
+ /** Tonal steps of the ground toward the ink (ghost type, panels, rings). */
+ tone1: string;
+ tone2: string;
+ /** Overlays: the pill, the highlighter, one word. */
+ accent: string;
+ /** Ink on the accent. */
+ onAccent: string;
+ paper: string;
+ night: string;
+ /** Small details (ink at 75 %). */
+ meta: string;
+ /** The brand's two colours as given. */
+ brand: [string, string];
+}
+
+const rgba = (hex: string, a: number) => {
+ const [r, g, b] = rgbOf(hex).map((v) => Math.round(v * 255));
+ return `rgba(${r},${g},${b},${a})`;
+};
+
+/** A look's palette from a brand kit's colours (§ brand first: no hue outside the kit but paper, night and light). */
+export function kineticPalette(colors: readonly string[], look: Look): KineticPalette {
+ const kit = colors.filter((c) => HEX.test(c)).map((c) => (c.startsWith("#") ? c : `#${c}`).toLowerCase());
+ const c0 = kit[0] ?? "#1f3a5f";
+ const c1 = kit[1] ?? mixOk(c0, "#ffffff", 0.7);
+ const paper = mixOk("#faf7f2", c0, 0.035);
+ // Night: the brand's own hue near black with only a trace of its colour (a muddy mid-chroma dark reads olive or khaki).
+ const lab0 = toLab(c0);
+ const C0 = Math.hypot(lab0.a, lab0.b);
+ const nc = C0 > 1e-4 ? Math.min(0.032, C0 * 0.4) / C0 : 0;
+ const night = fromLab({ L: 0.135, a: lab0.a * nc, b: lab0.b * nc });
+ let ground: string;
+ let ink: string;
+ let accent: string;
+ if (look === "light") {
+ ground = paper;
+ ink = ensureContrast(c0, ground, 4.5);
+ accent = c1;
+ } else if (look === "dark") {
+ ground = night;
+ ink = paper;
+ accent = ensureContrast(c1, ground, 3);
+ } else {
+ ground = c0;
+ // The second colour on the first when it reads (a two-tone look), else paper or night.
+ const candidates = [c1, paper, night];
+ ink = candidates.find((c) => contrastOf(c, ground) >= 4.5) ?? candidates.sort((a, b) => contrastOf(b, ground) - contrastOf(a, ground))[0];
+ // A mid-tone brand colour that nothing reads on at 4.5:1: the ground steps in lightness (away from the ink) until it does.
+ if (contrastOf(ink, ground) < 4.5) ground = ensureContrast(ground, ink, 4.5);
+ accent = ink === c1 ? (contrastOf(paper, ground) > contrastOf(night, ground) ? paper : night) : c1;
+ }
+ const gL = toLab(ground).L;
+ const iL = toLab(ink).L;
+ const step = (k: number) => withLightness(ground, gL + (iL - gL) * k);
+ const onAccent = [ground, paper, night].sort((a, b) => contrastOf(b, accent) - contrastOf(a, accent))[0];
+ return { look, ground, ink, tone1: step(0.09), tone2: step(0.15), accent, onAccent, paper, night, meta: rgba(ink, 0.75), brand: [c0, c1] };
+}
+
+/** A colour at OKLCh (lightness, chroma, hue in degrees); out-of-gamut chroma is reduced to fit. */
+export function fromLch(L: number, C: number, h: number): string {
+ const r = (h * Math.PI) / 180;
+ return fromLab({ L: Math.min(1, Math.max(0, L)), a: C * Math.cos(r), b: C * Math.sin(r) });
+}
+
+/** OKLCh of a colour (hue in degrees). */
+export function lchOf(hex: string): { L: number; C: number; h: number } {
+ const c = toLab(hex);
+ return { L: c.L, C: Math.hypot(c.a, c.b), h: ((Math.atan2(c.b, c.a) * 180) / Math.PI + 360) % 360 };
+}
+
+/**
+ * A lit two-stop field for a look (§3.2): the dark stop is the brand's hue deep (L 0.11, chroma at least 60 % of the
+ * brand's), the light stop 0.2 lighter with the hue turned 20° (an analogous pair, never grey). Olive-prone hues
+ * (yellows and greens near 70–125°) keep their chroma low. Light looks: paper tinted toward the brand, a step deeper at
+ * its far corner. Brand looks: the brand colour a step either side.
+ */
+export function fieldStops(pal: KineticPalette): { dark: string; light: string } {
+ const b = lchOf(pal.brand[0]);
+ const olive = b.h > 70 && b.h < 125;
+ if (pal.look === "light") {
+ const C = Math.min(0.03, b.C * 0.25);
+ return { light: fromLch(0.975, C * 0.6, b.h), dark: fromLch(0.92, C, (b.h + 18) % 360) };
+ }
+ const g = lchOf(pal.ground);
+ if (pal.look === "brand" && g.L > 0.2) {
+ return { dark: fromLch(g.L - 0.07, g.C * 1.05, g.h), light: fromLch(g.L + 0.08, g.C, (g.h + 18) % 360) };
+ }
+ const C = olive ? Math.min(0.035, b.C * 0.4) : Math.max(0.6 * b.C, Math.min(0.08, b.C));
+ return { dark: fromLch(0.115, C * 0.75, b.h), light: fromLch(0.32, C, (b.h + 20) % 360) };
+}
+
+/** Whether two hues are close enough for a gradient between them (within ±30° in OKLCh). */
+export function analogous(a: string, b: string, maxDeg = 30): boolean {
+ const x = toLab(a);
+ const y = toLab(b);
+ if (Math.hypot(x.a, x.b) < 0.02 || Math.hypot(y.a, y.b) < 0.02) return true;
+ const d = Math.abs(Math.atan2(x.b, x.a) - Math.atan2(y.b, y.a)) * (180 / Math.PI);
+ return Math.min(d, 360 - d) <= maxDeg;
+}
diff --git a/src/lib/motion/display.ts b/src/lib/motion/display.ts
index 9c4fc26c..243ccd38 100644
--- a/src/lib/motion/display.ts
+++ b/src/lib/motion/display.ts
@@ -54,7 +54,15 @@ export interface Stroke {
join?: CanvasLineJoin;
}
-export type Blend = "source-over" | "multiply" | "screen" | "overlay" | "lighter" | "source-atop";
+export type Blend = "source-over" | "multiply" | "screen" | "overlay" | "lighter" | "source-atop" | "destination-in" | "destination-out" | "soft-light" | "hard-light" | "color-dodge";
+
+/** A box in design units (or, for an image's crop, in shares 0–1 of the picture). */
+export interface Box {
+ x: number;
+ y: number;
+ w: number;
+ h: number;
+}
/** What a group is clipped to: a (rounded) rectangle, an ellipse, or a closed path (path data in design units). */
export type ClipShape = { type: "rect"; x: number; y: number; w: number; h: number; r?: number } | { type: "ellipse"; cx: number; cy: number; rx: number; ry: number } | { type: "path"; d: string };
@@ -75,6 +83,18 @@ export interface GroupNode {
isolate?: { x: number; y: number; w: number; h: number };
/** A soft wipe: only what lies where the gradient is opaque shows (drawn on its own layer). */
mask?: Gradient & { bounds: { x: number; y: number; w: number; h: number } };
+ /**
+ * A blur in design units (a CSS blur's radius) on its own layer: the browser's gaussian where the canvas filters,
+ * else Fuobe's step-down blur (halved, then scaled back up), so it works in every browser. Glows, soft shadows,
+ * depth of field and blur-ins use it, on cached groups, so it costs once and not every frame.
+ */
+ soften?: number;
+ /**
+ * Drawn once into a bitmap and reused while `key` stays the same (ghost type, glows, extrusions, halftone, shadows):
+ * `bounds` is everything the children draw, in the group's own units (with room for `soften`). The key must change
+ * whenever what the children draw changes; the group's transform and opacity may change freely.
+ */
+ cache?: { key: string; bounds: Box };
children: DisplayNode[];
}
@@ -127,6 +147,13 @@ export interface TextRun {
dir?: "ltr" | "rtl";
opacity?: number;
transform?: Matrix;
+ /** An outline round the letters (hollow and outline type); with fill "transparent" only the outline is drawn. */
+ stroke?: { paint: Paint; width: number };
+ /**
+ * What is drawn in place of `text` for this frame only (a letter cycling before it locks, in a scramble). `text`
+ * stays the typed letter; at rest nothing is ever swapped.
+ */
+ shown?: string;
}
export interface TextNode {
@@ -135,6 +162,11 @@ export interface TextNode {
field: string;
runs: TextRun[];
opacity?: number;
+ /**
+ * A decorative copy of the field (a ghost, a glow, an echo, an extrusion, a colour split): never the readable words,
+ * so it may bleed off the frame; checks of readable text skip it.
+ */
+ decor?: boolean;
}
export interface ImageNode {
@@ -146,7 +178,13 @@ export interface ImageNode {
y: number;
w: number;
h: number;
+ /** The part of the picture drawn, in shares (0–1) of its width and height (all of it when absent). */
+ crop?: Box;
opacity?: number;
+ /** A photograph laid to the frame's edge as a ground or a panel: it may run under what covers the frame's edges (a tile's chips); words never do. */
+ bleed?: boolean;
+ /** A decorative copy of a picture (a reflection, a duotone ghost): never the picture itself. */
+ decor?: boolean;
smoothing?: boolean;
}
@@ -164,7 +202,28 @@ export interface VideoNode {
opacity?: number;
}
-export type DisplayNode = GroupNode | RectNode | EllipseNode | PathNode | TextNode | ImageNode | VideoNode;
+/**
+ * Film grain over a box: seeded mono noise tiles (made once per seed), the tile and its offset picked by `frame`, so a
+ * frame always gets the same grain and neighbouring frames differ. Blended (overlay on light grounds, screen on dark).
+ */
+export interface GrainNode {
+ type: "grain";
+ seed: number;
+ /** Which tile and offset (frames on twos: floor(frame / 2)). */
+ frame: number;
+ /** Alpha of the noise layer (0.03–0.06 reads as film, more as dirt). */
+ amount: number;
+ /** One grain's size in design units (1–1.5 at 1080). */
+ size: number;
+ blend: Blend;
+ x: number;
+ y: number;
+ w: number;
+ h: number;
+ opacity?: number;
+}
+
+export type DisplayNode = GroupNode | RectNode | EllipseNode | PathNode | TextNode | ImageNode | VideoNode | GrainNode;
export interface DisplayList {
/** Design size. */
@@ -181,12 +240,16 @@ export const videoNodeOf = (list: DisplayList): VideoNode | undefined => (list.n
export const group = (children: DisplayNode[], o: Omit<GroupNode, "type" | "children"> = {}): GroupNode => ({ type: "group", ...o, children });
-/** Every text node in a list, in drawing order (tests read the fields from it). */
-export function textNodes(nodes: readonly DisplayNode[]): TextNode[] {
+/**
+ * Every text node in a list that carries readable words, in drawing order (tests read the fields from it). Decorative
+ * copies (ghosts, glows, echoes) are left out unless `decor` is set.
+ */
+export function textNodes(nodes: readonly DisplayNode[], o: { decor?: boolean } = {}): TextNode[] {
const out: TextNode[] = [];
for (const n of nodes) {
- if (n.type === "text") out.push(n);
- else if (n.type === "group") out.push(...textNodes(n.children));
+ if (n.type === "text") {
+ if (o.decor || !n.decor) out.push(n);
+ } else if (n.type === "group") out.push(...textNodes(n.children, o));
}
return out;
}
diff --git a/src/lib/motion/ease.ts b/src/lib/motion/ease.ts
index 51175f6c..3e5544e9 100644
--- a/src/lib/motion/ease.ts
+++ b/src/lib/motion/ease.ts
@@ -154,13 +154,16 @@ export const hold: Ease = (p) => (p >= 1 ? 1 : 0);
export const SPRINGS = {
pop: { stiffness: 420, damping: 26 },
settle: { stiffness: 180, damping: 20 },
+ land: { stiffness: 300, damping: 18 },
} as const satisfies Record<string, SpringOptions>;
/**
* Fuobe's named curves: the only ones scenes use by name. enter: a soft expo-out for arrivals; glide: a gentler
* cubic-out for headlines and wide moves (the motion stays visible through its window); exit: leaving; move: an in-place
* move; pop: a button or badge, about 7 % past its size and back; settle: logos and large type; snap: small, UI-like
- * moves; draw: strokes; drift: a slow camera that comes to rest on the last frame.
+ * moves; draw: strokes; drift: a slow camera that comes to rest on the last frame. decel: a soft arrival with a long
+ * glide (quiet serif lines, quotes); roll: digits rolling to their value; whip: a fast in-place swap or camera whip;
+ * land: a sticker or pill landing with a bigger bounce (playful looks only); slam: accelerating into an impact (stomps).
*/
export const CURVES = {
enter: bezier(0.16, 1, 0.3, 1),
@@ -172,6 +175,11 @@ export const CURVES = {
settle: spring(SPRINGS.settle),
snap: bezier(0.2, 0, 0, 1),
draw: bezier(0.45, 0, 0.2, 1),
+ decel: bezier(0.05, 0.7, 0.1, 1),
+ roll: bezier(0.23, 1, 0.32, 1),
+ whip: bezier(0.83, 0, 0.17, 1),
+ land: spring(SPRINGS.land),
+ slam: expo.in,
linear,
} satisfies Record<string, Ease>;
diff --git a/src/lib/motion/fx/background.ts b/src/lib/motion/fx/background.ts
new file mode 100644
index 00000000..bdb094dd
--- /dev/null
+++ b/src/lib/motion/fx/background.ts
@@ -0,0 +1,191 @@
+/**
+ * Fields and atmosphere (pure): what sits behind the type. A field is never flat: a mesh of soft colour moving on
+ * slow seeded paths, light bars, an orb of glow, rings, a ribbon of light, bokeh. Every move is seeded and its period
+ * fits a whole number of times into the clip, so a looping clip closes without a jump.
+ */
+
+import { group, type DisplayNode, type GroupNode } from "../display";
+import { mixOk } from "../color";
+import { rng } from "../random";
+import { clamp } from "../time";
+import { CURVES } from "../ease";
+
+/** A period near `target` seconds that fits a whole number of times into `duration`. */
+export function loopPeriod(target: number, duration: number): number {
+ if (!(duration > 0)) return target;
+ return duration / Math.max(1, Math.round(duration / target));
+}
+
+/** A colour at an alpha (hex in). */
+export function rgba(hex: string, a: number): string {
+ const h = hex.replace("#", "");
+ const full = h.length === 3 ? [...h].map((c) => c + c).join("") : h.slice(0, 6).padEnd(6, "0");
+ const [r, g, b] = [0, 2, 4].map((i) => parseInt(full.slice(i, i + 2), 16));
+ return `rgba(${r},${g},${b},${clamp(a)})`;
+}
+
+/** A soft radial pool of a colour (four stops, so it fades without a ring). */
+export function pool(cx: number, cy: number, r: number, color: string, alpha: number): { kind: "radial"; cx: number; cy: number; r0: number; r1: number; stops: { at: number; color: string }[] } {
+ return {
+ kind: "radial",
+ cx,
+ cy,
+ r0: 0,
+ r1: Math.max(1, r),
+ stops: [
+ { at: 0, color: rgba(color, alpha) },
+ { at: 0.35, color: rgba(color, alpha * 0.7) },
+ { at: 0.7, color: rgba(color, alpha * 0.22) },
+ { at: 1, color: rgba(color, 0) },
+ ],
+ };
+}
+
+export interface MeshOptions {
+ w: number;
+ h: number;
+ /** 3–5 colours: the palette's tonal steps and its accent. */
+ colors: readonly string[];
+ seed: number;
+ t: number;
+ /** The clip's length (paths close on it). */
+ duration: number;
+ /** On a dark ground the pools add light (screen); on a light one they lay colour (normal). */
+ dark: boolean;
+ /** How far the pools wander, as a share of the frame (0.05–0.12). */
+ amplitude?: number;
+}
+
+/** A moving mesh gradient: 3–5 large pools of colour on seeded Lissajous paths. */
+export function meshGradient(o: MeshOptions): GroupNode {
+ const W = Math.max(o.w, o.h);
+ const nodes: DisplayNode[] = o.colors.slice(0, 5).map((c, i) => {
+ const r = (0.4 + 0.4 * rng(o.seed, "mesh-r", i)) * W;
+ const bx = 0.1 + 0.8 * rng(o.seed, "mesh-x", i);
+ const by = 0.1 + 0.8 * rng(o.seed, "mesh-y", i);
+ const amp = (o.amplitude ?? 0.05 + 0.07 * rng(o.seed, "mesh-a", i)) * W;
+ const px = loopPeriod(8 + 6 * rng(o.seed, "mesh-px", i), o.duration);
+ const py = loopPeriod(8 + 6 * rng(o.seed, "mesh-py", i), o.duration);
+ const fx = rng(o.seed, "mesh-fx", i) * Math.PI * 2;
+ const fy = rng(o.seed, "mesh-fy", i) * Math.PI * 2;
+ const cx = bx * o.w + amp * Math.sin((2 * Math.PI * o.t) / px + fx);
+ const cy = by * o.h + amp * Math.sin((2 * Math.PI * o.t) / py + fy);
+ const a = 0.3 + 0.4 * rng(o.seed, "mesh-alpha", i);
+ return { type: "rect", x: 0, y: 0, w: o.w, h: o.h, fill: pool(cx, cy, r, c, a) };
+ });
+ return group(nodes, { id: "mesh", ...(o.dark && { blend: "screen" }) });
+}
+
+export interface BarsOptions {
+ /** The box the bars fill (often the frame). */
+ x: number;
+ y: number;
+ w: number;
+ h: number;
+ /** 5–12 bars. */
+ count: number;
+ ground: string;
+ accent: string;
+ t: number;
+ duration: number;
+ seed: number;
+}
+
+/** Striped light: vertical bars from the ground into the accent, sliding 1–2 % sideways over the clip. */
+export function lightBars(o: BarsOptions): GroupNode {
+ const n = Math.max(3, Math.min(12, Math.round(o.count)));
+ const bw = o.w / n;
+ const slide = Math.sin((2 * Math.PI * o.t) / loopPeriod(10, o.duration)) * 0.015 * o.w;
+ const nodes: DisplayNode[] = Array.from({ length: n }, (_, i) => {
+ const lift = 0.35 + 0.5 * rng(o.seed, "bar-lift", i);
+ const top = mixOk(o.ground, o.accent, lift);
+ return {
+ type: "rect",
+ x: o.x + i * bw + slide,
+ y: o.y,
+ w: bw * (0.62 + 0.18 * rng(o.seed, "bar-w", i)),
+ h: o.h,
+ fill: { kind: "linear", x0: 0, y0: o.y, x1: 0, y1: o.y + o.h, stops: [{ at: 0, color: rgba(top, 0.95) }, { at: 0.55, color: rgba(mixOk(o.ground, o.accent, lift * 0.4), 0.6) }, { at: 1, color: rgba(o.ground, 0) }] },
+ };
+ });
+ return group(nodes, { id: "light-bars", clip: { type: "rect", x: o.x, y: o.y, w: o.w, h: o.h } });
+}
+
+/** One or two blurred discs of glow behind the hero (accent hue at 35–60 %). */
+export function orbGlow(o: { cx: number; cy: number; r: number; color: string; alpha?: number }): DisplayNode {
+ const R = o.r;
+ return { type: "rect", x: o.cx - R, y: o.cy - R, w: 2 * R, h: 2 * R, fill: pool(o.cx, o.cy, R, o.color, o.alpha ?? 0.45) };
+}
+
+/** Concentric rings in tonal steps from a point (often a corner). */
+export function rings(o: { cx: number; cy: number; count: number; gap: number; width?: number; colors: readonly string[]; alpha?: number; t?: number; drift?: number }): GroupNode {
+ const n = Math.max(1, Math.min(8, Math.round(o.count)));
+ const grow = (o.drift ?? 0) * (o.t ?? 0);
+ return group(
+ Array.from({ length: n }, (_, i) => {
+ const r = o.gap * (i + 1) + grow;
+ return { type: "ellipse" as const, cx: o.cx, cy: o.cy, rx: r, ry: r, stroke: { paint: rgba(o.colors[i % o.colors.length], o.alpha ?? 0.22), width: o.width ?? 1.5 } };
+ }),
+ { id: "rings" },
+ );
+}
+
+/**
+ * A ribbon of light: a thick curve with a gradient along it (clear → hue → white → hue → clear) over a blurred copy of
+ * itself, sweeping behind the hero. `p` (0–1) draws it on along its length.
+ */
+export function ribbon(o: { d: string; from: [number, number]; to: [number, number]; width: number; hue: string; p?: number; length?: number; key: string; bounds: { x: number; y: number; w: number; h: number } }): GroupNode {
+ const paint = { kind: "linear" as const, x0: o.from[0], y0: o.from[1], x1: o.to[0], y1: o.to[1], stops: [{ at: 0, color: rgba(o.hue, 0) }, { at: 0.3, color: rgba(o.hue, 0.9) }, { at: 0.5, color: "rgba(255,255,255,0.95)" }, { at: 0.7, color: rgba(o.hue, 0.9) }, { at: 1, color: rgba(o.hue, 0) }] };
+ const trim = o.p === undefined ? undefined : clamp(o.p);
+ const stroke = (w: number) => ({ paint, width: w, cap: "round" as const, ...(trim !== undefined && { trim, length: o.length }) });
+ const soft = trim === undefined || trim >= 1;
+ return group(
+ [
+ group([{ type: "path", d: o.d, stroke: stroke(o.width * 2.2) }], { soften: o.width * 1.2, opacity: 0.55, blend: "screen", ...(soft && { cache: { key: `ribbon|${o.key}|${o.width}`, bounds: o.bounds } }) }),
+ { type: "path", d: o.d, stroke: stroke(o.width) },
+ ],
+ { id: "ribbon" },
+ );
+}
+
+/** A dark ground: the brand's hue near black with a soft glow in its top third (never pure black). */
+export function nightGround(o: { w: number; h: number; night: string; glow: string; alpha?: number }): DisplayNode[] {
+ return [
+ { type: "rect", x: 0, y: 0, w: o.w, h: o.h, fill: o.night },
+ { type: "rect", x: 0, y: 0, w: o.w, h: o.h, fill: pool(o.w * 0.5, o.h * 0.22, Math.max(o.w, o.h) * 0.75, o.glow, o.alpha ?? 0.35) },
+ ];
+}
+
+/** Bokeh: at most three faint out-of-focus discs (alpha ≤ 0.1, a slightly brighter rim, a soft edge), drifting by their depth. */
+export function bokeh(o: { w: number; h: number; count: number; colors: readonly string[]; seed: number; t: number; duration: number }): GroupNode {
+ const n = Math.max(1, Math.min(3, Math.round(o.count)));
+ const S = Math.min(o.w, o.h);
+ const nodes: DisplayNode[] = Array.from({ length: n }, (_, i) => {
+ const depth = 0.3 + 0.7 * rng(o.seed, "bokeh-z", i);
+ const r = (0.05 + 0.07 * rng(o.seed, "bokeh-r", i)) * S;
+ const period = loopPeriod(12 + 8 * rng(o.seed, "bokeh-p", i), o.duration);
+ const cx = rng(o.seed, "bokeh-x", i) * o.w + Math.sin((2 * Math.PI * o.t) / period + i) * 0.03 * o.w * depth;
+ const cy = rng(o.seed, "bokeh-y", i) * o.h + Math.cos((2 * Math.PI * o.t) / period + i) * 0.02 * o.h * depth;
+ const c = o.colors[i % o.colors.length];
+ const a = 0.05 + 0.05 * rng(o.seed, "bokeh-a", i);
+ return { type: "ellipse", cx, cy, rx: r, ry: r, fill: { kind: "radial", cx, cy, r0: 0, r1: r, stops: [{ at: 0, color: rgba(c, a * 0.45) }, { at: 0.72, color: rgba(c, a * 0.75) }, { at: 0.9, color: rgba(c, a) }, { at: 1, color: rgba(c, 0) }] } };
+ });
+ return group(nodes, { id: "bokeh", blend: "screen" });
+}
+
+/** Light leaks round a cut: 2–3 warm pools sliding in from an edge (p 0–1 over 400–800 ms). */
+export function lightLeak(o: { w: number; h: number; from: "left" | "right" | "top"; p: number; seed: number; warm?: readonly string[] }): GroupNode | null {
+ if (o.p <= 0 || o.p >= 1) return null;
+ const warm = o.warm ?? ["#ffb46b", "#ff8a5c", "#ff5fa2"];
+ const env = Math.sin(Math.PI * o.p);
+ const k = CURVES.move(o.p);
+ const W = Math.max(o.w, o.h);
+ const nodes: DisplayNode[] = warm.slice(0, 3).map((c, i) => {
+ const along = 0.2 + 0.6 * rng(o.seed, "leak", i);
+ const reach = (-0.2 + 0.7 * k) * (o.from === "top" ? o.h : o.w);
+ const cx = o.from === "left" ? reach : o.from === "right" ? o.w - reach : along * o.w;
+ const cy = o.from === "top" ? reach : along * o.h;
+ return { type: "rect", x: 0, y: 0, w: o.w, h: o.h, fill: pool(cx, cy, W * (0.35 + 0.2 * i), c, (0.15 + 0.2 * rng(o.seed, "leak-a", i)) * env) };
+ });
+ return group(nodes, { id: "leak", blend: "screen" });
+}
diff --git a/src/lib/motion/fx/depth.ts b/src/lib/motion/fx/depth.ts
new file mode 100644
index 00000000..458d493f
--- /dev/null
+++ b/src/lib/motion/fx/depth.ts
@@ -0,0 +1,135 @@
+/**
+ * Depth (pure): shadows that sit things on the ground, glows, solid extrusions and offset copies. Every blur comes
+ * from the drawer's own cached blur (`soften` on a cached group), so a shadow costs one bitmap draw a frame, and the
+ * same shadow looks the same in every browser. Shadows are tinted toward the ground's hue, never pure black.
+ */
+
+import { group, type Box, type DisplayNode, type GroupNode, type Matrix, type TextNode } from "../display";
+import { mixOk, withLightness, toLab } from "../color";
+import { rgba } from "./background";
+
+/** A shadow colour for a ground: its hue, very dark. */
+export const shadowTint = (ground: string): string => withLightness(mixOk(ground, "#000000", 0.6), Math.min(0.18, toLab(ground).L * 0.25));
+
+/** A copy of a silhouette in one colour (text runs recoloured; shapes refilled), for shadows and glows. */
+export function silhouette(nodes: readonly DisplayNode[], color: string): DisplayNode[] {
+ return nodes.map((n): DisplayNode => {
+ switch (n.type) {
+ case "text":
+ return { ...n, decor: true, runs: n.runs.map((r) => ({ ...r, fill: color, ...(r.stroke && { stroke: { ...r.stroke, paint: color } }) })) };
+ case "rect":
+ case "ellipse":
+ case "path":
+ return { ...n, fill: color, ...(n.stroke && { stroke: { ...n.stroke, paint: color } }) };
+ case "image":
+ return { ...n, decor: true };
+ case "group":
+ return { ...n, children: silhouette(n.children, color) };
+ default:
+ return n;
+ }
+ });
+}
+
+export interface ShadowOptions {
+ /** What casts it (drawn as a silhouette). */
+ nodes: readonly DisplayNode[];
+ /** The caster's size (its height, or its cap height for type): blur and offset scale with it. */
+ size: number;
+ ground: string;
+ /** Everything the caster draws, in its own units. */
+ bounds: Box;
+ /** Stable for as long as the caster looks the same. */
+ key: string;
+ /** 0–1 (fades with the caster). */
+ opacity?: number;
+}
+
+/**
+ * The two-shadow rule: a tight contact shadow (blur ~0.75 % of the size, 1 % down, 30 %) under a wide ambient one
+ * (blur ~8 %, 3.5 % down, 14 %), both tinted toward the ground.
+ */
+export function twoShadow(o: ShadowOptions): GroupNode[] {
+ const tint = shadowTint(o.ground);
+ const shape = silhouette(o.nodes, tint);
+ const k = o.opacity ?? 1;
+ const pad = (blur: number, dy: number): Box => ({ x: o.bounds.x - blur * 2.5, y: o.bounds.y - blur * 2.5, w: o.bounds.w + blur * 5, h: o.bounds.h + blur * 5 + dy });
+ const ambientBlur = o.size * 0.08;
+ const contactBlur = Math.max(0.6, o.size * 0.0075);
+ return [
+ group([group(shape, { soften: ambientBlur, cache: { key: `ambient|${o.key}|${ambientBlur.toFixed(1)}`, bounds: pad(ambientBlur, 0) } })], { transform: [1, 0, 0, 1, 0, o.size * 0.035], opacity: 0.14 * k }),
+ group([group(shape, { soften: contactBlur, cache: { key: `contact|${o.key}|${contactBlur.toFixed(1)}`, bounds: pad(contactBlur, 0) } })], { transform: [1, 0, 0, 1, 0, o.size * 0.01], opacity: 0.3 * k }),
+ ];
+}
+
+/** A lift: the ambient shadow only, straight under, at 25 %. */
+export function lift(o: ShadowOptions): GroupNode {
+ const blur = o.size * 0.08;
+ return group([group(silhouette(o.nodes, shadowTint(o.ground)), { soften: blur, cache: { key: `lift|${o.key}|${blur.toFixed(1)}`, bounds: { x: o.bounds.x - blur * 2.5, y: o.bounds.y - blur * 2.5, w: o.bounds.w + blur * 5, h: o.bounds.h + blur * 5 } } })], { opacity: 0.25 * (o.opacity ?? 1) });
+}
+
+/** A glow behind: a cached blurred copy (3–6 % of the cap height) added as light (dark grounds only). */
+export function glowBehind(o: { nodes: readonly DisplayNode[]; color: string; blur: number; alpha?: number; bounds: Box; key: string }): GroupNode {
+ const pad = o.blur * 2.5;
+ return group(silhouette(o.nodes, o.color), { soften: o.blur, blend: "lighter", opacity: o.alpha ?? 0.45, cache: { key: `glow|${o.key}|${o.color}|${o.blur.toFixed(1)}`, bounds: { x: o.bounds.x - pad, y: o.bounds.y - pad, w: o.bounds.w + 2 * pad, h: o.bounds.h + 2 * pad } } });
+}
+
+export interface ExtrudeOptions {
+ /** The face (a text node, drawn on top by the caller). */
+ face: TextNode;
+ /** The face's colour: the sides step from 70 % to 35 % of its brightness, darkest at the back. */
+ color: string;
+ /** Copies (10–24) and the step between them (1–1.5 units). */
+ depth: number;
+ step?: number;
+ /** Down-right angle in degrees (30–45). */
+ angle?: number;
+ /** 0–1: the depth grows as the word lands. */
+ p?: number;
+ /** Cache key for the finished block (when p reaches 1). */
+ key: string;
+ bounds: Box;
+}
+
+/** A solid 2D extrusion behind type: stepped copies down and to the right, darker toward the back. */
+export function extrude(o: ExtrudeOptions): GroupNode {
+ const n = Math.max(1, Math.round(o.depth * Math.min(1, Math.max(0, o.p ?? 1))));
+ const step = o.step ?? 1.25;
+ const a = ((o.angle ?? 38) * Math.PI) / 180;
+ const L = toLab(o.color).L;
+ const copies: DisplayNode[] = [];
+ for (let i = n; i >= 1; i--) {
+ const k = i / Math.max(1, o.depth);
+ const shade = withLightness(o.color, L * (0.7 - 0.35 * k));
+ const m: Matrix = [1, 0, 0, 1, Math.cos(a) * step * i, Math.sin(a) * step * i];
+ copies.push(group(silhouette([o.face], shade), { transform: m }));
+ }
+ const reach = o.depth * step;
+ const done = (o.p ?? 1) >= 1;
+ return group(copies, { id: "extrude", ...(done && { cache: { key: `extrude|${o.key}|${o.color}|${o.depth}|${step}|${o.angle ?? 38}`, bounds: { x: o.bounds.x, y: o.bounds.y, w: o.bounds.w + reach + 2, h: o.bounds.h + reach + 2 } } }) });
+}
+
+/** A hard shadow: one solid offset copy (4–8 % of the size, down-right) in a second colour. */
+export function hardShadow(face: TextNode, size: number, color: string, share = 0.06): GroupNode {
+ return group(silhouette([face], color), { transform: [1, 0, 0, 1, size * share, size * share] });
+}
+
+/** An echo stack: 3–5 copies stepping back in opacity (1, 0.5, 0.25, 0.12…) along an offset. */
+export function echoStack(face: TextNode, o: { count: number; dx: number; dy: number; color?: string }): GroupNode[] {
+ const n = Math.max(1, Math.min(5, Math.round(o.count)));
+ const alphas = [0.5, 0.25, 0.12, 0.06, 0.03];
+ return Array.from({ length: n }, (_, i) => {
+ const k = n - i;
+ const copy: TextNode = { ...face, decor: true, ...(o.color && { runs: face.runs.map((r) => ({ ...r, fill: o.color! })) }) };
+ return group([copy], { transform: [1, 0, 0, 1, o.dx * k, o.dy * k], opacity: alphas[k - 1] });
+ });
+}
+
+/** A soft contact shadow under an object resting on a floor (an ellipse, blurred once and cached). */
+export function floorShadow(o: { cx: number; y: number; width: number; ground: string; strength?: number; key: string }): GroupNode {
+ const rx = o.width * 0.42;
+ const ry = Math.max(2, o.width * 0.045);
+ const blur = Math.max(2, o.width * 0.035);
+ const pad = blur * 3;
+ return group([{ type: "ellipse", cx: o.cx, cy: o.y, rx, ry, fill: rgba(shadowTint(o.ground), 1) }], { soften: blur, opacity: o.strength ?? 0.4, cache: { key: `floor|${o.key}|${rx.toFixed(0)}|${o.ground}`, bounds: { x: o.cx - rx - pad, y: o.y - ry - pad, w: 2 * (rx + pad), h: 2 * (ry + pad) } } });
+}
diff --git a/src/lib/motion/fx/finish.ts b/src/lib/motion/fx/finish.ts
new file mode 100644
index 00000000..6a504aed
--- /dev/null
+++ b/src/lib/motion/fx/finish.ts
@@ -0,0 +1,66 @@
+/**
+ * Finish (pure): film grain, a vignette and a flash. Grain is seeded noise: a few 256 × 256 tiles made once per
+ * seed, the tile and its offset changing every second frame (on twos), so it reads as film, the same frame always gets
+ * the same grain, and gradients don't band in the video. It is drawn under the readable type.
+ */
+
+import type { DisplayNode, GrainNode } from "../display";
+import { rng } from "../random";
+
+/** Tiles per seed. */
+export const GRAIN_TILES = 6;
+export const GRAIN_SIZE = 256;
+
+/**
+ * One grain tile: GRAIN_SIZE² grey values around 128 (a sum of three seeded uniforms, so it is soft-edged, not salt
+ * and pepper). Pure: the drawer turns it into a bitmap once.
+ */
+export function grainTile(seed: number, index: number, size = GRAIN_SIZE): Uint8ClampedArray {
+ const out = new Uint8ClampedArray(size * size);
+ // A fast seeded stream (xorshift) started from the order-free hash: the tile is the same whatever else was drawn.
+ let s = Math.floor(rng(seed, "grain-tile", index) * 0xffffffff) | 1;
+ const next = () => {
+ s ^= s << 13;
+ s ^= s >>> 17;
+ s ^= s << 5;
+ return (s >>> 0) / 4294967296;
+ };
+ for (let i = 0; i < out.length; i++) out[i] = Math.round(128 + ((next() + next() + next()) / 3 - 0.5) * 2 * 110);
+ return out;
+}
+
+/** Which tile and offset a frame uses (it changes every second frame). */
+export function grainPick(seed: number, frame: number): { tile: number; ox: number; oy: number } {
+ const step = Math.floor(Math.max(0, frame) / 2);
+ return { tile: step % GRAIN_TILES, ox: Math.floor(rng(seed, "grain-ox", step) * GRAIN_SIZE), oy: Math.floor(rng(seed, "grain-oy", step) * GRAIN_SIZE) };
+}
+
+/** Grain over the frame: overlay at 4–6 % on light grounds, screen at 3–5 % on dark ones; grains 1.25 units at 1080. */
+export function grain(o: { w: number; h: number; seed: number; frame: number; dark: boolean; amount?: number; size?: number }): GrainNode {
+ return { type: "grain", seed: o.seed, frame: o.frame, amount: o.amount ?? (o.dark ? 0.04 : 0.05), size: o.size ?? 1.25, blend: o.dark ? "screen" : "overlay", x: 0, y: 0, w: o.w, h: o.h };
+}
+
+/** A vignette: corners 10–20 % darker, toward the ground's own dark. */
+export function vignette(o: { w: number; h: number; strength?: number; color?: string }): DisplayNode {
+ const c = o.color ?? "#000000";
+ const hex = c.replace("#", "");
+ const [r, g, b] = [0, 2, 4].map((i) => parseInt(hex.slice(i, i + 2), 16));
+ const a = o.strength ?? 0.15;
+ return {
+ type: "rect",
+ x: 0,
+ y: 0,
+ w: o.w,
+ h: o.h,
+ fill: { kind: "radial", cx: o.w / 2, cy: o.h / 2, r0: Math.min(o.w, o.h) * 0.42, r1: Math.hypot(o.w, o.h) / 2, stops: [{ at: 0, color: `rgba(${r},${g},${b},0)` }, { at: 1, color: `rgba(${r},${g},${b},${a})` }] },
+ };
+}
+
+/** A white flash over the frame (a stomp's impact: 6 %, never more than three a second). */
+export const flash = (w: number, h: number, a: number): DisplayNode | null => (a > 0 ? { type: "rect", x: 0, y: 0, w, h, fill: `rgba(255,255,255,${Math.min(0.12, a)})` } : null);
+
+/**
+ * Motion-blur samples for an export frame from how far its fastest edge moves in a frame (pixels): none at rest,
+ * up to 16 at speed.
+ */
+export const blurSamples = (maxDisplacementPx: number): number => (maxDisplacementPx <= 0.5 ? 1 : Math.min(16, Math.max(1, Math.ceil(maxDisplacementPx / 2))));
diff --git a/src/lib/motion/fx/materials.ts b/src/lib/motion/fx/materials.ts
new file mode 100644
index 00000000..a76c1b7f
--- /dev/null
+++ b/src/lib/motion/fx/materials.ts
@@ -0,0 +1,75 @@
+/**
+ * Type materials (pure): paints and outlines for type at rest (any animation plays over them). Solid is the default;
+ * the others are for one hero word or number, never body copy.
+ */
+
+import type { Box, Gradient, Paint } from "../display";
+import { okStops, analogous } from "../color";
+import { rgba } from "./background";
+
+/** Hollow type: an outline 1.5–3 % of the size, no fill (ghost copies use 1–2.5 units at 25–40 %). */
+export function hollow(size: number, color: string, share = 0.022): { fill: Paint; stroke: { paint: Paint; width: number } } {
+ return { fill: "transparent", stroke: { paint: color, width: Math.max(1, size * share) } };
+}
+
+/**
+ * A gradient across a line box (2–3 analogous colours, 100–135°), sampled in OKLab. It drifts along its axis by ±8 %
+ * over `period` seconds, so it moves slowly without ever changing its colours. Falls back to two stops when the
+ * colours are far apart in hue (no rainbow on type).
+ */
+export function gradientInk(box: Box, colors: readonly string[], o: { angle?: number; t?: number; period?: number } = {}): Gradient {
+ const a = ((o.angle ?? 115) * Math.PI) / 180;
+ const cx = box.x + box.w / 2;
+ const cy = box.y + box.h / 2;
+ const half = (Math.abs(Math.cos(a)) * box.w + Math.abs(Math.sin(a)) * box.h) / 2;
+ const drift = o.period ? Math.sin((2 * Math.PI * (o.t ?? 0)) / o.period) * 0.08 * half * 2 : 0;
+ const dx = Math.cos(a) * half;
+ const dy = Math.sin(a) * half;
+ const cols = colors.length >= 3 && analogous(colors[0], colors[2], 60) ? colors.slice(0, 3) : colors.slice(0, 2);
+ const stops = cols.length === 3 ? [...okStops(cols[0], cols[1], 3, 0, 0.5), ...okStops(cols[1], cols[2], 3, 0.5, 1).slice(1)] : okStops(cols[0], cols[1] ?? cols[0], 5);
+ return { kind: "linear", x0: cx - dx + Math.cos(a) * drift, y0: cy - dy + Math.sin(a) * drift, x1: cx + dx + Math.cos(a) * drift, y1: cy + dy + Math.sin(a) * drift, stops };
+}
+
+/** Chrome's stops across the cap height: bright sky, a hard dark horizon, a bright ground. */
+export const CHROME_STOPS: readonly { at: number; color: string }[] = [
+ { at: 0, color: "#f5f7fa" },
+ { at: 0.46, color: "#a3acb6" },
+ { at: 0.5, color: "#3a4149" },
+ { at: 0.54, color: "#dfe4e9" },
+ { at: 1, color: "#79828c" },
+];
+
+/**
+ * Chrome type: the horizon gradient across the cap band (top to bottom of the capitals), shifted by `flow` (a share
+ * of the cap height, from the chrome-flow loop), with a lighter outline. Dark or saturated grounds only.
+ */
+export function chromeInk(capTop: number, capBottom: number, size: number, flow = 0): { fill: Gradient; stroke: { paint: Paint; width: number } } {
+ const h = capBottom - capTop;
+ const shift = flow * h;
+ return {
+ fill: { kind: "linear", x0: 0, y0: capTop + shift, x1: 0, y1: capBottom + shift, stops: CHROME_STOPS.map((s) => ({ ...s })) },
+ stroke: { paint: "rgba(255,255,255,0.4)", width: Math.max(1, size * 0.012) },
+ };
+}
+
+/** Glass type: a faint white fill with a top-bright outline. */
+export function glassInk(capTop: number, capBottom: number, size: number): { fill: Paint; stroke: { paint: Paint; width: number } } {
+ return {
+ fill: "rgba(255,255,255,0.2)",
+ stroke: { paint: { kind: "linear", x0: 0, y0: capTop, x1: 0, y1: capBottom, stops: [{ at: 0, color: "rgba(255,255,255,0.95)" }, { at: 1, color: "rgba(255,255,255,0.25)" }] }, width: Math.max(1, size * 0.01) },
+ };
+}
+
+/** Neon: a near-white core and its glow colour (the neon-strike preset draws the halos). */
+export const neonInk = (glow: string): { fill: string; glow: string } => ({ fill: "#fffaf0", glow });
+
+/** A pill round a text box: padding 0.35 em × 0.6 em, fully rounded. */
+export function pillBox(text: Box, size: number): Box & { r: number } {
+ const px = 0.6 * size;
+ const py = 0.35 * size;
+ const b = { x: text.x - px, y: text.y - py, w: text.w + 2 * px, h: text.h + 2 * py };
+ return { ...b, r: b.h / 2 };
+}
+
+/** A colour faded (hex in). */
+export const fade = (hex: string, a: number): string => rgba(hex, a);
diff --git a/src/lib/motion/fx/overlays.ts b/src/lib/motion/fx/overlays.ts
new file mode 100644
index 00000000..79b00d50
--- /dev/null
+++ b/src/lib/motion/fx/overlays.ts
@@ -0,0 +1,180 @@
+/**
+ * Overlays and graphic texture (pure): the pieces that lock into the type on purpose (a tilted pill, a highlighter
+ * under a word, a sticker's keyline) and the texture around it (halftone, organic blobs, rules and arrows, Bauhaus
+ * shapes, doodles). Every jitter is seeded; draw-ons take a progress 0–1.
+ */
+
+import { group, multiply, type Box, type DisplayNode, type GroupNode, type Matrix, type Paint } from "../display";
+import { rng } from "../random";
+import { clamp } from "../time";
+import { CURVES } from "../ease";
+
+const DEG = Math.PI / 180;
+
+/** A rotation by `deg` about (cx, cy). */
+export function rotation(deg: number, cx: number, cy: number): Matrix {
+ const a = deg * DEG;
+ const c = Math.cos(a);
+ const s = Math.sin(a);
+ return [c, s, -s, c, cx - c * cx + s * cy, cy - s * cx - c * cy];
+}
+
+/** A tilted pill (tag) behind its own content: rotated −4° to −8° about its centre; `p` pops it in (0–1, curve pop). */
+export function pillTag(box: Box & { r?: number }, fill: Paint, content: readonly DisplayNode[], o: { deg?: number; p?: number; stroke?: { paint: Paint; width: number } } = {}): GroupNode {
+ const p = o.p ?? 1;
+ const s = p >= 1 ? 1 : CURVES.pop(clamp(p));
+ const cx = box.x + box.w / 2;
+ const cy = box.y + box.h / 2;
+ const rot = rotation(o.deg ?? -6, cx, cy);
+ const scale: Matrix = [s, 0, 0, s, cx - s * cx, cy - s * cy];
+ return group([{ type: "rect", x: box.x, y: box.y, w: box.w, h: box.h, r: box.r ?? box.h / 2, fill, ...(o.stroke && { stroke: o.stroke }) }, ...content], {
+ id: "pill",
+ transform: multiply(rot, scale),
+ ...(p < 0.15 && { opacity: p / 0.15 }),
+ });
+}
+
+/**
+ * A highlighter bar under a word: covering the lower 45–60 % of its cap band, skewed −2° to −4°, its edges jittered
+ * by 0.3–0.6 % of its height (seeded); `p` grows it from the left (0–1).
+ */
+export function highlighter(o: { capTop: number; baseline: number; x: number; w: number; color: Paint; seed: number; p?: number; cover?: number; skew?: number; key?: string }): DisplayNode | null {
+ const p = clamp(o.p ?? 1);
+ if (p <= 0) return null;
+ const cap = o.baseline - o.capTop;
+ const h = cap * (o.cover ?? 0.52);
+ const y = o.baseline - h + cap * 0.06;
+ const pad = cap * 0.12;
+ const x0 = o.x - pad;
+ const x1 = x0 + (o.w + 2 * pad) * CURVES.snap(p);
+ const j = (k: string, i: number) => (rng(o.seed, "hl", o.key ?? "", k, i) * 2 - 1) * h * 0.005 * 0.9 + (rng(o.seed, "hl2", k, i) - 0.5) * h * 0.004;
+ const sk = Math.tan((o.skew ?? -3) * DEG);
+ const steps = 6;
+ const top: string[] = [];
+ const bottom: string[] = [];
+ // The skew leans the bar about its middle, so it overhangs the word by the same amount on both sides.
+ for (let i = 0; i <= steps; i++) {
+ const x = x0 + ((x1 - x0) * i) / steps;
+ top.push(`${(x + (sk * h) / 2).toFixed(1)} ${(y + j("t", i)).toFixed(1)}`);
+ bottom.unshift(`${(x - (sk * h) / 2).toFixed(1)} ${(y + h + j("b", i)).toFixed(1)}`);
+ }
+ return { type: "path", d: `M${top.join("L")}L${bottom.join("L")}Z`, fill: o.color };
+}
+
+/**
+ * A halftone field (drawn once, cached): dots on a staggered grid rotated 15° or 45°, each radius rmax × √coverage,
+ * the coverage fading from `origin` out to `reach`.
+ */
+export function halftone(o: { box: Box; spacing: number; angle?: number; origin: [number, number]; reach: number; color: Paint; alpha?: number; key: string }): GroupNode {
+ const a = (o.angle ?? 45) * DEG;
+ const c = Math.cos(a);
+ const s = Math.sin(a);
+ const rmax = o.spacing * 0.5;
+ const parts: string[] = [];
+ const diag = Math.hypot(o.box.w, o.box.h);
+ const cx = o.box.x + o.box.w / 2;
+ const cy = o.box.y + o.box.h / 2;
+ const n = Math.ceil(diag / o.spacing / 2) + 1;
+ for (let i = -n; i <= n; i++) {
+ for (let k = -n; k <= n; k++) {
+ const gx = (k + (i % 2 ? 0.5 : 0)) * o.spacing;
+ const gy = i * o.spacing * 0.866;
+ const x = cx + gx * c - gy * s;
+ const y = cy + gx * s + gy * c;
+ if (x < o.box.x - rmax || x > o.box.x + o.box.w + rmax || y < o.box.y - rmax || y > o.box.y + o.box.h + rmax) continue;
+ // Coverage fades from the origin out to its reach, and to nothing before the box's edges (never a clipped edge).
+ const edge = clamp(Math.min(x - o.box.x, o.box.x + o.box.w - x, y - o.box.y, o.box.y + o.box.h - y) / (0.3 * Math.min(o.box.w, o.box.h)));
+ const cover = clamp(1 - Math.hypot(x - o.origin[0], y - o.origin[1]) / o.reach) * edge;
+ const r = rmax * Math.sqrt(cover);
+ if (r < 0.35) continue;
+ parts.push(`M${(x + r).toFixed(1)} ${y.toFixed(1)}a${r.toFixed(2)} ${r.toFixed(2)} 0 1 0 ${(-2 * r).toFixed(2)} 0a${r.toFixed(2)} ${r.toFixed(2)} 0 1 0 ${(2 * r).toFixed(2)} 0`);
+ }
+ }
+ return group([{ type: "path", d: parts.join(""), fill: o.color }], { id: "halftone", opacity: o.alpha ?? 0.22, clip: { type: "rect", ...o.box }, cache: { key: `halftone|${o.key}`, bounds: o.box } });
+}
+
+/** An organic blob: a smooth closed curve through 6–8 seeded points whose radii breathe on slow sines. */
+export function blob(o: { cx: number; cy: number; r: number; seed: number; t: number; points?: number; wobble?: number; period?: number; fill: Paint }): DisplayNode {
+ const n = Math.max(5, Math.min(10, o.points ?? 7));
+ const pts: [number, number][] = [];
+ for (let i = 0; i < n; i++) {
+ const ang = (i / n) * Math.PI * 2 + rng(o.seed, "blob-a", i) * 0.4;
+ const period = o.period ?? 6;
+ const breathe = Math.sin((2 * Math.PI * o.t) / period + rng(o.seed, "blob-p", i) * Math.PI * 2);
+ const rr = o.r * (1 + (rng(o.seed, "blob-r", i) * 2 - 1) * 0.18 + breathe * (o.wobble ?? 0.06));
+ pts.push([o.cx + Math.cos(ang) * rr, o.cy + Math.sin(ang) * rr]);
+ }
+ return { type: "path", d: smoothClosed(pts), fill: o.fill };
+}
+
+/** A closed Catmull-Rom curve through points, as cubic Béziers. */
+export function smoothClosed(pts: readonly [number, number][]): string {
+ const n = pts.length;
+ const p = (i: number) => pts[((i % n) + n) % n];
+ let d = `M${p(0)[0].toFixed(1)} ${p(0)[1].toFixed(1)}`;
+ for (let i = 0; i < n; i++) {
+ const [x0, y0] = p(i - 1);
+ const [x1, y1] = p(i);
+ const [x2, y2] = p(i + 1);
+ const [x3, y3] = p(i + 2);
+ d += `C${(x1 + (x2 - x0) / 6).toFixed(1)} ${(y1 + (y2 - y0) / 6).toFixed(1)} ${(x2 - (x3 - x1) / 6).toFixed(1)} ${(y2 - (y3 - y1) / 6).toFixed(1)} ${x2.toFixed(1)} ${y2.toFixed(1)}`;
+ }
+ return `${d}Z`;
+}
+
+/** A thin rule that draws on from its left end (`p` 0–1, curve draw). */
+export function rule(o: { x: number; y: number; w: number; width?: number; color: Paint; p?: number }): DisplayNode {
+ return { type: "path", d: `M${o.x} ${o.y}H${o.x + o.w}`, stroke: { paint: o.color, width: o.width ?? 1.25, trim: CURVES.draw(clamp(o.p ?? 1)), length: o.w } };
+}
+
+/** A small ↗ arrow (stroked), drawn on with `p`. */
+export function arrow(o: { x: number; y: number; size: number; width?: number; color: Paint; p?: number }): DisplayNode {
+ const s = o.size;
+ const len = Math.SQRT2 * s + 2 * s * 0.6;
+ return { type: "path", d: `M${o.x} ${o.y + s}L${o.x + s} ${o.y}M${o.x + s * 0.4} ${o.y}H${o.x + s}V${o.y + s * 0.6}`, stroke: { paint: o.color, width: o.width ?? Math.max(1.25, s * 0.09), cap: "round", join: "round", trim: CURVES.draw(clamp(o.p ?? 1)), length: len } };
+}
+
+/** A sticker's keyline: a wide white outline behind the sticker's own nodes (text runs get a stroke copy). */
+export function keyline(nodes: readonly DisplayNode[], width: number, color = "#ffffff"): DisplayNode[] {
+ return nodes.map((n): DisplayNode => {
+ switch (n.type) {
+ case "text":
+ return { ...n, decor: true, runs: n.runs.map((r) => ({ ...r, fill: color, stroke: { paint: color, width: width * 2 } })) };
+ case "rect":
+ case "ellipse":
+ case "path":
+ return { ...n, fill: color, stroke: { paint: color, width: width * 2, join: "round" } };
+ case "group":
+ return { ...n, children: keyline(n.children, width, color) };
+ default:
+ return n;
+ }
+ });
+}
+
+/** Bauhaus accents on the grid: a disc, a quarter disc and a thin rule in one colour. */
+export function bauhaus(o: { x: number; y: number; size: number; color: Paint; seed: number }): GroupNode {
+ const s = o.size;
+ const flip = rng(o.seed, "bauhaus") < 0.5;
+ return group(
+ [
+ { type: "ellipse", cx: o.x + s * 0.5, cy: o.y + s * 0.5, rx: s * 0.5, ry: s * 0.5, fill: o.color },
+ { type: "path", d: flip ? `M${o.x + s * 1.2} ${o.y + s}A${s} ${s} 0 0 1 ${o.x + s * 2.2} ${o.y}V${o.y + s}Z` : `M${o.x + s * 1.2} ${o.y}A${s} ${s} 0 0 0 ${o.x + s * 2.2} ${o.y + s}H${o.x + s * 1.2}Z`, fill: o.color },
+ { type: "rect", x: o.x, y: o.y + s * 1.3, w: s * 2.2, h: Math.max(1, s * 0.03), fill: o.color },
+ ],
+ { id: "bauhaus" },
+ );
+}
+
+/** A hand-drawn squiggle under a word (playful looks), drawn on with `p`. */
+export function squiggle(o: { x: number; y: number; w: number; amp: number; seed: number; color: Paint; width?: number; p?: number }): DisplayNode {
+ const waves = Math.max(2, Math.round(o.w / (o.amp * 3)));
+ const step = o.w / waves;
+ let d = `M${o.x.toFixed(1)} ${o.y.toFixed(1)}`;
+ for (let i = 0; i < waves; i++) {
+ const x = o.x + step * (i + 0.5);
+ const up = (i % 2 ? 1 : -1) * o.amp * (0.8 + 0.4 * rng(o.seed, "squiggle", i));
+ d += `Q${x.toFixed(1)} ${(o.y + up).toFixed(1)} ${(o.x + step * (i + 1)).toFixed(1)} ${o.y.toFixed(1)}`;
+ }
+ return { type: "path", d, stroke: { paint: o.color, width: o.width ?? Math.max(2, o.amp * 0.35), cap: "round", join: "round", trim: CURVES.draw(clamp(o.p ?? 1)), length: o.w * 1.25 } };
+}
diff --git a/src/lib/motion/fx/photo.ts b/src/lib/motion/fx/photo.ts
new file mode 100644
index 00000000..1c39748f
--- /dev/null
+++ b/src/lib/motion/fx/photo.ts
@@ -0,0 +1,118 @@
+/**
+ * Photography and products (pure). A photo is never still: it pushes in slowly (1.00 → 1.04–1.08) or pans 2–4 % over
+ * the clip. It can be graded into the palette (a duotone: the dark tone multiplied into the shadows, the light tone
+ * screened into the highlights), shown inside the letters of one short heavy word, or set as a tilted card. A product
+ * cut-out stands on a soft floor light with its contact shadow, and a light band crosses it once after it settles.
+ */
+
+import { group, type Box, type DisplayNode, type GroupNode, type ImageNode, type Matrix, type TextNode } from "../display";
+import { CURVES, sine } from "../ease";
+import { clamp } from "../time";
+import { floorShadow, twoShadow } from "./depth";
+import { pool, rgba } from "./background";
+import { rotation } from "./overlays";
+
+/** The part of a picture (shares 0–1) that fills a box without distortion, centred on `focus`, zoomed by `zoom`. */
+export function coverCrop(img: { w: number; h: number }, box: { w: number; h: number }, focus: { x: number; y: number } = { x: 0.5, y: 0.45 }, zoom = 1): Box {
+ const scale = Math.max(box.w / img.w, box.h / img.h) * Math.max(1, zoom);
+ const sw = Math.min(1, box.w / scale / img.w);
+ const sh = Math.min(1, box.h / scale / img.h);
+ const x = clamp(focus.x - sw / 2, 0, 1 - sw);
+ const y = clamp(focus.y - sh / 2, 0, 1 - sh);
+ return { x, y, w: sw, h: sh };
+}
+
+/** A push-in's zoom and pan at `t` of `duration` (sine in-out, at rest on the last frame). */
+export function pushIn(t: number, duration: number, o: { from?: number; to?: number; pan?: { x: number; y: number } } = {}): { zoom: number; pan: { x: number; y: number } } {
+ const k = sine.inOut(clamp(duration > 0 ? t / duration : 1));
+ const from = o.from ?? 1;
+ const to = o.to ?? 1.06;
+ return { zoom: from + (to - from) * k, pan: { x: (o.pan?.x ?? 0) * k, y: (o.pan?.y ?? 0) * k } };
+}
+
+export interface PhotoOptions {
+ /** The source's key ("photo", "product"). */
+ src: string;
+ img: { w: number; h: number };
+ box: Box;
+ t: number;
+ duration: number;
+ /** Push-in range (default 1 → 1.06) and a pan in shares of the picture. */
+ push?: { from?: number; to?: number; pan?: { x: number; y: number } };
+ focus?: { x: number; y: number };
+ /** Rounded corners. */
+ radius?: number;
+ /** Laid to the frame's edge (see ImageNode.bleed). */
+ bleed?: boolean;
+ /** A duotone grade into the palette: shadows toward `dark`, highlights toward `light`. */
+ grade?: { dark: string; light: string; darkAlpha?: number; lightAlpha?: number };
+}
+
+/** A photo filling a box: cropped to cover, pushing in, optionally graded, clipped to the box. */
+export function photo(o: PhotoOptions): GroupNode {
+ const { zoom, pan } = pushIn(o.t, o.duration, o.push);
+ const focus = o.focus ?? { x: 0.5, y: 0.45 };
+ const crop = coverCrop(o.img, o.box, { x: focus.x + pan.x, y: focus.y + pan.y }, zoom);
+ const image: ImageNode = { type: "image", src: o.src, x: o.box.x, y: o.box.y, w: o.box.w, h: o.box.h, crop, ...(o.bleed && { bleed: true }) };
+ const children: DisplayNode[] = [image, ...(o.grade ? duotone(o.box, o.grade) : [])];
+ return group(children, { id: `photo-${o.src}`, clip: { type: "rect", ...o.box, ...(o.radius && { r: o.radius }) }, ...(o.grade && { isolate: o.box }) });
+}
+
+/** A duotone grade over a box: the dark tone multiplied in, the light tone screened in. */
+export function duotone(box: Box, g: { dark: string; light: string; darkAlpha?: number; lightAlpha?: number }): DisplayNode[] {
+ return [
+ group([{ type: "rect", ...box, fill: rgba(g.dark, g.darkAlpha ?? 0.55) }], { blend: "multiply" }),
+ group([{ type: "rect", ...box, fill: rgba(g.light, g.lightAlpha ?? 0.3) }], { blend: "screen" }),
+ ];
+}
+
+/** A photo seen through the letters of a word (one or two short, heavy words only); the photo pushes 1.08 → 1 inside them. */
+export function photoInType(word: TextNode, o: Omit<PhotoOptions, "push"> & { bounds: Box }): GroupNode {
+ const pic = photo({ ...o, push: { from: 1.08, to: 1 } });
+ return group([pic, group([word], { blend: "destination-in" })], { id: "photo-in-type", isolate: o.bounds });
+}
+
+/** A tilted photo card: ±3–6°, a 6–10 unit white border, the two shadows under it. */
+export function tiltedCard(o: PhotoOptions & { deg: number; border?: number; ground: string; key: string; paper?: string }): GroupNode {
+ const b = o.border ?? 8;
+ const frame = { x: o.box.x - b, y: o.box.y - b, w: o.box.w + 2 * b, h: o.box.h + 2 * b };
+ const card: DisplayNode = { type: "rect", ...frame, r: 2, fill: o.paper ?? "#fbfaf7" };
+ const rot: Matrix = rotation(o.deg, frame.x + frame.w / 2, frame.y + frame.h / 2);
+ return group([...twoShadow({ nodes: [card], size: frame.h, ground: o.ground, bounds: frame, key: `card|${o.key}` }), card, photo(o)], { id: "card", transform: rot });
+}
+
+export interface ProductOptions {
+ src: string;
+ /** Where the cut-out is drawn (its fitted box). */
+ box: Box;
+ ground: string;
+ t: number;
+ /** When the sweep crosses (seconds; none when absent) and how long it takes (0.7–0.9 s). */
+ sweepAt?: number;
+ sweepDur?: number;
+ /** A soft pool of floor light under it. */
+ floorLight?: string;
+ key: string;
+ opacity?: number;
+}
+
+/** A product cut-out on its floor: light pool, contact shadow, the picture, and one light band across it after it lands. */
+export function product(o: ProductOptions): GroupNode {
+ const b = o.box;
+ const foot = b.y + b.h;
+ const nodes: DisplayNode[] = [];
+ if (o.floorLight) nodes.push({ type: "ellipse", cx: b.x + b.w / 2, cy: foot, rx: b.w * 0.9, ry: b.w * 0.22, fill: pool(b.x + b.w / 2, foot, b.w * 0.9, o.floorLight, 0.35) });
+ nodes.push(floorShadow({ cx: b.x + b.w / 2, y: foot - b.h * 0.005, width: b.w, ground: o.ground, key: o.key }));
+ const image: ImageNode = { type: "image", src: o.src, x: b.x, y: b.y, w: b.w, h: b.h };
+ const d = o.sweepDur ?? 0.8;
+ const p = o.sweepAt === undefined ? -1 : (o.t - o.sweepAt) / d;
+ if (p > 0 && p < 1) {
+ const k = CURVES.move(p);
+ const band = b.w * 0.35;
+ const x = b.x - band + k * (b.w + 2 * band);
+ const sweep: DisplayNode = { type: "rect", x: x - band / 2, y: b.y, w: band, h: b.h, fill: { kind: "linear", x0: x - band / 2, y0: 0, x1: x + band / 2, y1: 0, stops: [{ at: 0, color: "rgba(255,255,255,0)" }, { at: 0.5, color: "rgba(255,255,255,0.45)" }, { at: 1, color: "rgba(255,255,255,0)" }] } };
+ const tilt: Matrix = [1, 0, Math.tan((20 * Math.PI) / 180), 1, -Math.tan((20 * Math.PI) / 180) * (b.y + b.h / 2), 0];
+ nodes.push(group([image, group([sweep], { blend: "source-atop", transform: tilt })], { isolate: b }));
+ } else nodes.push(image);
+ return group(nodes, { id: `product-${o.key}`, ...(o.opacity !== undefined && o.opacity < 1 && { opacity: o.opacity }) });
+}
diff --git a/src/lib/motion/fx/stack.ts b/src/lib/motion/fx/stack.ts
new file mode 100644
index 00000000..7ad63c44
--- /dev/null
+++ b/src/lib/motion/fx/stack.ts
@@ -0,0 +1,78 @@
+/**
+ * The layer stack (pure): a frame is built bottom to top from named layers, each at its own depth, so a camera pan
+ * moves far layers less than near ones (2.5D parallax) and each layer settles in from its own scale, coming home on
+ * the last frame (so the rest frame is the layout as set).
+ *
+ * ground · atmosphere · ghost type · texture · subject · grain · hero type · overlays · details · light · finish
+ *
+ * A product may sit in front of the hero type (the magazine-cover sandwich): ground, ghost, hero, then the cut-out
+ * with its shadow falling on the type. Grain sits under the readable type. Details (corner facts) never move with the
+ * camera.
+ */
+
+import { group, multiply, type DisplayNode, type Matrix } from "../display";
+import { sine } from "../ease";
+import { clamp } from "../time";
+
+export type LayerRole = "ground" | "atmosphere" | "ghost" | "texture" | "subject" | "grain" | "hero" | "overlay" | "meta" | "light" | "finish";
+
+export const LAYER_ORDER: readonly LayerRole[] = ["ground", "atmosphere", "ghost", "texture", "subject", "grain", "hero", "overlay", "meta", "light", "finish"];
+
+/** Depth per role: a layer moves camera / z (z 1: the hero's plane; none: fixed to the frame). */
+export const LAYER_DEPTH: Record<LayerRole, number | null> = { ground: 4, atmosphere: 3, ghost: 2.5, texture: 2, subject: 1.2, grain: null, hero: 1, overlay: 1, meta: null, light: null, finish: null };
+
+/**
+ * How far each role settles in over the clip (1 + push → 1): the field and the ghost pull back while the hero plane
+ * (the type and its overlays) pushes in from 97.5 % to 100 %, so the holds keep moving and the last frame is the layout.
+ */
+export const LAYER_PUSH: Record<LayerRole, number> = { ground: 0.04, atmosphere: 0.05, ghost: 0.06, texture: 0, subject: 0.1, grain: 0, hero: -0.025, overlay: -0.025, meta: 0, light: 0, finish: 0 };
+
+export interface Layer {
+ role: LayerRole;
+ nodes: DisplayNode[];
+ /** Override the role's depth. */
+ z?: number;
+ /** Override the role's push-in. */
+ push?: number;
+}
+
+export interface StackOptions {
+ w: number;
+ h: number;
+ t: number;
+ duration: number;
+ /** The camera's pan at the hero's plane (design units). */
+ camera?: { x: number; y: number };
+ /** The subject goes over the hero type (the sandwich). */
+ sandwich?: boolean;
+ /** Push-in on (default) or off. */
+ push?: boolean;
+}
+
+/** A layer's transform: the pan divided by its depth, and its push-in about the frame's centre. */
+export function layerTransform(role: LayerRole, o: StackOptions, z?: number, push?: number): Matrix | undefined {
+ const depth = z ?? LAYER_DEPTH[role];
+ const amount = o.push === false ? 0 : (push ?? LAYER_PUSH[role]);
+ const k = sine.inOut(clamp(o.duration > 0 ? o.t / o.duration : 1));
+ const s = 1 + amount * (1 - k);
+ const dx = depth ? (o.camera?.x ?? 0) / depth : 0;
+ const dy = depth ? (o.camera?.y ?? 0) / depth : 0;
+ if (s === 1 && dx === 0 && dy === 0) return undefined;
+ const cx = o.w / 2;
+ const cy = o.h / 2;
+ return multiply([1, 0, 0, 1, dx, dy], [s, 0, 0, s, cx - s * cx, cy - s * cy]);
+}
+
+/** The frame's nodes from its layers, in order, each in its own group with its depth's transform. */
+export function stack(layers: readonly Layer[], o: StackOptions): DisplayNode[] {
+ const order = o.sandwich ? LAYER_ORDER.filter((r) => r !== "subject").flatMap((r) => (r === "hero" ? (["hero", "subject"] as LayerRole[]) : [r])) : LAYER_ORDER;
+ const out: DisplayNode[] = [];
+ for (const role of order) {
+ for (const l of layers) {
+ if (l.role !== role || !l.nodes.length) continue;
+ const m = layerTransform(role, o, l.z, l.push);
+ out.push(group(l.nodes, { id: `layer-${role}`, ...(m && { transform: m }) }));
+ }
+ }
+ return out;
+}
diff --git a/src/lib/motion/grid.ts b/src/lib/motion/grid.ts
new file mode 100644
index 00000000..c14cd3f8
--- /dev/null
+++ b/src/lib/motion/grid.ts
@@ -0,0 +1,127 @@
+/**
+ * Layout grid and safe areas (pure). Every Kinetic layout sits on one grid: a 7 % margin of the short side, 12 columns
+ * and a baseline unit of 1 %, with four corner slots on the margin's inset line for the small facts (brand, date,
+ * web address, index). Readable copy (words, prices, logos, brand names, calls to action) stays inside the safe area
+ * of where the piece is shown; only fields, shapes, photos and decorative ghost type may bleed.
+ */
+
+import type { Box } from "./display";
+import { TILE_CHIPS } from "./sizes";
+
+/** Where a piece is shown, which decides its safe area. */
+export type Placement = "ad" | "story" | "post" | "cover";
+
+/** What each placement keeps readable copy out of, as shares of the frame (top, right, bottom, left). */
+export const SAFE_INSETS: Record<Placement, { top: number; right: number; bottom: number; left: number }> = {
+ // Reels and TikTok ads: the app's caption and buttons cover the bottom 15 % (plus a 4 % pad) and a column on the right.
+ ad: { top: 0.14, right: 0.11, bottom: 0.19, left: 0.06 },
+ story: { top: 0.14, right: 0.06, bottom: 0.2, left: 0.06 },
+ // Posts (1:1, 4:5, 16:9): the grid's margin (set from the short side, below).
+ post: { top: 0, right: 0, bottom: 0, left: 0 },
+ // A gallery tile: its chips at the top and the bottom.
+ cover: { top: TILE_CHIPS.top, right: 0.06, bottom: TILE_CHIPS.bottom, left: 0.06 },
+};
+
+/** The grid's margin: 7 % of the short side. */
+export const MARGIN = 0.07;
+
+/** Sizes in design units by role, as shares of the short side (1080). */
+export const LADDER = {
+ hero: [0.14, 0.4],
+ sub: [0.036, 0.05],
+ body: [0.024, 0.03],
+ meta: [0.016, 0.022],
+} as const;
+
+/** Brand, offer or call to action on a cover: at least this many design units, to read on a 220 px tile. */
+export const COVER_CRITICAL = 60;
+
+/** The hero is at least this many times the size of the smallest detail (the aim is 18–30). */
+export const SCALE_CONTRAST = 12;
+
+export interface Grid {
+ w: number;
+ h: number;
+ /** The short side. */
+ S: number;
+ margin: number;
+ /** The margin's box: the inset line the corners sit on. */
+ inset: Box;
+ /** Where readable copy may go (the inset and the placement's own safe area, whichever is tighter). */
+ safe: Box;
+ columns: number;
+ gutter: number;
+ /** Width of one column. */
+ col: number;
+ /** The baseline unit (1 % of the short side). */
+ unit: number;
+ placement: Placement;
+}
+
+/** The safe area for a frame and placement (posts: the margin). */
+export function safeBox(design: { w: number; h: number }, placement: Placement): Box {
+ const S = Math.min(design.w, design.h);
+ const m = S * MARGIN;
+ const s = SAFE_INSETS[placement];
+ const left = Math.max(m, design.w * s.left);
+ const right = Math.max(m, design.w * s.right);
+ const top = Math.max(m, design.h * s.top);
+ const bottom = Math.max(m, design.h * s.bottom);
+ return { x: left, y: top, w: design.w - left - right, h: design.h - top - bottom };
+}
+
+/** The grid for a frame shown in a placement. */
+export function gridFor(design: { w: number; h: number }, placement: Placement = "post"): Grid {
+ const S = Math.min(design.w, design.h);
+ const margin = S * MARGIN;
+ const inset = { x: margin, y: margin, w: design.w - 2 * margin, h: design.h - 2 * margin };
+ const safe = safeBox(design, placement);
+ const columns = 12;
+ const gutter = design.w * 0.018;
+ const col = (safe.w - gutter * (columns - 1)) / columns;
+ return { w: design.w, h: design.h, S, margin, inset, safe, columns, gutter, col, unit: S * 0.01, placement };
+}
+
+/** Columns `from` (0-based) for `span` columns, inside the safe area. */
+export function columns(g: Grid, from: number, span: number): { x: number; w: number } {
+ const a = Math.max(0, Math.min(g.columns - 1, from));
+ const n = Math.max(1, Math.min(g.columns - a, span));
+ return { x: g.safe.x + a * (g.col + g.gutter), w: n * g.col + (n - 1) * g.gutter };
+}
+
+export type Corner = "tl" | "tr" | "bl" | "br";
+
+/**
+ * A corner slot for a small fact: the anchor point on the inset line (pushed inside the safe area) and how text is
+ * aligned there. Facts in the top corners hang from the line; bottom corners sit on it.
+ */
+export function corner(g: Grid, c: Corner): { x: number; y: number; align: "left" | "right"; from: "top" | "bottom" } {
+ const left = c === "tl" || c === "bl";
+ const top = c === "tl" || c === "tr";
+ return {
+ x: left ? g.safe.x : g.safe.x + g.safe.w,
+ y: top ? g.safe.y : g.safe.y + g.safe.h,
+ align: left ? "left" : "right",
+ from: top ? "top" : "bottom",
+ };
+}
+
+/** The placement a recipe is shown in: a gallery cover, a 9:16 ad (or story when chosen), or a post. */
+export function placementOf(r: { size: unknown; controls?: Record<string, unknown> }): Placement {
+ if (r.controls?.cover === "tile") return "cover";
+ const tall = r.size === "9:16" || (typeof r.size === "object" && r.size !== null && (r.size as { h: number }).h / (r.size as { w: number }).w > 1.6);
+ if (tall) return r.controls?.placement === "story" ? "story" : "ad";
+ return "post";
+}
+
+/** Whether a box lies inside another (with a tolerance in design units). */
+export const inside = (b: Box, area: Box, tol = 0.5): boolean => b.x >= area.x - tol && b.y >= area.y - tol && b.x + b.w <= area.x + area.w + tol && b.y + b.h <= area.y + area.h + tol;
+
+/** Whether two boxes overlap (by more than `tol`). */
+export const overlaps = (a: Box, b: Box, tol = 0): boolean => a.x < b.x + b.w - tol && b.x < a.x + a.w - tol && a.y < b.y + b.h - tol && b.y < a.y + a.h - tol;
+
+/** The hero's size range for a frame (14–40 % of the short side). */
+export const heroRange = (design: { w: number; h: number }): { min: number; max: number } => {
+ const S = Math.min(design.w, design.h);
+ return { min: S * LADDER.hero[0], max: S * LADDER.hero[1] };
+};
diff --git a/src/lib/motion/layout.ts b/src/lib/motion/layout.ts
index d82688fa..efdb6d17 100644
--- a/src/lib/motion/layout.ts
+++ b/src/lib/motion/layout.ts
@@ -155,6 +155,12 @@ function atomsOf(text: string): Atom[] {
type Width = (i: number, j: number) => number;
+/** Little joining words a line should not end on (English). */
+const WEAK = /^(a|an|the|of|for|to|in|on|at|by|and|or|nor|but|with|from|into|as|that|which|who|whose|minus|plus|than|your|our|my|their|its|is|are|&)$/i;
+
+/** A word that ends a clause (a comma, a dash, a colon): the best place for a line to end. */
+const CLAUSE = /[,;:—–]$/;
+
/** Fewest lines that hold the atoms a..b (inclusive) at this width, or Infinity when one atom is wider than the box. */
function greedyCount(a: number, b: number, width: number, w: Width): number {
let lines = 1;
@@ -173,17 +179,24 @@ function greedyCount(a: number, b: number, width: number, w: Width): number {
* The break of atoms a..b into exactly `n` lines whose widths are closest to each other (least squares), a line of one
* lone word costing more when there are words enough to keep each line at two or more.
*/
-function balancedBreaks(a: number, b: number, n: number, width: number, w: Width): number[] {
+function balancedBreaks(a: number, b: number, n: number, width: number, w: Width, weak: (atom: number) => boolean = () => false, clause: (atom: number) => boolean = () => false): number[] {
if (n <= 1) return [a];
const avg = w(a, b) / n;
const count = b - a + 1;
- const lone = count >= 2 * n ? (avg * 0.4) ** 2 : 0;
+ // A lone word on a line (a widow at the start or end of a rag) costs more than an uneven line, less than a line
+ // ending on a joining word.
+ const lone = count >= 2 * n ? (avg * 0.6) ** 2 : 0;
+ // A line that ends on a little joining word ("for", "the", "and") reads as cut off: it costs as much as a lone word.
+ // A line that ends on a clause's punctuation ("Month-end,") reads best: it earns back nearly as much.
+ const dangling = (avg * 1.6) ** 2;
+ const bonus = (avg * 0.42) ** 2;
+ const end = (j: number) => (j < count - 1 ? (weak(a + j) ? dangling : clause(a + j) ? -bonus : 0) : 0);
// cost[l][j]: the best l + 1 lines ending at atom a + j; from[l][j]: where the last of them starts.
const cost = Array.from({ length: n }, () => new Float64Array(count).fill(Infinity));
const from = Array.from({ length: n }, () => new Int32Array(count).fill(-1));
for (let j = 0; j < count; j++) {
const lw = w(a, a + j);
- if (lw <= width) cost[0][j] = (lw - avg) ** 2 + (j === 0 ? lone : 0);
+ if (lw <= width) cost[0][j] = (lw - avg) ** 2 + (j === 0 ? lone : 0) + end(j);
}
for (let l = 1; l < n; l++) {
for (let j = l; j < count; j++) {
@@ -192,7 +205,7 @@ function balancedBreaks(a: number, b: number, n: number, width: number, w: Width
if (prev === Infinity) continue;
const lw = w(a + i, a + j);
if (lw > width) continue;
- const c = prev + (lw - avg) ** 2 + (i === j ? lone : 0);
+ const c = prev + (lw - avg) ** 2 + (i === j ? lone : 0) + end(j);
if (c < cost[l][j]) {
cost[l][j] = c;
from[l][j] = i;
@@ -266,7 +279,24 @@ export function layoutText(spec: TextSpec, measure: Measure): TextLayout {
const fits = total <= spec.maxLines && Number.isFinite(total);
if (!fits && !last) return null;
// Too long even at the smallest size: every line still laid out (nothing cut), and flagged.
- const starts = paras.flatMap(([a, b], k) => (fits ? balancedBreaks(a, b, counts[k], spec.width, w) : greedyStarts(a, b, spec.width, w)));
+ const weak = (j: number) => WEAK.test(text.slice(atoms[j].start, atoms[j].end));
+ const clause = (j: number) => CLAUSE.test(text.slice(atoms[j].start, atoms[j].end));
+ // A line may end on a little joining word only when there is no other way: one more line (while the box allows it)
+ // is tried first.
+ const endsWeak = (st: number[], b: number) => st.some((s0, i) => i > 0 && s0 - 1 <= b && weak(s0 - 1));
+ let spare = spec.maxLines - total;
+ const starts = paras.flatMap(([a, b], k) => {
+ if (!fits) return greedyStarts(a, b, spec.width, w);
+ let st = balancedBreaks(a, b, counts[k], spec.width, w, weak, clause);
+ if (spare > 0 && endsWeak(st, b)) {
+ const more = balancedBreaks(a, b, counts[k] + 1, spec.width, w, weak, clause);
+ if (more.length === counts[k] + 1 && !endsWeak(more, b)) {
+ st = more;
+ spare--;
+ }
+ }
+ return st;
+ });
const lines: LineLayout[] = starts.map((s, k) => {
const e = (k + 1 < starts.length ? starts[k + 1] : atoms.length) - 1;
const lineStart = atoms[s].start;
diff --git a/src/lib/motion/registry.ts b/src/lib/motion/registry.ts
index 3683a759..67b285fd 100644
--- a/src/lib/motion/registry.ts
+++ b/src/lib/motion/registry.ts
@@ -1,8 +1,10 @@
/**
- * Every Kinetic Motion scene by id, loaded only when a page plays or renders it.
+ * Every Kinetic Motion scene by id, loaded only when a page plays or renders it, and the type faces each one draws
+ * with (known before the scene loads, so its fonts are fetched alongside it).
*/
import type { Scene } from "./scene";
+import { pairingFaces, type PairingId } from "./type/pairings";
const LOADERS: Record<string, () => Promise<{ default: Scene }>> = {
"end-card/draw-on": () => import("./scenes/end-card/draw-on"),
@@ -19,12 +21,55 @@ const LOADERS: Record<string, () => Promise<{ default: Scene }>> = {
"marketing/offer-badge": () => import("./scenes/marketing/offer-badge"),
"marketing/big-number": () => import("./scenes/marketing/big-number"),
"marketing/quote": () => import("./scenes/marketing/quote"),
+ "marketing/drop-countdown": () => import("./scenes/marketing/drop-countdown"),
+ "marketing/fragrance-reveal": () => import("./scenes/marketing/fragrance-reveal"),
+ "marketing/editorial-sale": () => import("./scenes/marketing/editorial-sale"),
+ "marketing/glass-spotlight": () => import("./scenes/marketing/glass-spotlight"),
+ "marketing/announcement": () => import("./scenes/marketing/announcement"),
+ "marketing/lookbook": () => import("./scenes/marketing/lookbook"),
+ "marketing/stat-stack": () => import("./scenes/marketing/stat-stack"),
+ "marketing/testimonials": () => import("./scenes/marketing/testimonials"),
+};
+
+/**
+ * The type pairing each scene sets its words in (its hero, accent, details and body faces). Scenes built on the
+ * poster kit declare the same pairing themselves (tests hold the two together).
+ */
+export const SCENE_PAIRINGS: Record<string, PairingId> = {
+ "end-card/draw-on": "T9",
+ "end-card/rise": "T9",
+ "end-card/iris": "T9",
+ "end-card/split": "T9",
+ "end-card/glint": "T9",
+ "marketing/kinetic-headline": "T1",
+ "marketing/line-reveal": "T4",
+ "marketing/logo-sting": "T3",
+ "marketing/feature-cards": "T7",
+ "marketing/stat-dashboard": "T7",
+ "marketing/starburst": "T8",
+ "marketing/offer-badge": "T2",
+ "marketing/big-number": "T7",
+ "marketing/quote": "T5",
+ "marketing/drop-countdown": "T3",
+ "marketing/fragrance-reveal": "T4",
+ "marketing/editorial-sale": "T2",
+ "marketing/glass-spotlight": "T4",
+ "marketing/announcement": "T6",
+ "marketing/lookbook": "T1",
+ "marketing/stat-stack": "T2",
+ "marketing/testimonials": "T9",
};
export const SCENE_IDS = Object.keys(LOADERS);
export const hasScene = (id: string): boolean => Object.hasOwn(LOADERS, id);
+/** The Kinetic families a scene draws with (none for an unknown scene). */
+export function sceneFamilies(id: string | null | undefined): string[] {
+ const p = id ? SCENE_PAIRINGS[id] : undefined;
+ return p ? [...new Set(pairingFaces(p).map((f) => f.family))] : [];
+}
+
const loaded = new Map<string, Promise<Scene>>();
/** The scene with this id (rejects for an unknown one). */
diff --git a/src/lib/motion/scene.ts b/src/lib/motion/scene.ts
index 13e83eea..f4b01b5e 100644
--- a/src/lib/motion/scene.ts
+++ b/src/lib/motion/scene.ts
@@ -78,6 +78,8 @@ export interface Scene {
name: string;
durations: { min: number; max: number; default: number };
sizes: SizeSpec[];
+ /** The type pairing its words are set in (scenes built on the poster kit). */
+ pairing?: string;
plan(input: SceneInput): ScenePlan;
}
diff --git a/src/lib/motion/scenes/end-card/draw-on.ts b/src/lib/motion/scenes/end-card/draw-on.ts
index 7d44fc58..242b92d3 100644
--- a/src/lib/motion/scenes/end-card/draw-on.ts
+++ b/src/lib/motion/scenes/end-card/draw-on.ts
@@ -7,7 +7,7 @@
import { about, group, translate, type DisplayNode } from "../../display";
import { linearProgress, progress, type Cue } from "../../tween";
-import { endCardScene, letterRuns, lineLeft, lineRun, lineRuns, logoImage, logoPaths, pillRect, wipe } from "./shared";
+import { endCardScene, letterRuns, lineLeft, lineRun, lineRuns, logoImage, logoPaths, pillRect, wipe, keepFor } from "./shared";
export default endCardScene("draw-on", ({ rest, input }) => {
const { logo, brand, headline, cta, site } = rest;
@@ -34,6 +34,7 @@ export default endCardScene("draw-on", ({ rest, input }) => {
return {
cues,
+ keep: keepFor("draw-on", rest),
lead: 0.1,
signature: 0.2,
frame(t, tl) {
diff --git a/src/lib/motion/scenes/end-card/glint.ts b/src/lib/motion/scenes/end-card/glint.ts
index c3465372..a894e322 100644
--- a/src/lib/motion/scenes/end-card/glint.ts
+++ b/src/lib/motion/scenes/end-card/glint.ts
@@ -8,7 +8,7 @@
import { luminance } from "@/components/ads/layout";
import { group, mixHex, roundRectPath, withAlpha, type DisplayNode } from "../../display";
import { linearProgress, progress, type Cue } from "../../tween";
-import { blockCentre, deepGround, endCardScene, entering, letterRuns, lineRuns, markBox, markNodes, pillRect, wipe } from "./shared";
+import { blockCentre, deepGround, endCardScene, entering, letterRuns, lineRuns, markBox, markNodes, pillRect, wipe, keepFor } from "./shared";
const ANGLE = (20 * Math.PI) / 180;
@@ -30,6 +30,8 @@ export default endCardScene("glint", ({ rest }) => {
return {
cues,
+ keep: keepFor("glint", rest),
+ sweep: false,
lead: 0.06,
signature: 0.12,
background: ground,
diff --git a/src/lib/motion/scenes/end-card/iris.ts b/src/lib/motion/scenes/end-card/iris.ts
index 5a5f7365..30dcd22f 100644
--- a/src/lib/motion/scenes/end-card/iris.ts
+++ b/src/lib/motion/scenes/end-card/iris.ts
@@ -7,35 +7,41 @@
import { about, group, withAlpha, type DisplayNode } from "../../display";
import { linearProgress, progress, type Cue } from "../../tween";
-import { blockCentre, deepGround, endCardScene, entering, letterRuns, lineRuns, markBox, markNodes, openingGround, pillRect } from "./shared";
+import { blockCentre, deepGround, endCardScene, entering, letterRuns, lineRuns, markBox, markNodes, openingGround, pillRect, keepFor } from "./shared";
export default endCardScene("iris", ({ rest, second }) => {
const { headline, cta, site } = rest;
const mark = markBox(rest);
- const cues: Cue[] = [{ id: "iris", kind: "move", at: 0, dur: 0.65, curve: "glide" }];
+ const cues: Cue[] = [{ id: "iris", kind: "move", at: 0, dur: 0.45, curve: "glide" }];
if (mark) cues.push({ id: "mark", kind: "enter", at: 0.15, dur: 0.5, curve: "settle" });
if (headline.layout.lines.length) cues.push({ id: "headline", kind: "enter", at: 0.3, dur: 0.5, curve: "glide" });
if (site) cues.push({ id: "site", kind: "fade", at: 0.5, dur: 0.35, curve: "enter" });
if (cta) cues.push({ id: "cta", kind: "pop", at: 0.5, dur: 0.4, curve: "pop" });
- const ground = openingGround(rest.theme, second);
+ // It opens out of the deep shade of the brand colour (never a flat second colour in the corners).
+ const ground = deepGround(rest.theme);
+ void openingGround;
+ void second;
// On a deep ground a fine rim in the words' colour draws the circle's edge.
- const rim = ground === deepGround(rest.theme) && ground !== second ? rest.ink : null;
+ const rim = rest.ink;
const S = Math.min(rest.w, rest.h);
return {
cues,
+ keep: keepFor("iris", rest),
lead: 0.06,
signature: 0.14,
background: ground,
frame(t, tl) {
const P = (id: string) => progress(tl, id, t);
const under: DisplayNode[] = [];
- const R = Math.hypot(rest.w / 2, rest.h / 2) + 4;
+ // It opens past the corners with a wide feathered edge (no hard wedge in a corner).
+ const feather = S * 0.04;
+ const R = Math.hypot(rest.w / 2, rest.h / 2) + feather;
const open = P("iris");
const r = open * R;
if (r > 0.5) {
// A soft edge a few units wide.
- const edge = Math.max(0, (r - 3) / r);
+ const edge = Math.max(0, (r - feather) / r);
under.push({
type: "ellipse",
id: "iris",
diff --git a/src/lib/motion/scenes/end-card/rise.ts b/src/lib/motion/scenes/end-card/rise.ts
index 61699b61..17077465 100644
--- a/src/lib/motion/scenes/end-card/rise.ts
+++ b/src/lib/motion/scenes/end-card/rise.ts
@@ -6,9 +6,9 @@
import { about, group, multiply, translate, type DisplayNode } from "../../display";
import { progress, type Cue } from "../../tween";
-import { blockCentre, endCardScene, entering, lineRuns, markBox, markNodes, pillRect } from "./shared";
+import { blockCentre, deepGround, endCardScene, entering, lineRuns, markBox, markNodes, pillRect, keepFor } from "./shared";
-export default endCardScene("rise", ({ rest, second }) => {
+export default endCardScene("rise", ({ rest }) => {
const { headline, cta, site } = rest;
const mark = markBox(rest);
const items = [mark && "mark", headline.layout.lines.length && "headline", cta && "cta"].filter(Boolean) as string[];
@@ -20,10 +20,12 @@ export default endCardScene("rise", ({ rest, second }) => {
return {
cues,
+ keep: keepFor("rise", rest),
// The panel is about a quarter of the way up on the first frame.
lead: 0.055,
signature: 0.075,
- background: second,
+ // It rises out of the brand colour's own deep shade (no band of a second colour across the top).
+ background: deepGround(rest.theme),
frame(t, tl) {
const P = (id: string) => progress(tl, id, t);
const lift = S * 0.1;
diff --git a/src/lib/motion/scenes/end-card/shared.ts b/src/lib/motion/scenes/end-card/shared.ts
index 638538af..ba092d36 100644
--- a/src/lib/motion/scenes/end-card/shared.ts
+++ b/src/lib/motion/scenes/end-card/shared.ts
@@ -7,7 +7,7 @@
* layout's pieces. Through the hold a slow push-in keeps the card alive and comes to rest on the last frame.
*/
-import { contrast, luminance, readableOn, themeFrom, type AdTheme } from "@/components/ads/layout";
+import { contrast, fontString, luminance, readableOn, themeFrom, type AdTheme } from "@/components/ads/layout";
import { about, group, mixHex, multiply, translate, type DisplayList, type DisplayNode, type Matrix, type TextNode, type TextRun } from "../../display";
import { curve } from "../../ease";
import { layoutText, type Measure, type TextLayout } from "../../layout";
@@ -25,7 +25,7 @@ export type EndCardVariant = (typeof END_CARD_VARIANTS)[number];
export const END_CARD_VARIANT_NAMES: Record<EndCardVariant, string> = { "draw-on": "Draw-on", rise: "Rise", iris: "Iris", split: "Split", glint: "Glint" };
/** The card's lengths (seconds), as Click to Ad's end card allows. */
-export const END_CARD_DURATIONS = { min: 2, max: 3, default: 2.5 } as const;
+export const END_CARD_DURATIONS = { min: 2, max: 5, default: 2.5 } as const;
export interface EndCardContent {
/** Shown when there is no logo. */
@@ -96,17 +96,21 @@ export function endCardRest(p: { theme: AdTheme; content: EndCardContent; logo:
const inner = Math.min(W - 2 * m, Math.round(S * 1.1));
const { ink, pill, label: labelColour } = cardColours(t, p.colors ?? []);
const gap = V * 0.04;
- const logoH = V * 0.15;
+ // The mark is the hero: the logo as wide as the margins allow (up to a fifth of the height), or the name huge.
+ const logoH = V * 0.2;
const letters = p.letters ?? true;
const brandText = p.content.brand.trim();
- const name = !p.logo && brandText ? layoutText({ text: brandText, family: t.heading, weight: 800, width: inner, maxLines: 2, max: S * 0.1, min: S * 0.06, lineHeight: 1.05, letters }, p.measure) : null;
- const head = layoutText({ text: p.content.product, family: t.heading, weight: 700, width: inner, maxLines: 2, max: S * 0.068, min: S * 0.045, letters }, p.measure);
- const ctaSize = S * 0.045;
+ // One line where it fits (a name is never broken for size), two only when it must.
+ const name1 = !p.logo && brandText ? layoutText({ text: brandText, family: t.heading, weight: 800, width: inner, maxLines: 1, max: S * 0.16, min: S * 0.07, lineHeight: 1.05, letters }, p.measure) : null;
+ const name = name1 && name1.overflow ? layoutText({ text: brandText, family: t.heading, weight: 800, width: inner, maxLines: 2, max: S * 0.16, min: S * 0.06, lineHeight: 1.05, letters }, p.measure) : name1;
+ // The product's line about half the mark's size, the call to action a hairline-outlined tag about half of that.
+ const head = layoutText({ text: p.content.product, family: t.heading, weight: 600, width: inner, maxLines: 2, max: S * 0.066, min: S * 0.04, letters }, p.measure);
+ const ctaSize = S * 0.036;
const ctaText = p.content.cta?.trim();
- const label = ctaText ? layoutText({ text: ctaText, family: t.body, weight: 700, width: inner - ctaSize * 2.4, maxLines: 1, max: ctaSize, min: S * 0.03 }, p.measure) : null;
+ const label = ctaText ? layoutText({ text: ctaText, family: t.body, weight: 600, width: inner - ctaSize * 2.4, maxLines: 1, max: ctaSize, min: S * 0.026 }, p.measure) : null;
const siteText = p.content.website?.trim();
- const site = siteText ? layoutText({ text: siteText, family: t.body, weight: 500, width: inner, maxLines: 1, max: S * 0.032, min: S * 0.024 }, p.measure) : null;
- const ctaH = label ? label.size * 2.3 : 0;
+ const site = siteText ? layoutText({ text: siteText, family: t.body, weight: 500, width: inner, maxLines: 1, max: S * 0.028, min: S * 0.022 }, p.measure) : null;
+ const ctaH = label ? label.size * 2.2 : 0;
const top = p.logo ? logoH : name ? name.lines.length * name.size * 1.05 : 0;
const headH = head.lines.length * head.size * 1.12;
const siteH = site ? site.size * 1.12 : 0;
@@ -143,7 +147,9 @@ export function endCardRest(p: { theme: AdTheme; content: EndCardContent; logo:
y += gap * 1.4;
const bw = Math.min(inner, label.width + label.size * 2.4);
const bx = (W - bw) / 2;
- cta = { x: bx, y, w: bw, h: ctaH, r: ctaH / 2, color: pill, label: { field: "cta", layout: label, cx: bx + bw / 2, y: y + (ctaH - label.size * 1.12) / 2, color: labelColour } };
+ // A hairline-outlined tag in the words' colour, its label in the same colour on the brand colour.
+ void labelColour;
+ cta = { x: bx, y, w: bw, h: ctaH, r: ctaH / 2, color: pill, label: { field: "cta", layout: label, cx: bx + bw / 2, y: y + (ctaH - label.size * 1.12) / 2, color: ink } };
y += ctaH;
}
const siteBlock: TextBlock | undefined = site ? { field: "website", layout: site, cx: W / 2, y: y + (above ? siteGap : 0), color: ink } : undefined;
@@ -242,7 +248,8 @@ export function letterRuns(b: TextBlock, each: (letter: number, count: number) =
/** The logo as drawn at rest. */
export const logoImage = (r: NonNullable<EndCardRest["logo"]>, opacity = 1): DisplayNode => ({ type: "image", id: "logo", src: "logo", x: r.x, y: r.y, w: r.w, h: r.h, ...(opacity < 1 && { opacity }) });
-export const pillRect = (c: NonNullable<EndCardRest["cta"]>): DisplayNode => ({ type: "rect", id: "cta.pill", x: c.x, y: c.y, w: c.w, h: c.h, r: c.r, fill: c.color });
+/** The call to action's tag: a hairline outline in the words' colour (never a heavy web button). */
+export const pillRect = (c: NonNullable<EndCardRest["cta"]>): DisplayNode => ({ type: "rect", id: "cta.pill", x: c.x, y: c.y, w: c.w, h: c.h, r: c.r, fill: "rgba(0,0,0,0)", stroke: { paint: c.color, width: Math.max(1.5, c.h * 0.035) } });
/** The card at rest: what the still card draws, in the same order. */
export function restNodes(r: EndCardRest): DisplayNode[] {
@@ -255,6 +262,54 @@ export function restNodes(r: EndCardRest): DisplayNode[] {
return nodes;
}
+/**
+ * The light the card sits in (the still card draws it too): a soft pool of light high in the middle, the corners
+ * falling away into a deeper shade of the brand colour, a faint glow behind the mark, fine rings opening from one
+ * corner and a fine grain, so the ground is never a flat fill. Behind it the brand's name runs in rows of giant
+ * tonal type cropped by the edges, and a hairline frame sits inside the margin. Every piece is a gradient, a hairline or
+ * a faint tone: the words' colours read on the brand colour as before.
+ */
+export function cardField(r: EndCardRest, seed = 7, name = "", drift = 0): DisplayNode[] {
+ const { w, h } = r;
+ const S = Math.min(w, h);
+ const a = r.theme.accent;
+ const dark = luminance(a) < 0.18;
+ const light = mixHex(a, "#ffffff", dark ? 0.16 : 0.22);
+ const deep = mixHex(a, "#000000", dark ? 0.55 : 0.32);
+ const mark = markBox(r);
+ const mx = mark ? mark.x + mark.w / 2 : w / 2;
+ const my = mark ? mark.y + mark.h / 2 : h * 0.4;
+ const rgba = (hex: string, al: number) => `rgba(${parseInt(hex.slice(1, 3), 16)},${parseInt(hex.slice(3, 5), 16)},${parseInt(hex.slice(5, 7), 16)},${al})`;
+ const rows: DisplayNode[] = [];
+ const word = name.trim();
+ if (word) {
+ // One whole word, filled a step lighter than the brand colour (never a hairline), wider than the card's middle and
+ // centred, standing on the bottom edge so the edge crops its foot (every letter shows whole across); it drifts by
+ // `drift` (design units) while the card plays and sits centred at rest. Its width is estimated from its length
+ // (it is decoration: only roughly centred).
+ const unit = Math.max(1, [...word].length * 48);
+ const foot = r.site ? r.site.y + r.site.layout.height : r.cta ? r.cta.y + r.cta.h : r.headline.y + r.headline.layout.height;
+ // Whole: the word is sized to stand in the room under the stack with only the foot of its letters cropped (accents
+ // and all), never a cut-off fragment.
+ const size = Math.min(S * 0.6, ((w * 0.86) / unit) * 100, Math.max(S * 0.12, (h - foot - S * 0.06) / 0.92));
+ const font = fontString(r.theme.heading, size, 700);
+ const y0 = Math.max(foot + S * 0.06, h - size * 0.92);
+ const width = (unit * size) / 100;
+ const tone = mixHex(a, dark ? "#ffffff" : "#000000", dark ? 0.05 : 0.045);
+ const runs: TextRun[] = [{ text: word, gap: "", font, x: (w - width) / 2 + drift, y: y0, fill: tone }];
+ rows.push({ type: "text", field: "brand", runs, decor: true });
+ }
+ // A warm orb of the words' own colour behind the mark: one light source the card is lit by.
+ const orb = Math.max(S * 0.5, Math.min(w, h) * 0.7);
+ return [
+ { type: "rect", id: "card.light", x: 0, y: 0, w, h, fill: { kind: "radial", cx: w / 2, cy: h * 0.28, r0: 0, r1: Math.hypot(w, h) * 0.55, stops: [{ at: 0, color: rgba(light, 0.85) }, { at: 0.55, color: rgba(light, 0.18) }, { at: 1, color: rgba(light, 0) }] } },
+ { type: "rect", id: "card.corners", x: 0, y: 0, w, h, fill: { kind: "radial", cx: w / 2, cy: h * 0.45, r0: S * 0.4, r1: Math.hypot(w, h) * 0.62, stops: [{ at: 0, color: rgba(deep, 0) }, { at: 1, color: rgba(deep, 0.8) }] } },
+ { type: "rect", id: "card.glow", x: mx - orb, y: my - orb, w: orb * 2, h: orb * 2, fill: { kind: "radial", cx: mx, cy: my, r0: 0, r1: orb, stops: [{ at: 0, color: rgba(mixHex(r.ink, "#ffb46b", 0.25), 0.26) }, { at: 0.4, color: rgba(r.ink, 0.1) }, { at: 1, color: rgba(r.ink, 0) }] } },
+ ...rows,
+ { type: "grain", seed, frame: 0, amount: dark ? 0.035 : 0.045, size: 1.25, blend: dark ? "screen" : "overlay", x: 0, y: 0, w, h },
+ ];
+}
+
/** The mark at the top of the block: the logo, else the brand's name, else nothing. */
export const markNodes = (r: EndCardRest): DisplayNode[] => (r.logo ? [logoImage(r.logo)] : r.brand ? [lineRuns(r.brand)] : []);
@@ -322,6 +377,10 @@ export interface StyleFrame {
export interface StyleBuild {
cues: Cue[];
+ /** What this style leaves on the card at rest (its own mark of difference), drawn from when it settles. */
+ keep?: DisplayNode[];
+ /** Whether a band of light crosses the mark once the card has settled (default on). */
+ sweep?: boolean;
/**
* How far (seconds, on a 2.5 s card) the card is already into its motion on its first frame: the cut from the ad
* lands on movement, never on an empty frame.
@@ -387,10 +446,34 @@ export function endCardScene(variant: EndCardVariant, build: (c: StyleContext) =
};
const cx = design.w / 2;
const cy = design.h / 2;
+ const field = cardField(rest, input.recipe.seed, content.brand);
+ // The hollow name drifts across while the card moves, home by the time it settles.
+ const S0 = Math.min(design.w, design.h);
+ const fieldAt = (t: number) => {
+ const u = settled > 0 ? Math.min(1, t / settled) : 1;
+ const dx = -S0 * 0.12 * (1 - u) ** 2;
+ return Math.abs(dx) < 0.05 ? field : cardField(rest, input.recipe.seed, content.brand, dx);
+ };
+ const keep = style.keep ?? [];
const homeExtra = extra?.(last, last, design.w);
const homeMoved = !!homeExtra && (homeExtra.zoom !== 1 || homeExtra.x !== 0 || homeExtra.y !== 0 || homeExtra.roll !== 0);
- const restList: DisplayList = { w: design.w, h: design.h, background: theme.accent, nodes: homeMoved ? [group(restNodes(rest), { id: "camera", transform: multiply(translate(homeExtra.x, homeExtra.y), about(cx, cy, homeExtra.zoom, homeExtra.roll)) })] : restNodes(rest) };
+ const restList: DisplayList = { w: design.w, h: design.h, background: theme.accent, nodes: [...field, ...keep, ...(homeMoved ? [group(restNodes(rest), { id: "camera", transform: multiply(translate(homeExtra.x, homeExtra.y), about(cx, cy, homeExtra.zoom, homeExtra.roll)) })] : restNodes(rest))] };
const still = graded(restList, last);
+ // One band of light across the mark after it settles.
+ const markB = markBox(rest);
+ const sweepFrom = settled + 0.05;
+ const sweepDur = Math.min(0.7, Math.max(0, last - 0.05 - sweepFrom));
+ const sweepOn = style.sweep !== false && !!markB && sweepDur > 0.25;
+ const swept = (t: number, nodes: DisplayNode[]): DisplayNode[] => {
+ if (!sweepOn || !markB || t < sweepFrom || t >= sweepFrom + sweepDur) return nodes;
+ const u = curve("move")((t - sweepFrom) / sweepDur);
+ const bw = Math.max(markB.h * 0.6, markB.w * 0.18);
+ const x = markB.x - bw + (markB.w + 2 * bw) * u;
+ const pad = 4;
+ const band: DisplayNode = { type: "rect", x: x - bw / 2, y: markB.y - markB.h, w: bw, h: markB.h * 3, fill: { kind: "linear", x0: x - bw / 2, y0: 0, x1: x + bw / 2, y1: 0, stops: [{ at: 0, color: "rgba(255,255,255,0)" }, { at: 0.5, color: "rgba(255,255,255,0.6)" }, { at: 1, color: "rgba(255,255,255,0)" }] } };
+ const lit = group([...markNodes(rest).map((n): DisplayNode => (n.type === "text" || n.type === "image" ? { ...n, decor: true } : n)), group([band], { blend: "source-atop", transform: [1, 0, -0.3, 1, (markB.y + markB.h / 2) * 0.3, 0] })], { id: "sweep", isolate: { x: markB.x - pad, y: markB.y - pad, w: markB.w + 2 * pad, h: markB.h + 2 * pad } });
+ return [...nodes, lit];
+ };
const drift = curve("drift");
const camera = (t: number, nodes: DisplayNode[]): DisplayNode[] => {
const tc = clock ? clock(t) : t;
@@ -412,9 +495,9 @@ export function endCardScene(variant: EndCardVariant, build: (c: StyleContext) =
overflow: rest.overflow,
evaluate: (t) => {
if (t >= last) return still;
- if (t >= settled) return graded({ ...restList, nodes: camera(t, restNodes(rest)) }, t);
+ if (t >= settled) return graded({ ...restList, nodes: [...fieldAt(t), ...keep, ...camera(t, swept(t, restNodes(rest)))] }, t);
const f = style.frame(t, tl);
- return graded({ w: design.w, h: design.h, background: style.background ?? theme.accent, nodes: [...(f.under ?? []), ...camera(t, f.nodes), ...(f.over ?? [])] }, t);
+ return graded({ w: design.w, h: design.h, background: style.background ?? theme.accent, nodes: [...(f.under ?? []), ...fieldAt(t), ...camera(t, f.nodes), ...(f.over ?? [])] }, t);
},
still: (t) => t >= last,
};
@@ -439,3 +522,71 @@ export function wipe(children: DisplayNode[], box: { x: number; y: number; w: nu
mask: { kind: "linear", x0: edge - feather, y0: 0, x1: edge, y1: 0, stops: [{ at: 0, color: "rgba(0,0,0,1)" }, { at: 1, color: "rgba(0,0,0,0)" }], bounds: { x: box.x - feather, y: box.y - feather, w: box.w + 2 * feather, h: box.h + 2 * feather } },
});
}
+
+/** A colour at an alpha (hex in), for the details below. */
+const tint = (hex: string, a: number) => `rgba(${parseInt(hex.slice(1, 3), 16)},${parseInt(hex.slice(3, 5), 16)},${parseInt(hex.slice(5, 7), 16)},${a})`;
+
+
+/**
+ * What each style leaves on the card at rest, so the five end on five different cards: Draw-on its drawn corners,
+ * Rise a rule under the name, Iris a soft ring round the mark, Split a seam of light down the middle, Glint a star of
+ * light on the mark. Hairlines and light only: the words read as before.
+ */
+export function keepFor(variant: EndCardVariant, r: EndCardRest): DisplayNode[] {
+ const S = Math.min(r.w, r.h);
+ const hair = Math.max(1, S * 0.0022);
+ const mark = markBox(r);
+ const ink = r.ink.startsWith("#") && r.ink.length === 7 ? r.ink : "#ffffff";
+ switch (variant) {
+ case "draw-on": {
+ // Two fine rules flanking the product's name (a jeweller's label), clear of its letters.
+ const b = r.headline;
+ if (!b.layout.lines.length) return [];
+ const y = b.y + b.layout.lineHeight / 2;
+ const half = b.layout.width / 2;
+ const gap = S * 0.035;
+ const L = Math.min(S * 0.09, Math.max(0, r.w / 2 - half - gap - r.margin));
+ if (L < S * 0.03) return [];
+ const d = `M${b.cx - half - gap - L} ${y}H${b.cx - half - gap}M${b.cx + half + gap} ${y}H${b.cx + half + gap + L}`;
+ return [{ type: "path", id: "keep.rules", d, stroke: { paint: tint(ink, 0.75), width: hair, cap: "butt" } }];
+ }
+ case "rise": {
+ const b = r.headline;
+ const y = b.y + b.layout.height + S * 0.025;
+ const w = Math.max(S * 0.3, b.layout.width * 0.7);
+ return [{ type: "rect", id: "keep.rule", x: b.cx - w / 2, y, w, h: hair, fill: tint(ink, 0.8) }];
+ }
+ case "iris": {
+ if (!mark) return [];
+ const cx = mark.x + mark.w / 2;
+ const cy = mark.y + mark.h / 2;
+ // A fine oval round the mark alone: it clears every other line of words by 24 units or more and stays inside the
+ // frame (never through the product's name, the tag or the address).
+ const below = r.headline.layout.lines.length ? r.headline.y : r.cta ? r.cta.y : r.h - r.margin;
+ const room = Math.max(0, below - S * 0.022 - cy);
+ const rx = Math.min(r.w / 2 - S * 0.03, mark.w / 2 + S * 0.06);
+ const ry = Math.min(room, Math.max(mark.h / 2 + S * 0.03, rx * 0.36));
+ if (ry < mark.h / 2 + S * 0.012) return [];
+ return [{ type: "ellipse", id: "keep.ring", cx, cy, rx, ry, stroke: { paint: tint(ink, 0.35), width: Math.max(1.5, hair) } }];
+ }
+ case "split": {
+ // A pair of fine vertical rules either side of the stack, where the panels parted.
+ const top = mark ? mark.y : r.headline.y;
+ const bottom = r.site ? r.site.y + r.site.layout.height : r.cta ? r.cta.y + r.cta.h : r.headline.y + r.headline.layout.height;
+ const x0 = Math.max(r.margin * 0.6, r.w / 2 - r.inner / 2 - S * 0.02);
+ const x1 = r.w - x0;
+ const mid = (top + bottom) / 2;
+ const L = Math.min(S * 0.16, (bottom - top) * 0.5);
+ return [{ type: "path", id: "keep.seams", d: `M${x0} ${mid - L / 2}V${mid + L / 2}M${x1} ${mid - L / 2}V${mid + L / 2}`, stroke: { paint: tint(ink, 0.55), width: hair } }];
+ }
+ case "glint": {
+ if (!mark) return [];
+ // A soft diagonal sheen of warm light behind the mark, where the glint passed (no star).
+ const cx = mark.x + mark.w * 0.62;
+ const cy = mark.y + mark.h / 2;
+ const bw = Math.max(mark.h * 1.4, S * 0.12);
+ const sheen: DisplayNode = { type: "rect", id: "keep.sheen", x: cx - bw / 2, y: cy - mark.h * 0.85, w: bw, h: mark.h * 1.7, fill: { kind: "linear", x0: cx - bw / 2, y0: 0, x1: cx + bw / 2, y1: 0, stops: [{ at: 0, color: "rgba(255,236,200,0)" }, { at: 0.5, color: "rgba(255,236,200,0.14)" }, { at: 1, color: "rgba(255,236,200,0)" }] } };
+ return [group([sheen], { transform: [1, 0, -0.36, 1, cy * 0.36, 0] })];
+ }
+ }
+}
diff --git a/src/lib/motion/scenes/end-card/split.ts b/src/lib/motion/scenes/end-card/split.ts
index 3b92e4f1..2db12853 100644
--- a/src/lib/motion/scenes/end-card/split.ts
+++ b/src/lib/motion/scenes/end-card/split.ts
@@ -4,26 +4,29 @@
* draws under the call to action and the pill grows up from it, its round ends kept, with its label.
*/
-import { group, type DisplayNode } from "../../display";
+import { group, mixHex, type DisplayNode } from "../../display";
import { linearProgress, progress, type Cue } from "../../tween";
-import { endCardScene, entering, lineRuns, markBox, markNodes, shadeOf, wordRuns } from "./shared";
+import { endCardScene, entering, lineRuns, markBox, markNodes, wordRuns, keepFor } from "./shared";
export default endCardScene("split", ({ rest, second }) => {
const { headline, cta, site } = rest;
const mark = markBox(rest);
const words = headline.layout.lines.reduce((n, l) => n + l.words.length, 0);
const slots = Math.min(words, 8);
- const cues: Cue[] = [{ id: "panels", kind: "move", at: 0, dur: 0.55, curve: "move" }];
+ const cues: Cue[] = [{ id: "panels", kind: "move", at: 0, dur: 0.6, curve: "whip" }];
if (mark) cues.push({ id: "mark", kind: "enter", at: 0.15, dur: 0.5, curve: "settle" });
for (let s = 0; s < slots; s++) cues.push({ id: `headline.word.${s}`, kind: "enter", at: 0.28 + s * 0.065, dur: 0.45, curve: "glide", stagger: { group: "headline", unit: "words", index: s, each: 0.065 } });
if (cta) cues.push({ id: "cta.line", kind: "draw", at: 0.48, dur: 0.2, curve: "draw" }, { id: "cta.fill", kind: "move", at: 0.6, dur: 0.3, curve: "snap" });
if (site) cues.push({ id: "site", kind: "fade", at: 0.55, dur: 0.35, curve: "enter" });
- const left = second;
- const right = shadeOf(second);
+ // Both halves one colour (one deep shade of the brand colour): only the seam tells them apart.
+ const left = mixHex(rest.theme.accent, "#000000", 0.2);
+ const right = left;
+ void second;
const S = Math.min(rest.w, rest.h);
return {
cues,
+ keep: keepFor("split", rest),
lead: 0.05,
signature: 0.3,
frame(t, tl) {
@@ -72,6 +75,9 @@ export default endCardScene("split", ({ rest, second }) => {
if (open < 1) {
over.push({ type: "rect", id: "panel.left", x: -open * rest.w * 0.5, y: 0, w: rest.w * 0.5 + (1 - open), h: rest.h, fill: left });
over.push({ type: "rect", id: "panel.right", x: rest.w * 0.5 + open * rest.w * 0.5, y: 0, w: rest.w * 0.5, h: rest.h, fill: right });
+ // A rule of the words' colour on each inner edge, the light catching them as they whip apart.
+ const edge = Math.max(2, S * 0.004);
+ over.push({ type: "rect", id: "panel.edge.left", x: rest.w * 0.5 - open * rest.w * 0.5 - edge, y: 0, w: edge, h: rest.h, fill: rest.ink }, { type: "rect", id: "panel.edge.right", x: rest.w * 0.5 + open * rest.w * 0.5, y: 0, w: edge, h: rest.h, fill: rest.ink });
}
return { nodes, over };
},
diff --git a/src/lib/motion/scenes/marketing/announcement.ts b/src/lib/motion/scenes/marketing/announcement.ts
new file mode 100644
index 00000000..7b34abb1
--- /dev/null
+++ b/src/lib/motion/scenes/marketing/announcement.ts
@@ -0,0 +1,123 @@
+/**
+ * Marquee: an event announcement. A night photograph fills the frame and pushes in slowly, the guest framed in the
+ * right of it (the sample photo is mirrored so the face sits there), a warm light coming in from the top-right edge
+ * only; the event's name rises letter by letter as a justified stack in a heavy warm serif in the left 60 %, a line
+ * every 120 ms, and its glow comes up behind it like a sign switching on. A fine rule draws under it, the date and the
+ * place set under it, and the call to action lands in a pill. The house, the address, a corner note and an index
+ * arrow sit on the corners.
+ */
+
+import { group, type DisplayNode } from "../../display";
+import { ensureContrast, mixOk } from "../../color";
+import { pool } from "../../fx/background";
+import { photo as photoNode } from "../../fx/photo";
+import { rule } from "../../fx/overlays";
+import { brandSign, capAt, capBand, corners, fadeScrim, fitLines, footRow, meshField, metaInk, moveLines, onAccentInk, pillOn, posterScene, rgba, shadowed, signIn, signNodes, stackLanded } from "./poster";
+
+export default posterScene({
+ id: "marketing/announcement",
+ name: "Marquee",
+ pairing: "T6",
+ look: "dark",
+ build(c) {
+ const { S, safe, pal, design } = c;
+ const side = c.wide;
+ const pic = c.recipe.media?.product ? c.input.images?.product : undefined;
+ const colW = side ? safe.w * 0.5 : safe.w;
+ // The name keeps to the left two thirds, so the guest (framed in the right third) keeps their face.
+ // (narrow enough that no letter reaches the guest's face, which sits right of the frame's middle)
+ const heroW = side ? colW : safe.w * (design.w / design.h > 0.9 ? 0.46 : 0.52);
+ // The sample night photo has its guest on the left: mirrored, she stands in the right third (a person's own photo is never flipped).
+ const flip = !side && !!c.recipe.media?.product?.startsWith("/previews/kinetic/photos/");
+ const signH = S * (c.cover ? 0.066 : 0.05);
+ const sign = brandSign(c, { maxW: S * 0.42, h: signH, x: safe.x, y: safe.y, min: S * (c.cover ? 0.06 : 0.03) });
+
+ // Bottom up: the pill, the place, the date, the rule, then the name as large as the room above allows.
+ const ctaSize = S * (c.cover ? 0.05 : 0.04);
+ const footSize = S * (c.cover ? 0.024 : 0.02);
+ const footH = footSize * 1.1 + S * 0.045;
+ const ctaY = safe.y + safe.h - footH - ctaSize * 1.1 - ctaSize * 0.35;
+ const row = footRow(c, 2.6);
+ const cta = c.set("cta", c.field("cta"), { role: "body", weight: 600, x: safe.x + ctaSize * 0.6, y: ctaY, width: colW * 0.8, maxLines: 1, max: ctaSize, min: S * 0.03 });
+ const metaSize = S * (c.cover ? 0.036 : 0.028);
+ const whenSize = S * (c.cover ? 0.046 : 0.036);
+ // Two voices only: the display serif for the name, one sans for every fact.
+ const place0 = c.set("place", c.field("place"), { role: "body", weight: 400, x: safe.x, y: 0, width: colW, maxLines: 2, max: metaSize, min: S * 0.022 });
+ const when0 = c.set("when", c.field("when"), { role: "body", weight: 700, x: safe.x, y: 0, width: colW, maxLines: 2, max: whenSize, min: S * 0.026, leading: 1.1 });
+ const placeTop = (cta ? ctaY - ctaSize * 0.35 - S * 0.065 : safe.y + safe.h) - (place0 ? capBand(place0).h : 0);
+ const place = place0 ? capAt(c, "place", c.field("place"), { role: "body", weight: 400, x: safe.x, y: placeTop, width: colW, maxLines: 2, max: place0.size, min: place0.size }) : null;
+ const whenTop = placeTop - (place0 ? S * 0.028 : 0) - (when0 ? capBand(when0).h : 0);
+ const when = when0 ? capAt(c, "when", c.field("when"), { role: "body", weight: 700, x: safe.x, y: whenTop, width: colW, maxLines: 2, max: when0.size, min: when0.size, leading: 1.1 }) : null;
+ const ruleY = whenTop - S * 0.045;
+ const heroBottom = ruleY - S * 0.05;
+ const heroRoom = heroBottom - (safe.y + (sign?.h ?? 0) + S * 0.1);
+ const head = fitLines(c, "headline", c.field("headline"), { x: safe.x, top: heroBottom - heroRoom, room: heroRoom, anchor: 1, width: heroW, maxLines: 3, max: S * (side ? 0.17 : 0.22), min: S * 0.08, preset: "cut-rise-glyph", leading: 1.05, fill: 0.96, ratio: 1.25, gap: 0.16, stack: true });
+ const headB = head ? head.band : { x: safe.x, y: heroBottom, w: 0, h: 0 };
+
+ const k = c.spread(3.2, 1.6);
+ c.ev("leak", "fade", 0.1, 0.5, "glide");
+ const headPlans = head ? moveLines(c, head, { in: "cut-rise-glyph", at: 0.05, hero: true, loop: "light-sweep", loopAt: 2.2, loopEvery: 1.8 }, "headline", 0.12) : [];
+ const headDone = headPlans.length ? stackLanded(headPlans) : 1.2;
+ c.ev("lit", "fade", headDone - 0.1, 0.7, "glide");
+ c.ev("rule", "draw", headDone, 0.6, "draw");
+ const whenPlan = when ? c.move(when, { in: "word-lift", at: headDone + 0.1 * k }) : null;
+ const placePlan = place ? c.move(place, { in: "fade-rise", at: headDone + 0.25 * k, rate: 34 }) : null;
+ if (cta) c.ev("pill", "pop", headDone + 0.45 * k, 0.5, "pop");
+ const ctaPlan = cta ? c.move(cta, { in: "word-lift", at: headDone + 0.45 * k + 0.08 }) : null;
+ const signPlan = signIn(c, sign, "brand", 0.5);
+ const facts = corners(c, [{ at: "tr", field: "website", text: c.field("website") }], { at: headDone + 0.6 * k, box: { x: safe.x, y: safe.y + Math.max(0, ((sign?.h ?? 0) - S * 0.024) / 2), w: safe.w, h: safe.h } });
+
+ // Warm light on a dark ground; on a light look the words take the ink instead (always readable on the ground).
+ const warm = ensureContrast(mixOk(pal.accent, "#ffb36b", 0.35), pal.ground, 4.5);
+ const heroInk = c.dark ? mixOk(pal.paper, warm, 0.18) : pal.ink;
+ const grade = { dark: mixOk(pal.ground, "#000000", 0.2), light: warm, darkAlpha: 0.3, lightAlpha: 0.08 };
+
+ return {
+ overflow: [...(head?.overflow ? ["headline"] : []), ...(when?.overflow ? ["when"] : []), ...(place?.overflow ? ["place"] : []), ...(cta?.overflow ? ["cta"] : []), ...(sign?.overflow ? ["brand"] : []), ...facts.overflow, ...row.overflow],
+ signature: headDone + 0.4,
+ camera: (t) => ({ x: 0, y: 16 * (1 - Math.min(1, t / c.last)) ** 2 }),
+ grain: 0.07,
+ draw(t, kit) {
+ const field: DisplayNode[] = pic
+ ? [{ type: "rect", x: 0, y: 0, w: design.w, h: design.h, fill: pal.ground }, group([photoNode({ bleed: true, src: "product", img: pic, box: { x: 0, y: 0, w: design.w, h: design.h }, t, duration: c.last, push: { from: 1.0, to: 1.06 }, focus: { x: side ? 0.62 : flip ? 0.9 : 0.72, y: 0.42 }, grade })], { ...(flip && { transform: [-1, 0, 0, 1, design.w, 0] }) }), { type: "rect", x: 0, y: 0, w: design.w, h: design.h, fill: rgba(mixOk(warm, "#ffffff", 0.3), 0.06) }]
+ : meshField(c, t, { glow: warm, glowAlpha: 0.25 });
+ const atmosphere: DisplayNode[] = [
+ side
+ ? { type: "rect", x: 0, y: 0, w: design.w, h: design.h, fill: { kind: "linear", x0: design.w * 0.62, y0: 0, x1: 0, y1: 0, stops: [{ at: 0, color: rgba(pal.ground, 0) }, { at: 0.55, color: rgba(pal.ground, 0.62) }, { at: 1, color: rgba(pal.ground, 0.88) }] } }
+ : fadeScrim(c, pal.ground, 0.36, 0.98, 0.9),
+ { type: "rect", x: 0, y: 0, w: design.w, h: design.h * 0.26, fill: { kind: "linear", x0: 0, y0: 0, x1: 0, y1: design.h * 0.26, stops: [{ at: 0, color: rgba(pal.ground, 0.62) }, { at: 1, color: rgba(pal.ground, 0) }] } },
+ // The left side darkened for the words; the guest stays in the light on the right.
+ ...(side ? [] : [{ type: "rect" as const, x: 0, y: 0, w: design.w, h: design.h, fill: { kind: "linear" as const, x0: 0, y0: 0, x1: design.w * 0.7, y1: 0, stops: [{ at: 0, color: rgba(pal.ground, 0.55) }, { at: 1, color: rgba(pal.ground, 0) }] } }]),
+ ];
+ // A soft local shade behind the top corner's address, so a lit bulb in the photo never sits behind its letters.
+ for (const bx of facts.boxes) atmosphere.push({ type: "rect", x: 0, y: 0, w: design.w, h: design.h, fill: pool(bx.x + bx.w * 0.6, bx.y + bx.h / 2, Math.max(bx.w, S * 0.2) * 0.85, pal.ground, 0.55) });
+ // Warm light from the top-right edge only (never a wash over the face).
+ const lk = kit.P("leak");
+ if (lk > 0) atmosphere.push({ type: "rect", x: 0, y: 0, w: design.w, h: design.h, fill: pool(design.w * 1.02, -design.h * 0.04, Math.max(design.w, design.h) * 0.45, mixOk(warm, "#ff9a5c", 0.4), 0.2 * lk) });
+ const hero: DisplayNode[] = [];
+ if (head) {
+ const nodes = head.sets.flatMap((_, i) => kit.type(headPlans[i], { fill: heroInk, sweep: warm, sweepAlpha: 0.45 }));
+ if (kit.P("lit") > 0) hero.push(...shadowed(c, nodes, head.size, headB, `mq|${head.sets.map((s) => s.text).join("|")}|${head.size}`, kit.P("lit")));
+ hero.push(...nodes);
+ }
+ const overlay: DisplayNode[] = [];
+ const r = kit.P("rule");
+ if (r > 0) overlay.push(rule({ x: safe.x, y: ruleY, w: Math.min(colW, S * 0.5), color: warm, p: r, width: Math.max(1.5, S * 0.0025) }));
+ if (whenPlan) overlay.push(...kit.type(whenPlan, { fill: warm }));
+ if (placePlan) overlay.push(...kit.type(placePlan, { fill: metaInk(pal), caret: warm }));
+ if (cta && ctaPlan && kit.L("pill") > 0) {
+ const p = kit.P("pill");
+ overlay.push(pillOn(cta, kit.type(ctaPlan, { fill: onAccentInk(pal) }), pal.accent, { deg: 0, p }));
+ }
+ const meta = [...signNodes(c, kit, sign, signPlan, "brand", safe.x, safe.y, pal.ink), ...facts.draw(kit, metaInk(pal)), ...row.draw(kit, metaInk(pal), pal.ink)];
+ return [
+ { role: "ground", nodes: field, push: 0 },
+ { role: "atmosphere", nodes: atmosphere, push: 0 },
+ { role: "hero", nodes: hero },
+ { role: "overlay", nodes: overlay },
+ { role: "meta", nodes: meta },
+ ];
+ },
+ };
+ },
+});
diff --git a/src/lib/motion/scenes/marketing/big-number.ts b/src/lib/motion/scenes/marketing/big-number.ts
index 00e9553b..c0a1480f 100644
--- a/src/lib/motion/scenes/marketing/big-number.ts
+++ b/src/lib/motion/scenes/marketing/big-number.ts
@@ -1,58 +1,154 @@
/**
- * Big Number: one stat as big as the frame allows, edge to edge, rolling up figure by figure to the value the person
- * typed (tabular cells, their own separators and signs, in lining figures); the caption rises under it, and the piece
- * ends on the logo (or the brand's name) settling in at the foot. The beats spread over the clip's length.
+ * Big Number: one figure as big as the frame allows, its figures filling the width (the left 58 % column on a wide
+ * frame), rolling up digit by digit to the value the person typed (a short one lands with a stomp). A trailing unit
+ * (×, %, +) is set at 35 % of the figures' height, top-aligned to their cap height, so the number reads first. A
+ * giant filled tonal copy of the figures bleeds off the right edge behind it, on a lit field of the brand's hue. An arc
+ * clear of every figure draws round its top right after it lands and ends in its own arrowhead; the caption cuts up
+ * under a rule. The brand, the address, a corner note and an index sit on the corners. Through the hold the type
+ * plane pushes in and a soft band of light crosses the figures.
*/
-import { about, group, type DisplayNode } from "../../display";
-import { brandMark, centreFigures, counterLayout, counterNode, ev, figureFamily, marketingScene, risingLines, setText, spread, textBlock } from "./kit";
+import { type DisplayNode } from "../../display";
+import { contrastOf, fieldStops, mixOk } from "../../color";
+import { highlighter, rule } from "../../fx/overlays";
+import { marked } from "./kit";
+import { bands, brandSign, capBand, capAt, footRow, ghost, litField, metaInk, posterScene, shadowed, signIn, signNodes, toneOf, withLeadGap, topSite, markColor } from "./poster";
-export default marketingScene({
+/** A figure and its trailing unit ("3×" → "3", "×"; "98%" → "98", "%"); no unit when it doesn't end in one. */
+export function splitUnit(stat: string): [string, string] {
+ const m = /^(.*?\p{Nd}[\p{Nd}.,\s]*)(\s*[^\p{Nd}\s.,][^\p{Nd}]*)$/u.exec(stat);
+ return m && m[2].trim().length <= 3 ? [m[1], m[2]] : [stat, ""];
+}
+
+export default posterScene({
id: "marketing/big-number",
name: "Big Number",
+ pairing: "T7",
look: "brand",
build(c) {
- const { S, safe, palette: pal, design } = c;
- const markH = S * (c.wide ? 0.085 : 0.08);
- const mark = brandMark(c, { maxW: S * 0.5, h: markH, color: pal.ink, minName: 0.04 });
- const footH = mark?.h ?? 0;
- const room = safe.h - (footH ? footH + S * 0.06 : 0);
- const stat = centreFigures(counterLayout("stat", c.field("stat", "0"), figureFamily(c, 800), 800, safe.w, Math.min(S * 0.8, room * 0.58), S * 0.1, c.measure), c.measure);
- const caption = setText(c, c.field("caption"), { weight: 700, width: Math.min(safe.w, S * 1.3), maxLines: 3, max: S * 0.075, min: S * 0.05, lineHeight: 1.12 });
- const statH = stat.size * 1.0;
- const gap = S * 0.04;
- const stackH = statH + (caption ? gap + caption.height : 0);
- const top = safe.y + Math.max(0, (room - stackH) / 2);
- const statLeft = (design.w - stat.width) / 2;
- // The figures' glyphs sit a little low in their line box: lift them so the stack is optically centred.
- const statTop = top - stat.size * 0.06;
- const capB = caption ? textBlock("caption", caption, { y: top + statH + gap, color: pal.ink, cx: design.w / 2 }) : null;
- const footY = safe.y + safe.h - footH;
+ const { S, safe, pal, design } = c;
+ const stat = c.field("stat", "0");
+ const [figs, unit] = splitUnit(stat);
+ const short = [...figs].length <= 3;
+ const signH = S * (c.cover ? 0.058 : 0.046);
+ const sign = brandSign(c, { maxW: S * 0.4, h: signH, x: safe.x, y: safe.y, min: S * (c.cover ? 0.05 : 0.03) });
+ const metaSize = S * (c.cover ? 0.024 : 0.02);
+ const site = topSite(c, sign, metaSize);
+
+ const side = c.wide;
+ const b = bands(c, { topRow: sign?.h ?? metaSize, gap: S * 0.06 });
+ const foot = metaSize * 1.1 + S * 0.05;
+ const numW = side ? safe.w * 0.58 : safe.w;
+ const preset = short ? "stomp" : "odometer";
+ // The caption (its *starred* words get a highlighter): beside it on a wide frame, in the column under the unit when
+ // the figures are short (a big numeral with its line tucked beside it), under it otherwise. Quiet ink, small, so the
+ // figure is twelve times its size or more.
+ const typedCap = marked(c.field("caption"));
+ const capText = typedCap.text;
+ const capSize = S * (c.cover ? 0.042 : 0.038);
+ const gap = S * 0.05;
+ const unitShare = unit ? 0.35 : 0;
+ const setNum = (size: number, y: number) => {
+ const opts = { role: "hero" as const, weight: 800, x: safe.x, y, width: numW * 2, maxLines: 1, max: size, min: size, tabular: true, preset, tracking: -0.01, leading: 0.9 } as const;
+ const n = capAt(c, "stat", figs, opts);
+ if (!n) return null;
+ const u = unit ? capAt(c, "stat", unit.trimStart(), { ...opts, x: n.ink.x + n.ink.w + size * 0.04, max: size * unitShare, min: size * unitShare, tabular: false, preset: "stomp", y: n.lines[0].y + n.cap.top }) : null;
+ return { n, u: u ? withLeadGap(u, unit.slice(0, unit.length - unit.trimStart().length)) : null };
+ };
+ // The size: the widest that fits numW (measured at 100, scaled), held to the room's height.
+ const probe = setNum(100, 0);
+ const probeW = probe ? (probe.u ? probe.u.ink.x + probe.u.ink.w : probe.n.ink.x + probe.n.ink.w) - probe.n.ink.x : 100;
+ const probeFigW = probe ? probe.n.ink.w : 100;
+ const probeCap = probe ? probe.n.cap.bottom - probe.n.cap.top : 70;
+ const roomAll = b.bottom - foot - b.top;
+ const tallSize = Math.min((100 * roomAll * 0.97) / probeCap, (100 * safe.w * 0.68) / Math.max(1, probeW));
+ const besideX = safe.x + (probeFigW * tallSize) / 100 + tallSize * 0.08;
+ const beside = !side && !!capText && (probeW * tallSize) / 100 <= safe.w * 0.72 && safe.x + safe.w - besideX >= safe.w * 0.3;
+ const capX = side ? safe.x + safe.w * 0.64 : beside ? besideX : safe.x;
+ const capW = side ? safe.w * 0.36 : beside ? safe.x + safe.w - besideX : Math.min(safe.w, S * 0.8);
+ let cap = c.set("caption", capText, { role: "body", weight: 500, x: capX, y: 0, width: capW, maxLines: beside ? 5 : 3, max: capSize, min: S * 0.03, leading: 1.18 });
+ const capH = cap && !side && !beside ? capBand(cap).h + gap * 2.4 : 0;
+ const room = roomAll - capH;
+ let size = beside ? tallSize : Math.min((100 * numW * 0.96) / Math.max(1, probeW), (100 * (side ? Math.min(room, design.h * 0.62) : room * 0.95)) / probeCap, S * 1.2);
+ size = Math.max(size, S * 0.12);
+ const capPx = (probeCap * size) / 100;
+ const numTop = side ? b.top + (b.bottom - foot - b.top - capPx) * 0.5 : beside ? b.top + Math.max(0, (roomAll - capPx) * 0.5) : b.top + Math.max(0, Math.min(room - capPx, design.h * 0.42 - capPx / 2 - b.top));
+ const set = setNum(size, numTop);
+ const num = set?.n ?? null;
+ const unitSet = set?.u ?? null;
+ const band = num ? { ...capBand(num), w: (unitSet ? unitSet.ink.x + unitSet.ink.w : num.ink.x + num.ink.w) - num.ink.x } : { x: safe.x, y: numTop, w: 0, h: 0 };
+ const ruleY = band.y + band.h + gap;
+ if (cap) {
+ const y = side || beside ? band.y + band.h - capBand(cap).h : ruleY + gap * 0.9;
+ cap = c.set("caption", capText, { role: "body", weight: 500, x: capX, y: y - (cap.lines[0].y + cap.cap.top), width: capW, maxLines: beside ? 5 : 3, max: cap.size, min: cap.size, leading: 1.18 });
+ }
+ // The starred words' highlighter boxes.
+ const marks: { x: number; w: number; capTop: number; baseline: number; key: string }[] = [];
+ if (cap) {
+ const cs = cap;
+ let at = 0;
+ cs.words.forEach((w, wi) => {
+ at += w.gap.length;
+ const a = at;
+ const e = at + w.text.length;
+ at = e;
+ if (!typedCap.marks.some(([p, q]) => p < e && q > a)) return;
+ const line = cs.lines[w.line];
+ marks.push({ x: w.x, w: w.w, capTop: line.y + cs.cap.top, baseline: line.baseline, key: `c${wi}` });
+ });
+ }
- // Three beats over the clip: the count, the caption, the sign-off.
- const k = spread(c, 1.8, 2.4);
- const lines = caption?.lines.length ?? 0;
- const events = [
- ev("count", "move", 0.12, Math.min(2.4, 1.45 * k), "linear"),
- ev("stat.in", "enter", 0.1, 0.7, "settle"),
- ...Array.from({ length: lines }, (_, i) => ev(`cap.${i}`, "enter", 0.9 * k + i * 0.09, 0.55, "glide", { group: "caption", unit: "elements" })),
- ...(mark ? [ev("mark", "enter", 1.5 * k, 0.6, "settle")] : []),
- ];
+ const k = c.spread(3, 1.6);
+ const numPlan = num ? c.move(num, { in: preset, at: 0.03, hero: true, flash: short, intensity: 1, loop: "light-sweep", loopAt: 1.8, loopEvery: 1.8 }) : null;
+ const numLanded = numPlan?.settled ?? 0.8;
+ const unitPlan = unitSet ? c.move(unitSet, { in: "stomp", at: Math.max(0.1, numLanded - 0.3), intensity: 0.8 }, "stat.unit") : null;
+ const landed = Math.max(numLanded, unitPlan?.settled ?? 0);
+ c.ev("rule", "draw", landed + 0.05, 0.6, "draw");
+ const capPlan = cap ? c.move(cap, { in: "cut-rise", at: landed + 0.2 * k }) : null;
+ const signPlan = signIn(c, sign, "brand", 0.25);
+ const sitePlan = site ? c.move(site, { in: "fade-rise", at: 0.4, rate: 26 }) : null;
+ const row = footRow(c, (capPlan?.settled ?? landed) + 0.1);
+ marks.forEach((_, j) => c.ev(`mark.${j}`, "draw", (capPlan?.settled ?? landed) + 0.05 + 0.1 * j, 0.4, "snap"));
+ // The caption in quiet ink (never the figure's colour): near-black on a light field, paper on a dark one.
+ const grounds = [pal.ground, fieldStops(pal).light, fieldStops(pal).dark];
+ const worst = (ink: string) => Math.min(...grounds.map((g) => contrastOf(ink, g)));
+ const capInk = [mixOk(pal.paper, pal.ground, 0.15), mixOk(pal.night, pal.ground, 0.12), pal.paper, pal.night, "#ffffff", "#000000"].find((x) => worst(x) >= 4.8) ?? (worst("#000000") > worst("#ffffff") ? "#000000" : "#ffffff");
+
+ const stops = fieldStops(pal);
+ const ghostGround = mixOk(stops.dark, stops.light, 0.5);
return {
- events,
- overflow: [...(stat.overflow ? ["stat"] : []), ...(caption?.overflow ? ["caption"] : []), ...(mark?.overflow ? ["brand"] : [])],
- signature: 0.12 + 0.6 * k,
- frame(_t, P, Lp) {
- const nodes: DisplayNode[] = [];
- const lin = Lp("stat.in");
- if (lin > 0) {
- const s = 1.08 - 0.08 * P("stat.in");
- nodes.push(group([counterNode(stat, statLeft, statTop, pal.ink, Lp("count"))], { transform: about(design.w / 2, statTop + stat.size / 2, s), ...(lin < 0.25 && { opacity: lin / 0.25 }) }));
+ overflow: [...(num?.overflow || (probeW * size) / 100 > numW + 1 ? ["stat"] : []), ...(unitSet?.overflow ? ["stat"] : []), ...(cap?.overflow ? ["caption"] : []), ...(sign?.overflow ? ["brand"] : []), ...(site?.overflow ? ["website"] : []), ...row.overflow],
+ signature: landed + 0.3,
+ camera: (t) => ({ x: -20 * (1 - Math.min(1, t / c.last)) ** 2, y: 10 * (1 - Math.min(1, t / c.last)) ** 2 }),
+ draw(t, kit) {
+ const field = litField(c, t, { from: "tl", stops });
+ const atmosphere: DisplayNode[] = [];
+ // The ghost: the figures far bigger than the hero, one faint step from the field, low in the right half so only
+ // its top shows, behind the caption and never level with the hero.
+ const ghosts: DisplayNode[] = num && !beside ? [ghost(c, { field: "stat", lines: [figs], size: num.size * 2.2, x: design.w + num.size * 0.25, align: "right", y: Math.max(design.h * 0.6, band.y + band.h * 0.9), t, ground: ghostGround, weight: 800 })] : [];
+ const hero: DisplayNode[] = [];
+ if (num && numPlan) {
+ const nodes = [...kit.type(numPlan, { fill: pal.ink, sweep: "#ffffff", sweepAlpha: 0.45 }), ...(unitPlan ? kit.type(unitPlan, { fill: pal.ink }) : [])];
+ const pad = num.size * 0.25;
+ if (t >= landed) hero.push(...shadowed(c, nodes, num.size * 0.7, { x: band.x - pad, y: band.y - pad, w: band.w + 2 * pad, h: band.h + 2 * pad }, `bn|${stat}|${num.size}`));
+ hero.push(...nodes);
+ }
+ for (const [j, mk] of marks.entries()) {
+ const hl = highlighter({ capTop: mk.capTop, baseline: mk.baseline, x: mk.x, w: mk.w, color: mixOk(markColor(c, pal.ground, capInk), pal.ground, 0.35), seed: c.seed, p: kit.P(`mark.${j}`), key: mk.key, cover: 0.78, skew: -3 });
+ if (hl) hero.push(hl);
}
- if (capB) nodes.push(...risingLines(capB, (i) => P(`cap.${i}`)));
- if (mark) nodes.push(...mark.draw(design.w / 2, footY, P("mark"), Lp("mark")));
- return { nodes };
+ if (capPlan) hero.push(...kit.type(capPlan, { fill: capInk }));
+ const r = kit.P("rule");
+ const overlay: DisplayNode[] = [...atmosphere, ...(r > 0 && !side && !beside ? [rule({ x: safe.x, y: ruleY, w: Math.min(safe.w, band.w), color: toneOf(pal, 0.5), p: r, width: Math.max(1.25, S * 0.002) })] : [])];
+ const meta: DisplayNode[] = [...signNodes(c, kit, sign, signPlan, "brand", safe.x, safe.y, pal.ink), ...(sitePlan ? kit.type(sitePlan, { fill: metaInk(pal), caret: pal.accent }) : []), ...row.draw(kit, metaInk(pal), pal.ink)];
+ return [
+ { role: "ground", nodes: field },
+ { role: "ghost", nodes: ghosts },
+ { role: "hero", nodes: hero },
+ { role: "overlay", nodes: overlay },
+ { role: "meta", nodes: meta },
+ ];
},
};
},
diff --git a/src/lib/motion/scenes/marketing/drop-countdown.ts b/src/lib/motion/scenes/marketing/drop-countdown.ts
new file mode 100644
index 00000000..216afb76
--- /dev/null
+++ b/src/lib/motion/scenes/marketing/drop-countdown.ts
@@ -0,0 +1,143 @@
+/**
+ * Midnight Drop: a launch countdown. On a lit field of the brand's hue, the drop's name scrambles in as a justified
+ * stack (each line fitted to the width, a short code landing huge) and locks clean, a giant filled copy of its last
+ * line one tone off the field drifting behind. The countdown flips into place tile by tile on tiles a clear step off
+ * the field, over a slit of the brand's light, and then ticks down second by second to exactly what was typed. The
+ * time types on in the top corner, the call to action lands in a pill, and a corner note and the address sit on the
+ * bottom corners.
+ */
+
+import { mixHex, type DisplayNode } from "../../display";
+import { rgba } from "../../fx/background";
+import { rule } from "../../fx/overlays";
+import { chroma as toLabC, contrastOf, ensureContrast, mixOk, toLab, withLightness } from "../../color";
+import { brandSign, capBand, fitLines, footRow, litField, metaInk, moveLines, onBaseline, pillOn, posterScene, shadowed, signIn, signNodes, stackLanded, toneOf, topSite } from "./poster";
+
+export default posterScene({
+ id: "marketing/drop-countdown",
+ name: "Midnight Drop",
+ pairing: "T3",
+ look: "dark",
+ build(c) {
+ const { S, safe, pal, design } = c;
+ const side = c.wide;
+ const signH = S * (c.cover ? 0.058 : 0.046);
+ const sign = brandSign(c, { maxW: S * 0.34, h: signH, x: safe.x, y: safe.y, min: S * (c.cover ? 0.056 : 0.03) });
+ const metaSize = S * (c.cover ? 0.024 : 0.021);
+ const when = topSite(c, sign, metaSize, { field: "when", width: safe.w * 0.6 });
+ const top = safe.y + (sign?.h ?? metaSize) + S * 0.07;
+ const colW = side ? safe.w * 0.6 : safe.w;
+ const ctaSize = S * (c.cover ? 0.056 : 0.044);
+ const footSize = S * (c.cover ? 0.024 : 0.02);
+ const footH = footSize * 1.1 + S * 0.05;
+ const ctaY = safe.y + safe.h - footH - ctaSize * 0.75 - ctaSize * 0.35;
+ const row = footRow(c, 2.2);
+ const site = onBaseline(c, "website", c.field("website"), { role: "meta", x: safe.x + safe.w * 0.4, width: safe.w * 0.48, maxLines: 1, max: footSize, min: footSize * 0.8, align: "right", preset: "fade-rise", y: 0 }, safe.y + safe.h - footSize * 0.25);
+ const cta = c.set("cta", c.field("cta"), { role: "body", weight: 600, x: safe.x + ctaSize * 0.6, y: ctaY, width: safe.w * 0.7, maxLines: 1, max: ctaSize, min: S * 0.034 });
+ const bottom = ctaY - ctaSize * 0.35 - S * 0.08;
+ const room = bottom - top;
+ // The countdown in tiles under the name: a third of the room at most.
+ const countMax = Math.min(S * (side ? 0.12 : 0.16), room * 0.28);
+ // Room between the tiles: each tile pads its figure by 8 % of the size a side, the figures sit 24 % apart.
+ const countTrack = 0.24;
+ const count0 = c.set("count", c.field("count"), { role: "figures", weight: 800, x: safe.x, y: 0, width: colW - countMax * 0.16, maxLines: 1, max: countMax, min: S * 0.06, tabular: true, preset: "split-flap", tracking: countTrack });
+ const countH = count0 ? capBand(count0).h + count0.size * 0.5 : 0;
+ const headRoom = room - countH - S * 0.07;
+ const head = fitLines(c, "headline", c.field("headline"), { x: safe.x, top, room: headRoom, anchor: 0.3, width: colW, maxLines: 3, max: Math.min(S * 0.36, headRoom * 0.5), min: S * 0.1, preset: "scramble", leading: 0.88, fill: 0.98, ratio: 2.2, gap: 0.1, stack: true });
+ const headB = head ? head.band : { x: safe.x, y: top, w: 0, h: 0 };
+ const countY = headB.y + headB.h + S * 0.1 + (count0 ? count0.size * 0.25 : 0);
+ // The row of tiles sits on the grid: the first tile's edge on the inset line.
+ const countOpts = (text: string) => (count0 ? c.set("count", text, { role: "figures", weight: 800, x: safe.x + count0.size * 0.08, y: countY, width: colW - count0.size * 0.16, maxLines: 1, max: count0.size, min: count0.size, tabular: true, preset: "split-flap", tracking: countTrack }) : null);
+ const typedCount = c.field("count");
+ const count = countOpts(typedCount);
+
+ const k = c.spread(3.2, 1.6);
+ const headPlans = head ? moveLines(c, head, { in: "scramble", at: 0.03, hero: true }, "headline", 0.12) : [];
+ const headDone = headPlans.length ? stackLanded(headPlans) : 0.8;
+ c.ev("bars", "hero", 0, 1, "enter");
+ // The clock starts flipping 200 ms after the name lands (nothing of it shows before), a few seconds over what was
+ // typed, then ticks down a second at a time to exactly the typed value, a second before the end.
+ const countAt = headDone + 0.2;
+ // Ticks a second apart on the clip's clock, the last one landing just before the final frame (the poster shows
+ // the typed value, and the clock never sits still for a second before it).
+ const lastTick = c.last - 0.1;
+ const flapDone = countAt + 1.0;
+ const nTicks = Math.max(0, Math.min(4, Math.floor(lastTick - flapDone) + 1));
+ const tail = /^(.*?)(\d{2})$/.exec(typedCount);
+ const ticks = tail && Number(tail[2]) + nTicks <= 59 ? nTicks : 0;
+ const shownAt = (n: number) => (tail ? `${tail[1]}${String(Number(tail[2]) + n).padStart(2, "0")}` : typedCount);
+ const startSet = ticks ? countOpts(shownAt(ticks)) : count;
+ const countPlan = startSet ? c.move(startSet, { in: "split-flap", at: countAt }) : null;
+ const countDone = countPlan?.settled ?? headDone + 0.6;
+ // The ticks: each value drawn from its moment (seconds 47, 46 … then the typed one); laid out once, at rest by then.
+ const tickSets = Array.from({ length: ticks }, (_, i) => {
+ const set = i === ticks - 1 ? count : countOpts(shownAt(ticks - 1 - i));
+ const at = lastTick - (ticks - 1 - i);
+ return set ? { at, plan: c.move(set, { in: "split-flap", at: 0.02 }, `count.tick${i}`) } : null;
+ }).filter((x): x is { at: number; plan: ReturnType<typeof c.move> } => !!x);
+ c.ev("rule", "draw", countDone - 0.1, 0.55, "draw");
+ const whenPlan = when ? c.move(when, { in: "fade-rise", at: countDone + 0.05, rate: 30 }) : null;
+ if (cta) c.ev("pill", "pop", countDone + 0.2 * k, 0.5, "pop");
+ const ctaPlan = cta ? c.move(cta, { in: "word-lift", at: countDone + 0.2 * k + 0.08 }) : null;
+ const signPlan = signIn(c, sign, "brand", 0.2);
+ const sitePlan = site ? c.move(site, { in: "fade-rise", at: countDone + 0.2, rate: 30 }) : null;
+
+ const ghostSize = Math.min(design.h * 0.55, (head?.size ?? S * 0.2) * 2.1);
+ // Tiles a clear step off the ground (ΔL 0.12 or more), away from the figures' ink so the figures read on both halves.
+ const inkLight = toLab(pal.ink).L > 0.6;
+ const tile = c.dark ? withLightness(pal.ground, Math.min(0.45, toLab(pal.ground).L + 0.2)) : mixOk(pal.ground, inkLight ? pal.night : pal.paper, inkLight ? 0.4 : 0.6);
+ // The figures read on the tile's darker lower half too.
+ const countInk = ensureContrast(ensureContrast(pal.ink, mixHex(tile, "#000000", 0.12), 4.6), mixHex(tile, "#ffffff", 0.06), 4.6);
+ // The call to action in the brand's own colour (the most vivid of the kit), words readable on it.
+ const ctaFill = [pal.brand[0], pal.brand[1], pal.accent].sort((a, b) => toLabC(b) - toLabC(a))[0];
+ const ctaInk = ensureContrast([pal.paper, pal.night].sort((a, b) => contrastOf(b, ctaFill) - contrastOf(a, ctaFill))[0], ctaFill, 4.5);
+ const ruleY = count ? capBand(count).y + capBand(count).h + count.size * 0.42 : bottom;
+
+ return {
+ overflow: [...(head?.overflow ? ["headline"] : []), ...(count?.overflow ? ["count"] : []), ...(when?.overflow ? ["when"] : []), ...(cta?.overflow ? ["cta"] : []), ...(sign?.overflow ? ["brand"] : []), ...(site?.overflow ? ["website"] : []), ...row.overflow],
+ signature: headDone + 0.05,
+ camera: (t) => ({ x: 22 * (1 - Math.min(1, t / c.last)) ** 2, y: 0 }),
+ draw(t, kit) {
+ const field = litField(c, t, { from: "bl", light: pal.brand[0], lightAlpha: 0.22 });
+ const b = kit.P("bars");
+ // A slit of the brand's light behind the countdown (one soft band, never stripes).
+ const slitY = count ? capBand(count).y + capBand(count).h / 2 : design.h * 0.6;
+ const slitH = (count?.size ?? S * 0.12) * 1.6;
+ const atmosphere: DisplayNode[] = [{ type: "rect", x: 0, y: slitY - slitH / 2, w: design.w, h: slitH, fill: { kind: "linear", x0: 0, y0: slitY - slitH / 2, x1: 0, y1: slitY + slitH / 2, stops: [{ at: 0, color: rgba(pal.brand[0], 0) }, { at: 0.5, color: rgba(pal.brand[0], 0.42 * b) }, { at: 1, color: rgba(pal.brand[0], 0) }] } }];
+ // No ghost copy of the name (it read as a double of the hero).
+ const ghosts: DisplayNode[] = [];
+ void ghostSize;
+ const hero: DisplayNode[] = [];
+ if (head) {
+ const nodes = head.sets.flatMap((_, i) => kit.type(headPlans[i], { fill: pal.ink }));
+ if (t >= headDone) hero.push(...shadowed(c, nodes, head.size, headB, `md|${head.sets.map((s) => s.text).join("|")}|${head.size}`));
+ hero.push(...nodes);
+ }
+ const tick = [...tickSets].reverse().find((s) => t >= s.at);
+ if (count && (tick || (countPlan && t >= countAt))) {
+ const nodes = tick ? kit.type(tick.plan, { fill: countInk, tile }) : kit.type(countPlan!, { fill: countInk, tile });
+ hero.push(...shadowed(c, nodes, count.size * 0.6, capBand(count), `md-c|${count.size}`, 0.8), ...nodes);
+ }
+ const overlay: DisplayNode[] = [];
+ const r = kit.P("rule");
+ if (r > 0 && count) overlay.push(rule({ x: safe.x, y: ruleY, w: safe.w, color: toneOf(pal, 0.4), p: r }));
+ if (cta && ctaPlan && kit.L("pill") > 0) {
+ const p = kit.P("pill");
+ // A squared tag on the tiles' left edge, level (the clock's own hardware look).
+ overlay.push(pillOn(cta, kit.type(ctaPlan, { fill: ctaInk }), ctaFill, { deg: 0, p }));
+ }
+ const meta: DisplayNode[] = [...signNodes(c, kit, sign, signPlan, "brand", safe.x, safe.y, pal.ink), ...row.draw(kit, metaInk(pal))];
+ if (whenPlan) meta.push(...kit.type(whenPlan, { fill: metaInk(pal), caret: pal.brand[0] }));
+ if (sitePlan) meta.push(...kit.type(sitePlan, { fill: metaInk(pal) }));
+ return [
+ { role: "ground", nodes: field },
+ { role: "atmosphere", nodes: atmosphere },
+ { role: "ghost", nodes: ghosts },
+ { role: "hero", nodes: hero },
+ { role: "overlay", nodes: overlay },
+ { role: "meta", nodes: meta },
+ ];
+ },
+ };
+ },
+});
diff --git a/src/lib/motion/scenes/marketing/editorial-sale.ts b/src/lib/motion/scenes/marketing/editorial-sale.ts
new file mode 100644
index 00000000..a3c3c3fc
--- /dev/null
+++ b/src/lib/motion/scenes/marketing/editorial-sale.ts
@@ -0,0 +1,130 @@
+/**
+ * Season Finale: an editorial sale poster. A fashion photograph fills one side of the page, pushing in slowly under a
+ * light duotone; the sale stomps in as a justified stack in a condensed poster face, every line filling the paper
+ * panel; whole words of it repeat behind in giant filled type one tone off the paper, each row whole across the panel
+ * and drifting up. The offer lands on a skewed highlighter that grows from the left, the call to action lands in a
+ * tilted pill, and the house's name, the corner note and the address sit on the corners.
+ */
+
+import { group, type DisplayNode } from "../../display";
+import { ensureContrast, mixOk } from "../../color";
+import { coverCrop, duotone, pushIn } from "../../fx/photo";
+import { highlighter, rotation } from "../../fx/overlays";
+import { twoShadow } from "../../fx/depth";
+import { brandSign, capBand, corners, fitLines, footRow, ghost, metaInk, moveLines, onAccentInk, paperField, meshField, pillOn, posterScene, rgba, shadowed, signIn, signNodes, stackLanded } from "./poster";
+
+export default posterScene({
+ id: "marketing/editorial-sale",
+ name: "Season Finale",
+ pairing: "T2",
+ look: "light",
+ build(c) {
+ const { S, safe, pal, design } = c;
+ const side = c.wide;
+ const photo = c.recipe.media?.product ? c.input.images?.product : undefined;
+ // The photo: the right half (a little more on a tall frame), edge to edge.
+ const pw = Math.round(design.w * (side ? 0.46 : 0.45));
+ const panel = { x: design.w - pw, y: 0, w: pw, h: design.h };
+ const signH = S * (c.cover ? 0.064 : 0.048);
+ const sign = brandSign(c, { maxW: S * 0.32, h: signH, x: safe.x, y: safe.y, min: S * (c.cover ? 0.056 : 0.03) });
+ const top = safe.y + (sign?.h ?? 0) + S * 0.06;
+ const ctaSize = S * (c.cover ? 0.054 : 0.044);
+ const footSize = S * (c.cover ? 0.024 : 0.02);
+ const footH = footSize * 1.1 + S * 0.05;
+ const ctaY = safe.y + safe.h - footH - ctaSize * 1.05 - ctaSize * 0.35;
+ const leftBox = { x: safe.x, y: safe.y, w: design.w - pw - safe.x - S * 0.03, h: safe.h };
+ const row = footRow(c, 2.4, { arrow: false, box: leftBox });
+ const ctaOpts = { role: "body" as const, weight: 700, x: safe.x + ctaSize * 0.6, width: safe.w * 0.55, maxLines: 1, max: ctaSize, min: S * 0.032 };
+ const cta0 = c.set("cta", c.field("cta"), { ...ctaOpts, y: ctaY });
+ const offerSize = S * (c.cover ? 0.062 : 0.05);
+ // The hero takes the room above the offer and the pill, every line ending before the photo's edge (never on a face).
+ const heroW = panel.x - safe.x - S * 0.035;
+ const roomBottom = ctaY - ctaSize * 0.35 - S * 0.06 - offerSize * 1.6 - S * 0.05;
+ const head = fitLines(c, "headline", c.field("headline"), { x: safe.x, top, room: roomBottom - top, centre: Math.min(design.h * 0.42, (top + roomBottom) / 2), width: heroW, maxLines: 3, max: S * 0.42, min: S * 0.1, preset: "stomp", leading: 0.86, fill: 0.97, ratio: 1.3, gap: 0.07, stack: true });
+ const headB = head ? head.band : { x: safe.x, y: top, w: 0, h: 0 };
+ const offerY = headB.y + headB.h + S * 0.07;
+ // The offer on the text's own margin (its bar bleeds a little to the left), the call to action close under it.
+ const offer = c.set("offer", c.field("offer"), { role: "accent", x: safe.x, y: offerY, width: safe.w * 0.7, maxLines: 2, max: offerSize, min: S * 0.032, preset: "bar-swipe" });
+ const offerBottom = offer ? offer.lines[offer.lines.length - 1].baseline + offer.size * 0.3 : headB.y + headB.h;
+ const cta = cta0 ? (c.set("cta", c.field("cta"), { ...ctaOpts, max: cta0.size, min: cta0.size, y: Math.min(ctaY, offerBottom + S * 0.09) }) ?? cta0) : null;
+
+ const k = c.spread(3, 1.6);
+ c.ev("photo", "hero", 0, 0.9, "enter");
+ const headPlans = head ? moveLines(c, head, { in: "stomp", at: 0.05, hero: true, flash: true }, "headline", 0.14) : [];
+ const headDone = headPlans.length ? stackLanded(headPlans) : 1;
+ c.ev("bar", "draw", headDone + 0.05, 0.28, "snap");
+ const offerPlan = offer ? c.move(offer, { in: "word-lift", at: headDone + 0.15 }) : null;
+ if (cta) c.ev("pill", "pop", headDone + 0.35 * k, 0.5, "pop");
+ const ctaPlan = cta ? c.move(cta, { in: "word-lift", at: headDone + 0.35 * k + 0.08 }) : null;
+ c.ev("arrow", "draw", headDone + 0.5 * k, 0.5, "draw");
+ const signPlan = signIn(c, sign, "brand", 0.2);
+
+ const offerB = offer ? capBand(offer) : null;
+ const ghostWord = c.field("headline").split(/\s+/).pop() ?? "";
+ // The ghost word whole across the paper panel (its width 92 % of the panel), rows down the page.
+ const panelW = panel.x;
+ const g100 = ghostWord ? c.measure(ghostWord, `${c.pairing.hero.weight} 100px "${c.pairing.hero.family}"`) : 100;
+ const ghostSize = Math.min(design.h * 0.4, (100 * panelW * 0.92) / Math.max(1, g100));
+ // A fact on the photo's foot, over a soft scrim.
+ const facts = corners(c, [{ at: "br", field: "website", text: c.field("website") }], { at: headDone + 0.6 * k, box: { x: panel.x + S * 0.04, y: safe.y, w: safe.x + safe.w - panel.x - S * 0.04, h: safe.h }, width: safe.x + safe.w - panel.x - S * 0.04 });
+ const factInk = pal.paper;
+
+ return {
+ overflow: [...(head?.overflow ? ["headline"] : []), ...(offer?.overflow ? ["offer"] : []), ...(cta?.overflow ? ["cta"] : []), ...(sign?.overflow ? ["brand"] : []), ...facts.overflow, ...row.overflow],
+ signature: headDone + 0.1,
+ camera: (t) => ({ x: -18 * (1 - Math.min(1, t / c.last)) ** 2, y: 0 }),
+ draw(t, kit) {
+ const field = c.dark ? meshField(c, t) : paperField(c, t, { tint: pal.brand[1], light: 0.4 });
+ const rows = Math.ceil(design.h / (ghostSize * 1.02)) + 1;
+ // The ghost rows show only above and below the headline's band and below the wordmark (never a double image of the
+ // hero, never under the brand).
+ const rowsN: DisplayNode[] = ghostWord ? Array.from({ length: rows }, (_, i) => ghost(c, { field: "headline", lines: [ghostWord], size: ghostSize, x: panelW * 0.04, y: -ghostSize * 0.35 + i * ghostSize * 1.02, t, vertical: true, dir: 1, step: 0.6 })) : [];
+ const clearTop = safe.y + (sign?.h ?? 0) + S * 0.04;
+ const bandTop = headB.y - S * 0.04;
+ const bandBottom = offerBottom + S * 0.03;
+ // (the room above only when a row can show there whole enough to read as type, never a sliver)
+ const zone = `${bandTop - clearTop >= ghostSize * 0.7 ? `M0 ${clearTop}H${panelW}V${bandTop}H0Z ` : ""}M0 ${bandBottom}H${panelW}V${design.h}H0Z`;
+ const ghosts: DisplayNode[] = rowsN.length ? [group(rowsN, { clip: { type: "path", d: zone } })] : [];
+ const subject: DisplayNode[] = [];
+ const pl = kit.L("photo");
+ if (pl > 0) {
+ // A mask wipes the photo open from the seam outwards (never a fade), graded, pushing in slowly.
+ const p = kit.P("photo");
+ const box = panel;
+ const shown = { ...panel, w: pw * p };
+ const content: DisplayNode[] = photo
+ ? [{ type: "image", bleed: true, src: "product", ...box, crop: coverCrop(photo, box, { x: 0.5, y: 0.42 }, pushIn(t, c.last, { from: 1.0, to: 1.06 }).zoom) }, ...duotone(box, { dark: mixOk(pal.brand[0], "#000000", 0.2), light: pal.brand[1], darkAlpha: 0.25, lightAlpha: 0.12 }), { type: "rect", x: box.x, y: box.y + box.h * 0.68, w: box.w, h: box.h * 0.32, fill: { kind: "linear", x0: 0, y0: box.y + box.h * 0.68, x1: 0, y1: box.y + box.h, stops: [{ at: 0, color: rgba(pal.night, 0) }, { at: 1, color: rgba(pal.night, 0.62) }] } }]
+ : [{ type: "rect", ...box, fill: { kind: "linear", x0: 0, y0: 0, x1: 0, y1: design.h, stops: [{ at: 0, color: mixOk(pal.brand[1], pal.ground, 0.2) }, { at: 1, color: mixOk(pal.brand[1], "#000000", 0.3) }] } }];
+ subject.push(group([...twoShadow({ nodes: [{ type: "rect", ...shown, fill: "#000" }], size: S * 0.5, ground: pal.ground, bounds: shown, key: `sf|${shown.w.toFixed(0)}x${design.h}` }), group(content, { clip: { type: "rect", ...shown }, isolate: box })]));
+ // The seam: a paper keyline down the photo's edge.
+ subject.push({ type: "rect", x: panel.x - Math.max(1, S * 0.002), y: 0, w: Math.max(2, S * 0.004), h: design.h, fill: pal.paper, opacity: Math.min(1, pl * 2) });
+ }
+ const heroWords: DisplayNode[] = head ? head.sets.flatMap((_, i) => kit.type(headPlans[i], { fill: pal.ink })) : [];
+ const hero: DisplayNode[] = head && t >= headDone ? [...shadowed(c, heroWords, head.size, headB, `sf|${head.sets.map((s) => s.text).join("|")}|${head.size}`, 0.7), ...heroWords] : heroWords;
+ const overlay: DisplayNode[] = [];
+ const bp = kit.P("bar");
+ // The offer's highlighter: skewed −3°, its edges a little uneven, growing from the left; taller than the words.
+ if (offer && offerB && bp > 0) {
+ // Tilted -2.5° with the words on it, overrunning them by 0.15 em a side.
+ const hl = highlighter({ capTop: offerB.y, baseline: offerB.y + offerB.h + offerB.h * 0.3, x: offerB.x - offer.size * 0.03, w: offerB.w + offer.size * 0.06, color: pal.accent, seed: c.seed, p: bp, cover: 1.5, skew: 0, key: "offer" });
+ const cx = offerB.x + offerB.w / 2;
+ const cy = offerB.y + offerB.h / 2;
+ const words = offerPlan && bp >= 1 ? kit.type(offerPlan, { fill: onAccentInk(pal) }) : [];
+ // (a plain block of the bar's colour inside it, under the words, so what is behind them is the bar itself)
+ const under: DisplayNode[] = bp >= 1 ? [{ type: "rect", x: offerB.x, y: offerB.y - offerB.h * 0.05, w: offerB.w, h: offerB.h * 1.1, fill: pal.accent }] : [];
+ if (hl) overlay.push(group([hl, ...under, ...words], { transform: rotation(-2.5, cx, cy) }));
+ }
+ if (cta && ctaPlan && kit.L("pill") > 0) overlay.push(pillOn(cta, kit.type(ctaPlan, { fill: ensureContrast(pal.ground, pal.ink, 4.5) }), pal.ink, { deg: 0, p: kit.P("pill") }));
+ const meta = [...signNodes(c, kit, sign, signPlan, "brand", safe.x, safe.y, pal.ink), ...facts.draw(kit, factInk), ...row.draw(kit, metaInk(pal))];
+ return [
+ { role: "ground", nodes: field },
+ { role: "ghost", nodes: ghosts },
+ { role: "subject", nodes: subject, push: 0 },
+ { role: "hero", nodes: hero },
+ { role: "overlay", nodes: overlay },
+ { role: "meta", nodes: meta },
+ ];
+ },
+ };
+ },
+});
diff --git a/src/lib/motion/scenes/marketing/feature-cards.ts b/src/lib/motion/scenes/marketing/feature-cards.ts
index 5d55bb34..4f1155b6 100644
--- a/src/lib/motion/scenes/marketing/feature-cards.ts
+++ b/src/lib/motion/scenes/marketing/feature-cards.ts
@@ -1,121 +1,154 @@
/**
- * Feature Cards: the headline rises, then up to three rounded cards fly in from near the camera (bigger, tilted, from
- * below) and settle into a stack, one beat apart, each ticking its check as it lands; the headline drifts less than the
- * cards, so the stack reads in depth, and the camera keeps a slow drift the whole clip long. The brand signs off at the
- * foot (its logo, else its name). Each card carries one benefit, set exactly as typed, its lines kept even. A tall frame
- * stacks them, bigger, and centres the whole; a wide one sets them side by side.
+ * Feature Cards: a big headline set as a justified stack (each line fitted to the width, broken after its clause),
+ * cutting up line by line; then three numbered benefits land one after another. The numbers are the design: 01 02 03
+ * in the hero face down the left, each with a rule drawing out to its card. The cards are one system: frosted glass
+ * with a bright top edge and a contact and an ambient shadow, each as wide as its words, the first a few degrees off
+ * true, sliding in from the right with its benefit riding inside (never over its number). A lit two-tone field of
+ * the brand's hue sits under everything; the brand, the address, a corner note and an index arrow sit on the corners.
+ * Through the hold the type plane pushes in.
*/
-import { about, group, multiply, translate, type DisplayNode } from "../../display";
-import { lineRuns } from "../end-card/shared";
-import { brandMark, ev, marketingScene, MIN_BODY, MIN_HEAD, risingLines, setText, shadowOf, spread, textBlock } from "./kit";
-import type { TextLayout } from "../../layout";
+import { group, type DisplayNode } from "../../display";
+import { contrastOf, fieldStops, mixOk } from "../../color";
+import { twoShadow } from "../../fx/depth";
+import { rotation } from "../../fx/overlays";
+import { asDecor, bands, brandSign, capBand, fitLines, footRow, ghost, litField, metaInk, moveLines, posterScene, signIn, signNodes, stackLanded, topSite } from "./poster";
+import type { TypePlan } from "../../type/animate";
+import type { TypeSet } from "../../type/glyphs";
+import { fontOf } from "../../type/faces";
-export const FEATURE_FIELDS = ["point1", "point2", "point3"] as const;
+interface Card {
+ i: number;
+ x: number;
+ y: number;
+ w: number;
+ h: number;
+ deg: number;
+ set: TypeSet;
+}
-export default marketingScene({
+/** Each card swings in from a slight tilt (alternating) and settles level: never tilted at rest. */
+const TILTS = [-3, 2, -1.5];
+
+export default posterScene({
id: "marketing/feature-cards",
name: "Feature Cards",
- look: "light",
+ pairing: "T7",
+ look: "brand",
build(c) {
- const { S, safe, palette: pal, design } = c;
- const row = c.wide;
- // A tall frame has room to spare: everything a size up.
- // Set at a scale (a tall frame has room to spare: everything a size up), then a step down while the whole does not
- // fit over the sign-off.
- const points = FEATURE_FIELDS.map((f) => ({ field: f, text: c.field(f) })).filter((p) => p.text);
- const set = (g: number) => {
- const head = setText(c, c.field("headline"), { weight: 800, width: row ? Math.min(safe.w, S * 1.4) : safe.w, maxLines: c.tall ? 3 : 2, max: S * (row ? 0.085 : 0.1 * g), min: S * MIN_HEAD, lineHeight: 1.06 });
- // The brand signs the stack off at the foot.
- const mark = brandMark(c, { maxW: S * (row ? 0.36 : 0.52), h: S * (row ? 0.07 : 0.08 * g), color: pal.ink, minName: 0.04 });
- const footH = mark ? mark.h + S * 0.055 : 0;
- const pad = S * 0.042 * g;
- const badge = S * 0.074 * g;
- const gap = S * (row ? 0.032 : 0.03 * g);
- const cardW = row ? (safe.w - gap * (Math.max(1, points.length) - 1)) / Math.max(1, points.length) : Math.min(safe.w, S * 0.96);
- const textW = row ? cardW - 2 * pad : cardW - 3 * pad - badge;
- const texts: { field: string; L: TextLayout | null }[] = points.map((p) => ({ field: p.field, L: setText(c, p.text, { family: "body", weight: 700, width: textW, maxLines: row ? 4 : 2, max: S * 0.05 * g, min: S * MIN_BODY, lineHeight: 1.22 }) }));
- const textHs = texts.map((t) => t.L?.height ?? 0);
- const cardH = row ? badge + pad * 0.7 + Math.max(0, ...textHs) + 2 * pad : 0;
- const heights = texts.map((_, i) => (row ? cardH : Math.max(badge, textHs[i]) + 2 * pad));
- const stackH = row ? cardH : heights.reduce((s, h) => s + h, 0) + gap * Math.max(0, heights.length - 1);
- const headGap = S * 0.07 * g;
- const total = (head ? head.height + headGap : 0) + stackH;
- return { g, head, mark, footH, pad, badge, gap, cardW, textW, texts, cardH, heights, headGap, total };
- };
- let L = set(c.tall ? 1.22 : 1);
- for (let i = 0; i < 4 && L.total + L.footH > safe.h; i++) L = set(L.g * 0.9);
- const { head, mark, footH, pad, badge, gap, cardW, textW, texts, cardH, heights, headGap, total, g } = L;
- // Centred in what the sign-off leaves.
- const top = safe.y + Math.max(0, (safe.h - footH - total) / 2);
- const footY = safe.y + safe.h - (mark?.h ?? 0);
- const headB = head ? textBlock("headline", head, { y: top, color: pal.ink, cx: design.w / 2 }) : null;
- let y = top + (head ? head.height + headGap : 0);
- const left0 = row ? safe.x : (design.w - cardW) / 2;
- const cards = texts.map((t, i) => {
- const box = row ? { x: left0 + i * (cardW + gap), y, w: cardW, h: cardH } : { x: left0, y, w: cardW, h: heights[i] };
- if (!row) y += heights[i] + gap;
- const bx = box.x + pad + badge / 2;
- const by = row ? box.y + pad + badge / 2 : box.y + box.h / 2;
- const tx = row ? box.x + pad : box.x + 2 * pad + badge;
- const ty = row ? box.y + pad + badge + pad * 0.7 : box.y + (box.h - (t.L?.height ?? 0)) / 2;
- const block = t.L ? textBlock(t.field, t.L, { y: ty, color: pal.surfaceInk, left: tx, width: textW }) : null;
- return { box, badge: { cx: bx, cy: by, r: badge / 2 }, block };
+ const { S, safe, pal, design } = c;
+ const side = c.wide;
+ const signH = S * (c.cover ? 0.058 : 0.046);
+ const sign = brandSign(c, { maxW: S * 0.36, h: signH, x: safe.x, y: safe.y, min: S * (c.cover ? 0.05 : 0.03) });
+ const metaSize = S * (c.cover ? 0.024 : 0.02);
+ const site = topSite(c, sign, metaSize);
+ const b = bands(c, { topRow: sign?.h ?? metaSize, gap: S * 0.06 });
+ const foot = metaSize * 1.1 + S * 0.05;
+ const bottom = b.bottom - foot;
+ const points = ["point1", "point2", "point3"].map((k) => ({ key: k, text: c.field(k) })).filter((p) => p.text);
+ const n = Math.max(1, points.length);
+ const headW = side ? safe.w * 0.44 : safe.w;
+ // The cards keep room for their words at a readable size; the headline takes the rest.
+ const minCard = S * 0.1;
+ const cardRoom = side ? 0 : n * minCard + (n - 1) * S * 0.03 + S * 0.07;
+ const head = fitLines(c, "headline", c.field("headline"), { x: safe.x, top: b.top, room: side ? bottom - b.top : bottom - b.top - cardRoom, anchor: side ? 0.45 : 0, width: headW, maxLines: 3, max: S * (side ? 0.18 : 0.26), min: S * 0.07, preset: "cut-rise", fill: 0.98, ratio: 1.5, gap: 0.14, stack: true });
+ const headBottom = head ? head.band.y + head.band.h + head.size * 0.25 : b.top;
+ const colX = side ? safe.x + safe.w * 0.5 : safe.x;
+ const colW = side ? safe.w * 0.5 : safe.w;
+ const cardsTop = side ? b.top : headBottom + S * 0.07;
+ const gapY = S * 0.03;
+ const cardH = Math.min(S * 0.15, Math.max(minCard, (bottom - cardsTop - gapY * (n - 1)) / n));
+ // The cards spread down to the foot (their gaps open up when there's room).
+ const spread = side ? gapY : Math.max(gapY, Math.min(S * 0.08, (bottom - cardsTop - n * cardH) / Math.max(1, n - 1)));
+ const numSize = Math.min(cardH * 0.7, S * 0.13);
+ const numFont = fontOf(c.pairing.hero.family, numSize, c.pairing.hero.weight);
+ const numW = Math.max(c.measure("00", numFont), c.measure("03", numFont)) + S * 0.04;
+ const cardX = colX + numW;
+ const padX = S * 0.045;
+ const pointMax = Math.min(S * (c.cover ? 0.05 : 0.045), cardH * 0.3);
+ const cards: Card[] = [];
+ points.forEach((p, i) => {
+ const y = cardsTop + i * (cardH + spread);
+ const maxW = colW - numW;
+ const textX = cardX + padX;
+ const opts = { role: "body" as const, weight: 600, x: textX, width: maxW - 2 * padX, maxLines: 2, min: S * 0.03, leading: 1.15, tracking: 0, preset: "word-lift" as const };
+ const set = c.set(p.key, p.text, { ...opts, y: 0, max: pointMax });
+ if (!set) return;
+ const h = capBand(set).h;
+ const placed = c.set(p.key, p.text, { ...opts, y: y + (cardH - h) / 2 - set.cap.top, max: set.size, min: set.size })!;
+ // One width for every card (the column's), the words flush left inside.
+ const w = maxW;
+ cards.push({ i, x: cardX, y, w, h: cardH, deg: TILTS[i] ?? 0, set: placed });
+ });
+
+ const k = c.spread(3.2, 1.6);
+ const headPlans = head ? moveLines(c, head, { in: "cut-rise", at: 0.03, hero: true }, "headline", 0.12) : [];
+ const headDone = headPlans.length ? stackLanded(headPlans) : 0.6;
+ // Each card enters as one piece with its words already in it (never an empty box), a short slide from the right
+ // that swings level; they follow one another closely.
+ const cardAt = (i: number) => Math.max(0.5, headDone - 0.3) + i * 0.1 * k;
+ cards.forEach((_, i) => {
+ c.ev(`card.${i}`, "enter", cardAt(i), 0.4, "settle");
+ c.ev(`num.${i}`, "enter", cardAt(i) - 0.05, 0.45, "glide");
});
+ const cardPlans: TypePlan[] = cards.map((cd, i) => c.move(cd.set, { in: "fade-rise", at: cardAt(i), intensity: 0 }, `${cd.set.field}`));
+ const lastCard = cardPlans.length ? Math.max(...cardPlans.map((p) => p.settled)) : headDone;
+ const signPlan = signIn(c, sign, "brand", 0.2);
+ const sitePlan = site ? c.move(site, { in: "fade-rise", at: 0.35, rate: 26 }) : null;
+ const row = footRow(c, lastCard + 0.1);
- // The beats, spread over the length: the headline, the cards one by one, the sign-off.
- const k = spread(c, 2.6);
- const lines = head?.lines.length ?? 0;
- const cardAt = 0.15 + (lines ? 0.35 + lines * 0.09 : 0) * k;
- const fly = 0.62;
- const each = Math.min(0.45, 0.14 * k * k);
- const landed = cardAt + each * Math.max(0, cards.length - 1) + fly;
- const events = [
- ...Array.from({ length: lines }, (_, i) => ev(`head.${i}`, "enter", 0.15 + i * 0.09, 0.55, "glide", { group: "head", unit: "elements" })),
- ...cards.map((_, i) => ev(`card.${i}`, "enter", cardAt + i * each, fly, "enter")),
- ...cards.map((_, i) => ev(`check.${i}`, "draw", cardAt + i * each + fly * 0.7, 0.35, "draw")),
- ev("pan", "camera", 0, c.last, "drift"),
- ...(mark ? [ev("brand", "enter", landed + 0.25 * k, 0.6, "glide")] : []),
- ];
- const tilt = (i: number) => (i % 2 ? 0.07 : -0.08);
- const shadow = shadowOf(pal.ground, pal.look === "light" ? 0.1 : 0.32);
- const radius = S * 0.034 * g;
+ const frosted = pal.look !== "light";
+ const glass = frosted ? "rgba(255,255,255,0.1)" : mixOk(pal.paper, "#ffffff", 0.7);
+ const edge = frosted ? "rgba(255,255,255,0.4)" : mixOk(pal.brand[0], pal.paper, 0.6);
+ const stops = fieldStops(pal);
+ // Paper on the frosted glass where it reads at 4.5:1, else the kit's ink.
+ const textInk = frosted && contrastOf(pal.paper, mixOk(pal.ground, "#ffffff", 0.12)) >= 4.5 ? pal.paper : pal.ink;
+ // Where each numeral's capitals sit in its em box (to centre the card on them).
+ const numBox = c.measure.box?.("03", numFont);
+ const numMid = numBox ? (numBox.top + numBox.bottom) / 2 : numSize * 0.55;
+ const count = String(cards.length).padStart(2, "0");
return {
- events,
- overflow: [...(head?.overflow ? ["headline"] : []), ...(mark?.overflow ? ["brand"] : []), ...texts.filter((t) => t.L?.overflow).map((t) => t.field)],
- signature: cardAt + each + fly * 0.45,
- frame(_t, P, Lp) {
- // The slow drift: the cards travel a little farther than the headline (depth), home on the last frame.
- const pan = (1 - P("pan")) * S * 0.05;
- const nodes: DisplayNode[] = [];
- if (headB) nodes.push(group(risingLines(headB, (i) => P(`head.${i}`)), { transform: translate(pan * 0.35, 0) }));
- cards.forEach((card, i) => {
- const q = P(`card.${i}`);
- const lin = Lp(`card.${i}`);
- if (lin <= 0) return;
- const { box } = card;
- const ccx = box.x + box.w / 2;
- const ccy = box.y + box.h / 2;
- const u = 1 - q;
- // From near the camera: bigger, tilted, from below (beside, on a wide frame), then down into the stack.
- const m = multiply(translate(pan + (row ? 0 : u * S * 0.05 * (i % 2 ? 1 : -1)), u * S * (row ? 0.22 : 0.3)), about(ccx, ccy, 1 + 0.16 * u, tilt(i) * u));
- const check = P(`check.${i}`);
- const r = card.badge.r;
- const children: DisplayNode[] = [
- { type: "rect", x: box.x, y: box.y + S * 0.014 + u * S * 0.02, w: box.w, h: box.h, r: radius, fill: shadow },
- { type: "rect", x: box.x, y: box.y, w: box.w, h: box.h, r: radius, fill: pal.surface },
- { type: "ellipse", cx: card.badge.cx, cy: card.badge.cy, rx: r, ry: r, fill: pal.highlight.fill },
- ];
- if (check > 0) {
- const d = `M${card.badge.cx - r * 0.42} ${card.badge.cy + r * 0.02}L${card.badge.cx - r * 0.1} ${card.badge.cy + r * 0.34}L${card.badge.cx + r * 0.45} ${card.badge.cy - r * 0.3}`;
- children.push({ type: "path", d, stroke: { paint: pal.highlight.ink, width: r * 0.2, trim: check, length: r * 1.3, cap: "round", join: "round" } });
+ overflow: [...(head?.overflow ? ["headline"] : []), ...cards.filter((cd) => cd.set.overflow).map((cd) => cd.set.field), ...(sign?.overflow ? ["brand"] : []), ...(site?.overflow ? ["website"] : []), ...row.overflow],
+ signature: cardAt(1) + 0.5,
+ camera: (t) => ({ x: 0, y: 24 * (1 - Math.min(1, t / c.last)) ** 2 }),
+ draw(t, kit) {
+ const field = litField(c, t, { from: "tr", stops, light: mixOk(pal.brand[1], "#ffffff", 0.3), lightAlpha: 0.2 });
+ // Behind the cards: the count as a giant tonal numeral bleeding off the right edge, so the glass has depth.
+ const ghosts: DisplayNode[] = cards.length && !side ? [ghost(c, { field: "index", lines: [count], size: cardH * 2.6, x: design.w + cardH * 0.25, align: "right", y: cards[0].y - cardH * 0.2, t, weight: c.pairing.hero.weight })] : [];
+ const hero: DisplayNode[] = head ? head.sets.flatMap((_, i) => kit.type(headPlans[i], { fill: pal.ink })) : [];
+ const subject: DisplayNode[] = [];
+ const numerals: DisplayNode[] = [];
+ cards.forEach((cd, i) => {
+ // The number in the hero face, rising into place, a rule drawing out from it to the card.
+ const nl = kit.L(`num.${i}`);
+ if (nl > 0) {
+ const np = kit.P(`num.${i}`);
+ const label = String(i + 1).padStart(2, "0");
+ const ny = cd.y + cd.h / 2 - numMid;
+ numerals.push(group(asDecor([{ type: "text", field: `index.${i}`, runs: [{ text: label, gap: "", font: numFont, x: colX, y: ny, fill: pal.accent }] }]), { transform: [1, 0, 0, 1, 0, (1 - np) * numSize * 0.4], clip: { type: "rect", x: colX - S * 0.02, y: ny - numSize * 0.1, w: numW + S * 0.04, h: numSize * 1.25 } }));
}
- if (card.block) children.push(lineRuns(card.block));
- nodes.push(group(children, { transform: m, ...(lin < 0.3 && { opacity: lin / 0.3 }) }));
+ const lin = kit.L(`card.${i}`);
+ if (lin <= 0) return;
+ const p = kit.P(`card.${i}`);
+ // In from the right, a short way (never across its number), its words riding inside.
+ const dx = (1 - p) * cd.w * 0.12;
+ const box = { x: cd.x, y: cd.y, w: cd.w, h: cd.h };
+ const plate: DisplayNode = { type: "rect", ...box, r: S * 0.026, fill: glass, stroke: { paint: edge, width: Math.max(1, S * 0.0015) } };
+ const sheen: DisplayNode = { type: "rect", ...box, r: S * 0.026, fill: { kind: "linear", x0: box.x, y0: box.y, x1: box.x + box.w * 0.35, y1: box.y + box.h, stops: [{ at: 0, color: frosted ? "rgba(255,255,255,0.14)" : "rgba(255,255,255,0.6)" }, { at: 0.45, color: "rgba(255,255,255,0)" }, { at: 1, color: "rgba(255,255,255,0)" }] } };
+ const words = kit.type(cardPlans[i], { fill: textInk });
+ const shadows = twoShadow({ nodes: [{ ...plate, fill: "#000000" }], size: cd.h, ground: pal.ground, bounds: box, key: `fc|${cd.w.toFixed(0)}x${cd.h.toFixed(0)}` });
+ const rot = rotation(cd.deg * (1 - p), cd.x + cd.w / 2, cd.y + cd.h / 2);
+ subject.push(group([...shadows, plate, sheen, ...words], { transform: dx ? [rot[0], rot[1], rot[2], rot[3], rot[4] + dx, rot[5]] : rot, ...(lin < 0.15 && { opacity: lin / 0.15 }) }));
});
- if (mark) nodes.push(...mark.draw(design.w / 2, footY, P("brand"), Lp("brand")));
- return { nodes };
+ const meta = [...signNodes(c, kit, sign, signPlan, "brand", safe.x, safe.y, pal.ink), ...(sitePlan ? kit.type(sitePlan, { fill: metaInk(pal), caret: pal.accent }) : []), ...row.draw(kit, metaInk(pal), pal.ink)];
+ return [
+ { role: "ground", nodes: field },
+ { role: "ghost", nodes: asDecor(ghosts) },
+ { role: "hero", nodes: [...hero, ...numerals] },
+ { role: "overlay", nodes: subject },
+ { role: "meta", nodes: meta },
+ ];
},
};
},
diff --git a/src/lib/motion/scenes/marketing/fragrance-reveal.ts b/src/lib/motion/scenes/marketing/fragrance-reveal.ts
new file mode 100644
index 00000000..2b29da6a
--- /dev/null
+++ b/src/lib/motion/scenes/marketing/fragrance-reveal.ts
@@ -0,0 +1,136 @@
+/**
+ * Nocturne: a fragrance reveal. Two ribbons of light cross a night field, a spot opens from above, and the bottle
+ * rises into its pool of light over a soft reflection; a band of light crosses the glass once. The name cuts up in a
+ * fine display serif, the line drifts in under it, the call to action settles under a hairline, and the house signs
+ * at the top. Everything readable sits in the safe area; the bottle and its light may run lower.
+ */
+
+import { group, type DisplayNode } from "../../display";
+import { mixOk } from "../../color";
+import { pool, rgba } from "../../fx/background";
+import { floorShadow } from "../../fx/depth";
+import { product as productNode } from "../../fx/photo";
+import { rule } from "../../fx/overlays";
+import { fitBox, logoNode } from "./kit";
+import { brandSign, capBand, footRow, glowAtmosphere, litField, metaInk, onBaseline, posterScene, signIn, signNodes } from "./poster";
+
+export default posterScene({
+ id: "marketing/fragrance-reveal",
+ name: "Nocturne",
+ pairing: "T4",
+ look: "dark",
+ build(c) {
+ const { S, safe, pal, design } = c;
+ const side = c.wide;
+ const cx = design.w / 2;
+ const prod = c.recipe.media?.product ? c.input.images?.product : undefined;
+ const signH = S * (c.cover ? 0.06 : 0.05);
+ const textX = side ? safe.x + safe.w * 0.5 : safe.x;
+ const textW = side ? safe.w * 0.5 : safe.w;
+ const align = side ? "left" : "centre";
+ const sign0 = brandSign(c, { maxW: S * 0.4, h: signH, x: textX, y: safe.y, align, min: S * (c.cover ? 0.056 : 0.03) });
+ const sign = sign0?.set && !side ? brandSign(c, { maxW: S * 0.4, h: signH, x: cx - S * 0.2, y: safe.y, align: "centre", min: S * (c.cover ? 0.056 : 0.03) }) : sign0;
+ const top = safe.y + (sign?.h ?? 0) + S * 0.06;
+ const head = c.set("headline", c.field("headline"), { role: "hero", x: textX, y: top, width: textW, maxLines: 2, max: S * (side ? 0.17 : 0.24), min: S * 0.08, align, preset: "cut-rise" });
+ const headB = head ? capBand(head) : { x: textX, y: top, w: 0, h: 0 };
+ // The title at the top, the line and the call to action above the bottom corners (under the title on a wide
+ // frame), the bottle standing large between them. The corner note and the address sit on the bottom corners.
+ const metaSize = S * (c.cover ? 0.024 : 0.02);
+ const row = footRow(c, 2.4, { arrow: false });
+ const site = onBaseline(c, "website", c.field("website"), { role: "meta", x: safe.x + safe.w * 0.5, width: safe.w * 0.5, maxLines: 1, max: metaSize, min: metaSize * 0.8, align: "right", preset: "fade-rise", y: 0 }, safe.y + safe.h - metaSize * 0.25);
+ const footH = metaSize * 1.1 + S * 0.05;
+ const ctaSize = S * (c.cover ? 0.03 : 0.027);
+ const lineOpts = { role: "accent" as const, weight: 400, x: textX + (side ? 0 : textW * 0.06), width: side ? textW : textW * 0.88, maxLines: 2, max: S * (c.cover ? 0.05 : 0.044), min: S * 0.03, align: align as "left" | "centre", leading: 1.2, preset: "slow-drift" as const, even: 0.6 };
+ const line0 = c.set("line", c.field("line"), { ...lineOpts, y: 0 });
+ // The call to action in the title's serif, small and tracked out, on a hairline (never a web button).
+ const ctaOpts = { role: "hero" as const, weight: 500, tracking: 0.12, leading: 1.1 };
+ const cta0 = c.set("cta", c.field("cta"), { ...ctaOpts, x: textX, y: 0, width: textW, maxLines: 1, max: ctaSize, min: S * 0.022, align });
+ const lineH = line0 ? capBand(line0).h : 0;
+ const ctaTop = side ? headB.y + headB.h + S * 0.06 + lineH + S * 0.075 : safe.y + safe.h - footH - (cta0 ? cta0.size * 1.2 : 0);
+ const lineTop = side ? headB.y + headB.h + S * 0.06 : ctaTop - S * 0.075 - lineH;
+ const line = line0 ? c.set("line", c.field("line"), { ...lineOpts, y: lineTop, max: line0.size, min: line0.size }) : null;
+ const cta = cta0 ? c.set("cta", c.field("cta"), { ...ctaOpts, x: textX, y: ctaTop, width: textW, maxLines: 1, max: cta0.size, min: cta0.size, align }) : null;
+ const floor = side ? safe.y + safe.h - footH : lineTop - S * 0.07;
+ // On a tall frame the bottle stands up behind the title's lower half (the title in front), so it can be large.
+ const boxTop = side ? safe.y + S * 0.04 : headB.y + headB.h * 0.5;
+ // The bottle large: as tall as the room allows, a third of the height or more.
+ const box = side ? { x: safe.x, y: boxTop, w: safe.w * 0.44, h: floor - boxTop } : { x: safe.x + safe.w * 0.1, y: boxTop, w: safe.w * 0.8, h: floor - boxTop };
+ const pic = prod ?? (c.input.logo ? { w: c.input.logo.w, h: c.input.logo.h } : null);
+ const img = pic ? fitBox(pic, box, true) : null;
+ const spot = img ? { x: img.x + img.w / 2, y: img.y + img.h * 0.45 } : { x: cx, y: design.h * 0.6 };
+
+ const k = c.spread(3.3, 1.6);
+ // The title cuts up letter by letter from the first frames; the light opens and the bottle rises from its floor.
+ c.ev("spot", "fade", 0.05, 1.1, "glide");
+ c.ev("bottle", "hero", 0.35, 1, "decel");
+ const headPlan = head ? c.move(head, { in: "cut-rise-glyph", at: 0.05, hero: true }) : null;
+ const headDone = headPlan?.settled ?? 1.6;
+ const linePlan = line ? c.move(line, { in: "slow-drift", at: headDone - 0.35 }) : null;
+ c.ev("rule", "draw", headDone, 0.6, "draw");
+ const ctaPlan = cta ? c.move(cta, { in: "word-lift", at: headDone + 0.25 }) : null;
+ const signPlan = signIn(c, sign, "brand", 0.2);
+ const sweepAt = headDone + 0.1;
+ const sitePlan = site ? c.move(site, { in: "fade-rise", at: headDone + 0.4, rate: 30 }) : null;
+
+ void k;
+ const gold = c.dark ? pal.accent : mixOk(pal.brand[1], pal.ink, 0.3);
+ // The cone of light from above: feathered at its sides, gone by the floor (drawn once, reused).
+ const coneBounds = img ? { x: spot.x - img.w * 1.6, y: 0, w: img.w * 3.2, h: img.y + img.h } : null;
+ const cone: DisplayNode | null = img && coneBounds ? group([{ type: "path", d: `M${spot.x - img.w * 0.16} 0L${spot.x + img.w * 0.16} 0L${spot.x + img.w * 0.95} ${img.y + img.h}L${spot.x - img.w * 0.95} ${img.y + img.h}Z`, fill: { kind: "linear", x0: 0, y0: 0, x1: 0, y1: img.y + img.h, stops: [{ at: 0, color: rgba(pal.paper, 0.02) }, { at: 0.55, color: rgba(pal.paper, 0.1) }, { at: 0.85, color: rgba(pal.paper, 0.06) }, { at: 1, color: rgba(pal.paper, 0) }] } }], { soften: img.w * 0.12, cache: { key: `nc-cone|${img.w.toFixed(0)}x${img.h.toFixed(0)}|${pal.paper}`, bounds: coneBounds } }) : null;
+
+ return {
+ overflow: [...(head?.overflow ? ["headline"] : []), ...(line?.overflow ? ["line"] : []), ...(cta?.overflow ? ["cta"] : []), ...(sign?.overflow ? ["brand"] : []), ...(site?.overflow ? ["website"] : []), ...row.overflow],
+ signature: headDone + 0.2,
+ camera: (t) => ({ x: 0, y: -24 * (1 - Math.min(1, t / c.last)) ** 2 }),
+ draw(t, kit) {
+ const field = litField(c, t, { from: "tl", light: mixOk(pal.brand[1], "#ffffff", 0.3), lightAlpha: 0.18 });
+ const sp = kit.P("spot");
+ const atmosphere: DisplayNode[] = [
+ ...glowAtmosphere(c, t, { cx: spot.x, cy: spot.y, r: S * 0.6, color: pal.brand[1], alpha: 0.3 * sp }),
+ ];
+ // The floor: a faintly lighter plane from the bottle's foot down, its horizon catching the light under the spot.
+ if (img) {
+ const fy = img.y + img.h;
+ atmosphere.push(
+ { type: "rect", x: 0, y: fy, w: design.w, h: design.h - fy, fill: { kind: "linear", x0: 0, y0: fy, x1: 0, y1: design.h, stops: [{ at: 0, color: rgba(pal.paper, 0.07) }, { at: 0.35, color: rgba(pal.paper, 0.025) }, { at: 1, color: rgba(pal.paper, 0) }] } },
+ { type: "rect", x: 0, y: 0, w: design.w, h: design.h, fill: pool(spot.x, fy, design.w * 0.4, mixOk(pal.brand[1], "#ffffff", 0.4), 0.2 * sp) },
+ );
+ }
+ if (cone && sp > 0) atmosphere.push(group([cone], { opacity: sp }));
+ const subject: DisplayNode[] = [];
+ const bl = kit.L("bottle");
+ if (img && bl > 0) {
+ const p = kit.P("bottle");
+ const dy = (1 - p) * S * 0.3;
+ const foot = img.y + img.h;
+ const pic: DisplayNode = prod ? productNode({ src: "product", box: img, ground: pal.ground, t, sweepAt, sweepDur: 0.9, key: "nc" }) : logoNode(c, img, pal.ink);
+ // Its reflection: the bottle mirrored under its foot, fading out.
+ const mirror = prod
+ ? group([group([{ type: "image", decor: true, src: "product", ...img }], { transform: [1, 0, 0, -1, 0, 2 * foot] })], { opacity: 0.15, mask: { kind: "linear", x0: 0, y0: foot, x1: 0, y1: foot + img.h * 0.4, stops: [{ at: 0, color: "rgba(0,0,0,1)" }, { at: 1, color: "rgba(0,0,0,0)" }], bounds: { x: img.x - 2, y: foot, w: img.w + 4, h: img.h * 0.45 } } })
+ : null;
+ // It rises out of its floor (a mask at the foot), never a fade; a soft contact shadow, no disc of light.
+ subject.push(
+ floorShadow({ cx: img.x + img.w / 2, y: foot, width: img.w * 0.9, ground: pal.ground, strength: 0.7 * p, key: `nc|${img.w.toFixed(0)}` }),
+ group([group([...(mirror ? [mirror] : []), pic], { transform: [1, 0, 0, 1, 0, dy] })], { ...(p < 1 && { clip: { type: "rect", x: img.x - img.w, y: img.y - img.h, w: img.w * 3, h: img.h * 2 + S * 0.006 } }) }),
+ );
+ }
+ const hero: DisplayNode[] = headPlan ? kit.type(headPlan, { fill: pal.ink }) : [];
+ const meta: DisplayNode[] = [];
+ if (linePlan) meta.push(...kit.type(linePlan, { fill: c.dark ? mixOk(pal.paper, pal.ground, 0.18) : metaInk(pal) }));
+ // The call to action on a hairline that draws under it.
+ const r = kit.P("rule");
+ if (r > 0 && cta) meta.push(rule({ x: cta.ink.x, y: cta.lines[0].baseline + cta.size * 0.4, w: cta.ink.w, color: gold, p: r, width: Math.max(1.25, S * 0.0018) }));
+ if (ctaPlan) meta.push(...kit.type(ctaPlan, { fill: pal.ink }));
+ if (sitePlan) meta.push(...kit.type(sitePlan, { fill: metaInk(pal) }));
+ meta.push(...signNodes(c, kit, sign, signPlan, "brand", side ? textX : cx - (sign?.w ?? 0) / 2, safe.y, pal.ink), ...row.draw(kit, metaInk(pal)));
+ return [
+ { role: "ground", nodes: field },
+ { role: "atmosphere", nodes: atmosphere },
+ { role: "subject", nodes: subject },
+ { role: "hero", nodes: hero },
+ { role: "meta", nodes: meta },
+ ];
+ },
+ };
+ },
+});
diff --git a/src/lib/motion/scenes/marketing/glass-spotlight.ts b/src/lib/motion/scenes/marketing/glass-spotlight.ts
new file mode 100644
index 00000000..bd63323b
--- /dev/null
+++ b/src/lib/motion/scenes/marketing/glass-spotlight.ts
@@ -0,0 +1,134 @@
+/**
+ * Prism Stage: a product spotlight. A lit field of the brand's hue (aubergine deep to violet), a plinth of dark glass
+ * with a cool rim and a fine bright edge rises, and the product lands on it with its contact shadow, a band of light
+ * crossing it; a prism's streak in the brand's neighbouring tones stays behind it at rest. The name is a justified
+ * stack in a fine display serif (each line fitted to the width), cutting up letter by letter on the diagonal from the
+ * product; the line drifts in under it, the call to action sits over a hairline, and the brand, the address, a corner
+ * note and an index arrow sit on the corners.
+ */
+
+import { about, group, type DisplayNode } from "../../display";
+import { mixOk } from "../../color";
+import { pool, rgba } from "../../fx/background";
+import { floorShadow } from "../../fx/depth";
+import { product as productNode } from "../../fx/photo";
+import { rule } from "../../fx/overlays";
+import { fitBox, logoNode } from "./kit";
+import { bands, brandSign, capBand, fitLines, footRow, glowAtmosphere, litField, metaInk, moveLines, posterScene, signIn, signNodes, stackLanded, topSite } from "./poster";
+
+export default posterScene({
+ id: "marketing/glass-spotlight",
+ name: "Prism Stage",
+ pairing: "T4",
+ look: "dark",
+ build(c) {
+ const { S, safe, pal, design } = c;
+ const side = c.wide;
+ const prod = c.recipe.media?.product ? c.input.images?.product : undefined;
+ const signH = S * (c.cover ? 0.066 : 0.05);
+ const sign = brandSign(c, { maxW: S * 0.4, h: signH, x: safe.x, y: safe.y, min: S * (c.cover ? 0.06 : 0.03) });
+ const textX = side ? safe.x + safe.w * 0.52 : safe.x;
+ const textW = side ? safe.w * 0.48 : safe.w;
+ const metaSize = S * (c.cover ? 0.024 : 0.02);
+ const site = topSite(c, sign, metaSize);
+ const b = bands(c, { topRow: sign?.h ?? metaSize, gap: S * 0.05 });
+ const foot = metaSize * 1.1 + S * 0.05;
+ // The name across the top, every line fitted to the width; the line and the call to action at the foot; the stage between.
+ const head = fitLines(c, "headline", c.field("headline"), { x: textX, top: b.top, room: side ? (b.bottom - b.top) * 0.5 : (b.bottom - b.top) * 0.36, anchor: 0, width: side ? textW : safe.w * 0.92, maxLines: 2, max: S * (side ? 0.17 : 0.3), min: S * 0.07, preset: "cut-rise-glyph", fill: 0.985, ratio: 1.9, gap: 0.12, stack: true });
+ const headB = head ? head.band : { x: textX, y: b.top, w: 0, h: 0 };
+ const ctaSize = S * (c.cover ? 0.034 : 0.03);
+ const ctaY = safe.y + safe.h - foot - ctaSize * 1.3;
+ const lineW = side ? textW : safe.w * 0.38;
+ // The line in the title's italic (one voice), small.
+ const lineOpts = { role: "accent" as const, weight: 400, style: "italic" as const, x: textX, width: lineW, maxLines: 3, max: S * (c.cover ? 0.036 : 0.032), min: S * 0.026, leading: 1.25, preset: "focus-in" as const, even: 0.6 };
+ const line0 = c.set("line", c.field("line"), { ...lineOpts, y: 0 });
+ const lineTop = side ? headB.y + headB.h + S * 0.045 : ctaY - ctaSize * 0.4 - S * 0.06 - (line0 ? capBand(line0).h : 0);
+ const line = line0 ? c.set("line", c.field("line"), { ...lineOpts, y: lineTop, max: line0.size, min: line0.size }) : null;
+ const cta = c.set("cta", c.field("cta"), { role: "hero", weight: 500, x: textX, y: ctaY, width: textW * 0.5, maxLines: 1, max: ctaSize, min: S * 0.022, tracking: 0.12 });
+ // The stage: the right of the frame between the name and the foot (the left half on a wide frame).
+ const stage = side ? { x: safe.x, y: safe.y + S * 0.04, w: safe.w * 0.46, h: safe.y + safe.h - foot - safe.y - S * 0.04 } : { x: safe.x + safe.w * 0.4, y: headB.y + headB.h + S * 0.05, w: safe.w * 0.6, h: 0 };
+ if (!side) stage.h = safe.y + safe.h - foot - stage.y;
+ // The plinth: 40 % of the frame's width; the bottle on it about half the plinth's width (never a miniature).
+ const plinthW = Math.min(stage.w * 0.92, design.w * (side ? 0.3 : 0.42));
+ const plinthH = plinthW * 0.26;
+ const plinth = { x: stage.x + (stage.w - plinthW) / 2, y: stage.y + stage.h - plinthH * 1.2, w: plinthW, h: plinthH };
+ const pic = prod ?? (c.input.logo ? { w: c.input.logo.w, h: c.input.logo.h } : null);
+ const img = pic ? fitBox(pic, { x: plinth.x + plinth.w * 0.22, y: Math.max(stage.y, plinth.y + plinthH * 0.28 - plinthW * 0.95), w: plinth.w * 0.56, h: Math.min(plinthW * 0.95, plinth.y + plinthH * 0.28 - stage.y) }, true) : null;
+ const focus = { x: plinth.x + plinth.w / 2, y: img ? img.y + img.h * 0.5 : plinth.y - S * 0.2 };
+
+ const k = c.spread(3.2, 1.6);
+ c.ev("rings", "hero", 0, 1, "enter");
+ c.ev("plinth", "enter", 0.25, 0.65, "glide");
+ c.ev("product", "hero", 0.55, 0.9, "settle");
+ const headPlans = head ? moveLines(c, head, { in: "cut-rise-glyph", at: 0.05, hero: true, loop: "light-sweep", loopAt: 2.4, loopEvery: 2 }, "headline", 0.14) : [];
+ const headDone = headPlans.length ? stackLanded(headPlans) : 1.6;
+ const linePlan = line ? c.move(line, { in: "focus-in", at: headDone - 0.3 }) : null;
+ c.ev("rule", "draw", headDone + 0.1, 0.6, "draw");
+ const ctaPlan = cta ? c.move(cta, { in: "word-lift", at: headDone + 0.15 * k }) : null;
+ const signPlan = signIn(c, sign, "brand", 0.2);
+ const sitePlan = site ? c.move(site, { in: "fade-rise", at: 0.35, rate: 26 }) : null;
+ const row = footRow(c, headDone + 0.3);
+ const sweepAt = Math.max(headDone + 0.05, 1.7);
+ // A prism's streak of light behind the bottle in the brand's neighbouring tones, sliding a little.
+ const streakW = Math.min(design.w * 0.7, stage.w * 1.1);
+
+ return {
+ overflow: [...(head?.overflow ? ["headline"] : []), ...(line?.overflow ? ["line"] : []), ...(cta?.overflow ? ["cta"] : []), ...(sign?.overflow ? ["brand"] : []), ...(site?.overflow ? ["website"] : []), ...row.overflow],
+ signature: headDone + 0.2,
+ camera: (t) => ({ x: 16 * (1 - Math.min(1, t / c.last)) ** 2, y: 0 }),
+ draw(t, kit) {
+ const field = litField(c, t, { from: "tr", light: mixOk(pal.brand[1], "#ffffff", 0.2), lightAlpha: 0.2 });
+ const rp = kit.P("rings");
+ const slide = (1 - Math.min(1, t / c.last)) ** 2 * stage.w * 0.04;
+ const sx = focus.x - streakW / 2 - slide;
+ // The spotlight: an elliptical pool (taller than wide) behind the bottle, falling off smoothly (no edge anywhere).
+ const sr = streakW * 0.42;
+ const streak: DisplayNode = group([{ type: "rect", x: 0, y: 0, w: design.w, h: design.h, fill: pool(focus.x + slide * 0, focus.y, sr, mixOk(pal.brand[1], "#ffffff", 0.45), 0.42) }], { blend: "screen", opacity: rp, transform: about(focus.x, focus.y, 1, 0, 1.6) });
+ void sx;
+ const atmosphere: DisplayNode[] = [...glowAtmosphere(c, t, { cx: focus.x, cy: focus.y, r: S * 0.7, color: pal.brand[1], alpha: 0.32 * rp }), streak];
+ const subject: DisplayNode[] = [];
+ const pp = kit.P("plinth");
+ if (kit.L("plinth") > 0) {
+ const dy = (1 - pp) * S * 0.08;
+ // A cylinder of dark glass: a soft vertical gradient on its side (a cool rim light at the edges, a dark core),
+ // its top face lit, a 1-unit bright edge, a shadow under it.
+ // Seen nearly level with the bottle (a flat top face).
+ const ry = plinth.h * 0.16;
+ const cxp = plinth.x + plinth.w / 2;
+ const cool = mixOk(pal.brand[1], "#bfd4ff", 0.4);
+ const topEll: DisplayNode = { type: "ellipse", cx: cxp, cy: plinth.y, rx: plinth.w / 2, ry, fill: { kind: "radial", cx: cxp, cy: plinth.y - ry * 0.4, r0: 0, r1: plinth.w * 0.55, stops: [{ at: 0, color: rgba(cool, 0.34) }, { at: 0.75, color: rgba(pal.brand[0], 0.5) }, { at: 1, color: rgba(cool, 0.3) }] } };
+ const rim: DisplayNode = { type: "ellipse", cx: cxp, cy: plinth.y, rx: plinth.w / 2, ry, stroke: { paint: rgba("#ffffff", 0.7), width: Math.max(1, S * 0.0012) } };
+ const bodyD = `M${plinth.x} ${plinth.y}V${plinth.y + plinth.h}A${plinth.w / 2} ${ry} 0 0 0 ${plinth.x + plinth.w} ${plinth.y + plinth.h}V${plinth.y}Z`;
+ const night = mixOk(pal.ground, "#000000", 0.35);
+ const body: DisplayNode = { type: "path", d: bodyD, fill: { kind: "linear", x0: plinth.x, y0: 0, x1: plinth.x + plinth.w, y1: 0, stops: [{ at: 0, color: rgba(cool, 0.32) }, { at: 0.12, color: rgba(night, 0.85) }, { at: 0.4, color: rgba(night, 0.95) }, { at: 0.88, color: rgba(night, 0.85) }, { at: 1, color: rgba(cool, 0.26) }] } };
+ const shade: DisplayNode = { type: "path", d: bodyD, fill: { kind: "linear", x0: 0, y0: plinth.y, x1: 0, y1: plinth.y + plinth.h + ry, stops: [{ at: 0, color: rgba("#000000", 0) }, { at: 1, color: rgba("#000000", 0.3) }] } };
+ subject.push(group([floorShadow({ cx: cxp, y: plinth.y + plinth.h + ry * 0.6, width: plinth.w * 1.05, ground: pal.ground, strength: 0.55, key: `ps-plinth|${plinth.w.toFixed(0)}` }), body, shade, topEll, rim], { transform: [1, 0, 0, 1, 0, dy], ...(pp < 1 && { opacity: Math.min(1, kit.L("plinth") * 2) }) }));
+ }
+ const pl = kit.L("product");
+ if (img && pl > 0) {
+ const p = kit.P("product");
+ const dy = (1 - p) * -design.h * 0.08;
+ const node: DisplayNode = prod ? productNode({ src: "product", box: img, ground: pal.ground, t, sweepAt, sweepDur: 0.85, key: "ps" }) : logoNode(c, img, pal.ink);
+ subject.push(floorShadow({ cx: img.x + img.w / 2, y: img.y + img.h, width: img.w * 0.9, ground: pal.ground, strength: 0.55 * Math.min(1, pl * 1.5), key: `ps|${img.w.toFixed(0)}` }), group([node], { transform: [1, 0, 0, 1, 0, dy] }));
+ }
+ const hero: DisplayNode[] = head ? head.sets.flatMap((_, i) => kit.type(headPlans[i], { fill: pal.ink, sweep: "#ffffff", sweepAlpha: 0.45 })) : [];
+ const overlay: DisplayNode[] = [];
+ if (linePlan) overlay.push(...kit.type(linePlan, { fill: metaInk(pal) }));
+ if (ctaPlan) overlay.push(...kit.type(ctaPlan, { fill: pal.ink }));
+ const r = kit.P("rule");
+ if (r > 0 && cta) overlay.push(rule({ x: cta.ink.x, y: cta.lines[0].baseline + cta.size * 0.4, w: cta.ink.w, color: pal.accent, p: r, width: Math.max(1.25, S * 0.0018) }));
+ const light: DisplayNode[] = [];
+ const meta = [...signNodes(c, kit, sign, signPlan, "brand", safe.x, safe.y, pal.ink), ...(sitePlan ? kit.type(sitePlan, { fill: metaInk(pal), caret: pal.accent }) : []), ...row.draw(kit, metaInk(pal), pal.ink)];
+ return [
+ { role: "ground", nodes: field },
+ { role: "atmosphere", nodes: atmosphere },
+ { role: "subject", nodes: subject },
+ { role: "hero", nodes: hero },
+ { role: "overlay", nodes: overlay },
+ { role: "meta", nodes: meta },
+ { role: "light", nodes: light },
+ ];
+ },
+ };
+ },
+});
diff --git a/src/lib/motion/scenes/marketing/kinetic-headline.ts b/src/lib/motion/scenes/marketing/kinetic-headline.ts
index 80dd13fe..618c19e4 100644
--- a/src/lib/motion/scenes/marketing/kinetic-headline.ts
+++ b/src/lib/motion/scenes/marketing/kinetic-headline.ts
@@ -1,146 +1,141 @@
/**
- * Kinetic Headline: the promise sets word by word on a beat. Each word lands with a spring and the words the person
- * marked with *stars* get a swatch in the kit's highlight colour (a lone star is part of the words and is drawn). The
- * camera leans in as each new line starts and keeps a slow push while the words are read. Then the words lift away and
- * the piece resolves to the logo with the Draw-on end card: on a dark brand colour the ground is that colour already,
- * so the card simply sets on it; otherwise the brand colour opens out from the middle of the frame.
+ * Kinetic Headline: a wide, confident statement set as a justified stack, each line fitted to the full width on its
+ * own, cut in letter by letter from under its line on a lit two-tone field. A giant filled ghost of the same words,
+ * one tonal step from the ground, drifts behind it, cropped by the frame; the words the person marked with *stars* get
+ * a skewed highlighter that wipes in just before they land. The brand and the address sit on the top corners, a corner
+ * note and an index arrow on the bottom ones, and the call to action lands in a tilted pill above them. Through the
+ * hold the type plane pushes in, the ghost drifts and a band of light crosses the words twice. The last frame is the
+ * poster.
*/
-import { group, translate, type DisplayNode, type TextRun } from "../../display";
-import { sample, type Key } from "../../tween";
-import drawOn from "../end-card/draw-on";
-import { glyphTop, lineLeft } from "../end-card/shared";
-import { ev, groundLight, marked, marketingScene, MIN_HEAD, setText, textBlock } from "./kit";
+import { group, translate, type DisplayNode } from "../../display";
+import { highlighter } from "../../fx/overlays";
+import { asDecor, bands, brandSign, fitLines, footRow, ghostSpan, litField, markColor, metaInk, moveLines, pillOn, posterScene, shadowed, stackLanded, topSite } from "./poster";
+import { ensureContrast, fieldStops, mixOk } from "../../color";
+import { marked } from "./kit";
-/** The end card's share of the clip. */
-const CARD = 2.3;
-
-export default marketingScene({
+export default posterScene({
id: "marketing/kinetic-headline",
name: "Kinetic Headline",
- look: "light",
+ pairing: "T1",
+ look: "dark",
build(c) {
- const { S, safe, palette: pal, design, recipe, pace } = c;
- const typed = c.field("headline") || recipe.brand.name.trim();
+ const { S, safe, pal, design } = c;
+ const typed = c.field("headline") || c.recipe.brand.name.trim();
const m = marked(typed);
const lead = m.text.length - m.text.trimStart().length;
const text = m.text.trim();
const marks = m.marks.map(([a, b]) => [a - lead, b - lead] as const);
- const flushLeft = recipe.controls?.align === "left";
- const width = c.wide ? Math.min(safe.w, S * 1.45) : safe.w;
- const L = setText(c, text, { weight: 800, width, maxLines: c.tall ? 5 : c.wide ? 3 : 4, max: S * (c.tall ? 0.17 : c.wide ? 0.13 : 0.145), min: S * MIN_HEAD, lineHeight: 1.08 });
- const y = L ? safe.y + (safe.h - L.height) / 2 - S * 0.02 : safe.y;
- const left = (design.w - width) / 2;
- const block = L ? textBlock("headline", L, { y, color: pal.ink, ...(flushLeft ? { left, width } : { cx: design.w / 2 }) }) : null;
+ const centred = c.recipe.controls?.align === "centre";
+ const align = centred ? "centre" : "left";
- // The words in reading order, each with where it sits and whether it's marked.
- interface Word {
- line: number;
- text: string;
- gap: string;
- x: number;
- y: number;
- w: number;
- hot: boolean;
- }
- const words: Word[] = [];
- if (block && L) {
+ // The top corner row: the brand (left), the address (right).
+ const markH = S * (c.cover ? 0.058 : 0.046);
+ const sign = brandSign(c, { maxW: S * 0.36, h: markH, x: safe.x, y: safe.y, min: S * (c.cover ? 0.05 : 0.03) });
+ const metaSize = S * (c.cover ? 0.024 : 0.02);
+ const site = topSite(c, sign, metaSize);
+
+ // The bottom corner row stands on the safe line; the call to action sits just above it.
+ const ctaSize = S * (c.cover ? 0.056 : 0.044);
+ const ctaPad = { x: ctaSize * 0.6, y: ctaSize * 0.35 };
+ const foot = S * (c.cover ? 0.024 : 0.02) * 1.1;
+ const ctaY = safe.y + safe.h - foot - S * 0.05 - ctaSize * 1.2 - ctaPad.y;
+ const cta = c.set("cta", c.field("cta"), { role: "body", weight: 600, x: centred ? design.w / 2 - safe.w * 0.4 : safe.x + ctaPad.x, y: ctaY, width: safe.w * 0.8 - ctaPad.x * 2, maxLines: 1, max: ctaSize, min: ctaSize * 0.75, align: centred ? "centre" : "left" });
+
+ // The hero fills the room between, every line fitted to the width, its centre near 45 % of the height.
+ const b = bands(c, { topRow: sign?.h ?? metaSize, gap: S * 0.06 });
+ const bottom = (cta ? ctaY - ctaPad.y : b.bottom) - S * 0.06;
+ const width = c.wide ? safe.w * 0.6 : safe.w;
+ const hero = fitLines(c, "headline", text, { x: centred ? design.w / 2 - width / 2 : safe.x, top: b.top, room: bottom - b.top, centre: c.wide ? (b.top + bottom) / 2 : design.h * 0.45, width, maxLines: c.wide ? 3 : 4, max: c.wide ? design.h * 0.3 : S * 0.5, min: S * 0.1, align, preset: "cut-rise-glyph", fill: 0.995, ratio: 1.7, gap: 0.1, stack: true });
+
+ const k = c.spread(3.2, 1.6);
+ // From the first frames: the first glyph is under way by 0.07 s. After it lands, two bands of light cross it.
+ const plans = hero ? moveLines(c, hero, { in: "cut-rise-glyph", at: 0.03, hero: true, loop: "light-sweep", loopAt: 1.9, loopEvery: 1.8 }, "headline", 0.12) : [];
+ const landed = plans.length ? stackLanded(plans) : 0.8;
+
+ // Marked words: a highlighter under each, wiping in 70 ms before its line lands.
+ const marksAt: { li: number; x: number; w: number; capTop: number; baseline: number; key: string }[] = [];
+ if (hero) {
let at = 0;
- L.lines.forEach((line, i) => {
- const x0 = lineLeft(block, i);
- const top = glyphTop(block, i);
- for (const w of line.words) {
+ hero.sets.forEach((set, li) => {
+ set.words.forEach((w, wi) => {
at += w.gap.length;
const a = at;
- const b = at + w.text.length;
- at = b;
- words.push({ line: i, text: w.text, gap: w.gap, x: x0 + w.x, y: top, w: w.w, hot: marks.some(([p, q]) => p < b && q > a) });
- }
+ const e = at + w.text.length;
+ at = e;
+ if (!marks.some(([p, q]) => p < e && q > a)) return;
+ const line = set.lines[w.line];
+ marksAt.push({ li, x: w.x, w: w.w, capTop: line.y + set.cap.top, baseline: line.baseline, key: `${li}.${wi}` });
+ });
});
}
+ marksAt.forEach((mk, j) => c.ev(`mark.${j}`, "draw", Math.max(0.1, (plans[mk.li]?.settled ?? landed) - 0.07 - 0.4 + 0.12 * j), 0.4, "snap"));
- // The end card: the logo (or the name), the call to action and the address, drawn by the Draw-on style.
- const T0 = recipe.duration - CARD;
- const card = drawOn.plan({
- ...c.input,
- recipe: { ...recipe, scene: "end-card/draw-on", duration: CARD, fields: { brand: recipe.brand.name, product: "", ...(c.field("cta") && { cta: c.field("cta") }), ...(c.field("website") && { website: c.field("website") }) } },
- });
- const exitAt = T0 - 0.45;
- const read = Math.max(0.7, 0.28 * exitAt);
- const n = Math.max(1, words.length);
- const pop = 0.5 * pace;
- const beat = n > 1 ? Math.min(0.42 * pace, Math.max(0.09, (exitAt - read - pop - 0.12) / (n - 1))) : 0;
- const events = words.flatMap((w, i) => {
- const s = 0.12 + i * beat;
- return [ev(`word.${i}`, "pop", s, pop, "pop"), ...(w.hot ? [ev(`mark.${i}`, "draw", s + 0.05, 0.36, "snap")] : [])];
- });
- events.push(ev("words.exit", "exit", exitAt, 0.4, "exit"), ev("panel", "enter", exitAt + 0.05, 0.5, "move"));
- for (const e of card.timeline.events) events.push({ ...e, id: `card.${e.id}`, start: Math.round((e.start + T0) * 1e6) / 1e6 });
+ const metaAt = Math.min(landed + 0.1 * k, c.room - 1);
+ const signPlan = sign?.set ? c.move(sign.set, { in: "word-lift", at: 0.2 }) : null;
+ if (sign && !sign.set) c.ev("brand", "enter", 0.2, 0.5, "glide");
+ const sitePlan = site ? c.move(site, { in: "fade-rise", at: 0.35, rate: 26 }) : null;
+ const ctaAt = metaAt + 0.1 * k;
+ const ctaPlan = cta ? c.move(cta, { in: "word-lift", at: ctaAt + 0.04 }) : null;
+ if (cta) c.ev("pill", "pop", ctaAt, 0.5, "pop");
+ const row = footRow(c, metaAt + 0.2);
- // The camera leans in a little as each line starts, and follows it.
- const lines = L?.lines.length ?? 0;
- const firstOf = (line: number) => words.findIndex((w) => w.line === line);
- const zoom: Key[] = [{ t: 0, v: 1 }];
- const pan: Key[] = [{ t: 0, v: 0 }];
- for (let k = 1; k < lines; k++) {
- const s = 0.12 + firstOf(k) * beat;
- const mid = block && L ? glyphTop(block, k) + L.size / 2 - (y + L.height / 2) : 0;
- zoom.push({ t: s - 0.05, v: zoom[zoom.length - 1].v }, { t: s + 0.55, v: 1 + 0.025 * k, ease: "move" });
- pan.push({ t: s - 0.05, v: pan[pan.length - 1].v }, { t: s + 0.55, v: -mid * 0.12, ease: "move" });
- }
+ // The ghost: the brand's name (never an echo of the hero's words), set across the frame behind the first lines,
+ // filled one faint step from the ground, so it reads as texture and never as another line of the headline.
+ const ghostWord = c.recipe.brand.name.trim() || (hero ? hero.sets[0].text.trim() : "");
+ const ghostTop = hero ? Math.max(b.top - S * 0.06, hero.band.y - S * 0.04) / design.h : 0.2;
+ const stops = fieldStops(pal);
+ // The call to action: a paper tag with the hero's ink (never a third hue), level.
+ const pillFill = pal.paper;
+ const pillInk = mixOk(pal.night, pal.brand[0], 0.35);
+ const heroInk = pal.ink;
+ // The bar covers the marked words' whole cap band in one colour the words read on at 4.5:1 (never a glyph split
+ // between two colours).
+ const knock = false;
+ const markInk = ensureContrast(markColor(c, pal.ground, heroInk), heroInk, 4.5);
+ const ghostGround = mixOk(stops.dark, stops.light, 0.45);
- // A slow push while the words are read, up to the moment they leave.
- const z0 = zoom[zoom.length - 1];
- if (exitAt > z0.t + 0.3) zoom.push({ t: exitAt, v: z0.v + 0.03, ease: "move" });
- const cardGround = card.evaluate(0).background;
- const same = typeof cardGround === "string" && cardGround.toLowerCase() === pal.ground.toLowerCase();
- const R = Math.hypot(design.w, design.h) / 2 + 2;
- const size = L?.size ?? S * 0.1;
- // The card's ground gets the same slow light and falloff as the words' ground, so it never reads as a flat fill.
- const lit = recipe.look?.light === false ? null : same ? groundLight(c) : typeof cardGround === "string" ? groundLight(c, { ground: cardGround, look: "brand" }) : null;
return {
- events,
- breath: false,
- cuts: [T0],
- overflow: [...(L?.overflow ? ["headline"] : []), ...card.overflow.filter((f) => f !== "product")],
- signature: 0.12 + Math.min(n - 1, 2) * beat + pop * 0.6,
- camera: (t) => ({ zoom: sample(zoom, t), x: 0, y: sample(pan, t) }),
- frame(t, P, Lp) {
- if (t >= T0) {
- const list = card.evaluate(t >= c.last ? card.rest : t - T0);
- const glow = lit ? lit(t) : [];
- // A card that opened out of the middle lights up as it lands; on the scene's own ground the light carries on.
- const fade = same ? 1 : Math.min(1, (t - T0) / 0.5);
- const light: DisplayNode[] = !glow.length ? [] : fade < 1 ? [group(glow, { opacity: fade })] : glow;
- return { nodes: [], over: [{ type: "rect", x: 0, y: 0, w: design.w, h: design.h, fill: list.background }, ...light, ...list.nodes] };
+ overflow: [...(hero?.overflow ? ["headline"] : []), ...(cta?.overflow ? ["cta"] : []), ...(site?.overflow ? ["website"] : []), ...(sign?.overflow ? ["brand"] : []), ...row.overflow],
+ signature: landed + 0.5,
+ camera: (t) => ({ x: 26 * (1 - Math.min(1, t / c.last)) ** 2, y: 0 }),
+ draw(t, kit) {
+ const field = litField(c, t, { from: "tr", stops });
+ const ghostNodes: DisplayNode[] = ghostWord ? [ghostSpan(c, { field: "headline", text: ghostWord, top: ghostTop, t, ground: ghostGround, span: 1.04 })] : [];
+
+ const heroNodes: DisplayNode[] = [];
+ if (hero) {
+ const words = hero.sets.flatMap((s, i) => kit.type(plans[i], { fill: heroInk, sweep: "#ffffff", sweepAlpha: 0.5 }));
+ if (t >= landed) heroNodes.push(...shadowed(c, words, hero.size, hero.band, `kh|${text}|${hero.size}`));
+ const knocks: DisplayNode[] = [];
+ marksAt.forEach((mk, j) => {
+ const hl = highlighter({ capTop: mk.capTop, baseline: mk.baseline, x: mk.x, w: mk.w, color: markInk, seed: c.seed, p: kit.P(`mark.${j}`), key: mk.key, cover: 1.14, skew: -3 });
+ if (!hl) return;
+ heroNodes.push(hl);
+ if (knock && hl.type === "path") knocks.push(group(asDecor(kit.type(plans[mk.li], { fill: pal.paper })), { clip: { type: "path", d: hl.d } }));
+ });
+ heroNodes.push(...words, ...knocks);
}
- const swatches: DisplayNode[] = [];
- const runs: TextRun[] = [];
- words.forEach((w, i) => {
- const p = P(`word.${i}`);
- if (p <= 0 && Lp(`word.${i}`) <= 0) return;
- const appear = Math.min(1, Lp(`word.${i}`) * 5);
- const s = 1.32 - 0.32 * p;
- const cx = w.x + w.w / 2;
- const cy = w.y + size / 2;
- if (w.hot) {
- const q = P(`mark.${i}`);
- if (q > 0) {
- const pad = size * 0.14;
- const full = w.w + pad * 2;
- const rtl = L?.dir === "rtl";
- swatches.push({ type: "rect", x: rtl ? w.x - pad + full * (1 - q) : w.x - pad, y: w.y - size * 0.06, w: full * q, h: size * 1.12, r: size * 0.12, fill: pal.highlight.fill });
- }
+ const overlay: DisplayNode[] = [];
+ if (cta && ctaPlan && kit.L("pill") > 0) overlay.push(pillOn(cta, kit.type(ctaPlan, { fill: pillInk }), pillFill, { deg: 0, p: kit.P("pill") }));
+ const meta: DisplayNode[] = [];
+ if (sign) {
+ if (signPlan) meta.push(...kit.type(signPlan, { fill: pal.ink }));
+ else {
+ const p = kit.P("brand");
+ const lin = kit.L("brand");
+ if (lin > 0) meta.push(group(sign.nodes(safe.x, safe.y, pal.ink), { ...(p < 1 && { transform: translate(0, (1 - p) * S * 0.02) }), ...(lin < 0.5 && { opacity: lin / 0.5 }) }));
}
- const fill = w.hot && P(`mark.${i}`) > 0.35 ? pal.highlight.ink : pal.ink;
- runs.push({ text: w.text, gap: w.gap, font: L!.font, x: w.x, y: w.y - (1 - p) * size * 0.12, fill, ...(appear < 1 && { opacity: appear }), ...(Math.abs(s - 1) > 1e-4 && { transform: [s, 0, 0, s, cx - s * cx, cy - s * cy] }), ...(L!.dir === "rtl" && { dir: "rtl" as const }) });
- });
- const e = P("words.exit");
- const content: DisplayNode[] = [...swatches, { type: "text", field: "headline", runs }];
- const nodes: DisplayNode[] = e > 0 ? [group(content, { transform: translate(0, -e * S * 0.06), opacity: 1 - e })] : content;
- const rise = P("panel");
- const over: DisplayNode[] = rise > 0 && !same ? [{ type: "ellipse", cx: design.w / 2, cy: design.h / 2, rx: R * rise, ry: R * rise, fill: cardGround }] : [];
- return { nodes, over };
+ }
+ if (sitePlan) meta.push(...kit.type(sitePlan, { fill: metaInk(pal), caret: pal.accent }));
+ meta.push(...row.draw(kit, metaInk(pal), pal.ink));
+ return [
+ { role: "ground", nodes: field },
+ { role: "ghost", nodes: ghostNodes },
+ { role: "hero", nodes: heroNodes },
+ { role: "overlay", nodes: overlay },
+ { role: "meta", nodes: meta },
+ ];
},
};
},
diff --git a/src/lib/motion/scenes/marketing/line-reveal.ts b/src/lib/motion/scenes/marketing/line-reveal.ts
index c9e70ae1..b35705ce 100644
--- a/src/lib/motion/scenes/marketing/line-reveal.ts
+++ b/src/lib/motion/scenes/marketing/line-reveal.ts
@@ -1,14 +1,17 @@
/**
- * Line-Art Reveal: one continuous line in the brand's colour runs in along the ground, traces the product's outline
- * (from the cut-out's own edge), and runs on out; then an arch of the brand's colour rises behind the product as it
- * fills in from the ground up, the line steps back, the headline and the call to action set under it with a drawn
- * underline, and the brand signs off (its logo, else its name). A photo without transparency gets a rounded frame traced
- * round it instead. Editorial and quiet: a fine line, generous space; the beats spread over the clip's length.
+ * Line-Art Reveal: quiet luxury. On warm paper with window light drifting across it, one fine line runs in along the
+ * floor, traces the product's own outline (from the cut-out's edge) and runs on out; a tonal arch rises behind as the
+ * product fills in from its foot, the line steps back, a band of light crosses the product once, and the headline
+ * cuts up in a fine display serif with the call to action under a drawn rule. A hairline frame holds the page and the
+ * brand settles at the top. A photo without transparency gets a rounded frame traced round it instead.
*/
-import { group, mixHex, type DisplayNode, type Matrix } from "../../display";
-import { lineRuns } from "../end-card/shared";
-import { brandMark, contactShadow, ev, fitBox, heroOf, logoNode, marketingScene, MIN_HEAD, riseReveal, risingLines, setText, spread, textBlock } from "./kit";
+import { type DisplayNode, type Matrix } from "../../display";
+import { mixOk } from "../../color";
+import { product as productNode } from "../../fx/photo";
+import { rule } from "../../fx/overlays";
+import { fitBox, logoNode, riseReveal } from "./kit";
+import { brandSign, capBand, litField, metaInk, onBaseline, paperField, posterScene, signIn, signNodes } from "./poster";
/** A rounded frame as path data from its bottom centre, clockwise on screen (left first), and its length. */
export function framePath(x: number, y: number, w: number, h: number, r: number): { d: string; length: number } {
@@ -25,125 +28,141 @@ const archPath = (cx: number, foot: number, w: number, h: number): string => {
return `M${cx - r} ${foot}V${foot - h + r}A${r} ${r} 0 0 1 ${cx + r} ${foot - h + r}V${foot}Z`;
};
-export default marketingScene({
+export default posterScene({
id: "marketing/line-reveal",
name: "Line-Art Reveal",
+ pairing: "T4",
look: "light",
build(c) {
- const { S, safe, palette: pal, design } = c;
- const hero = heroOf(c);
- const width = c.recipe.controls?.line === "bold" ? S * 0.008 : S * 0.0045;
- const line = pal.mark;
- // The picture's box, and where the words go.
+ const { S, safe, pal, design } = c;
const side = c.wide;
- const textLeft = side ? safe.x + safe.w * 0.54 : safe.x;
+ const prod = c.recipe.media?.product ? c.input.images?.product : undefined;
+ const logo = c.input.logo;
+ const width = c.recipe.controls?.line === "bold" ? S * 0.006 : S * 0.0017;
+ const cx = design.w / 2;
+ const signH = S * (c.cover ? 0.072 : 0.056);
+ const sign0 = brandSign(c, { maxW: S * 0.4, h: signH, x: 0, y: 0, align: "centre", min: S * (c.cover ? 0.056 : 0.03) });
+ const signsTop = !side && !!sign0;
+ const sign = sign0?.set ? brandSign(c, { maxW: S * 0.4, h: signH, x: side ? safe.x + safe.w * 0.54 : cx - S * 0.2, y: side ? safe.y : safe.y, align: side ? "left" : "centre", min: S * (c.cover ? 0.056 : 0.03) }) : sign0;
+ const textX = side ? safe.x + safe.w * 0.54 : safe.x;
const textW = side ? safe.w * 0.46 : safe.w;
- const head = setText(c, c.field("headline"), { weight: 700, width: textW, maxLines: 3, max: S * (side ? 0.09 : c.tall ? 0.105 : 0.09), min: S * MIN_HEAD, lineHeight: 1.08 });
- const cta = setText(c, c.field("cta"), { family: "body", weight: 600, width: textW, maxLines: 1, max: S * (c.tall ? 0.05 : 0.045), min: S * 0.036 });
- // The sign-off: on top of a tall or square frame, under the words on a wide one. A logo that is the picture already
- // (no product) is not shown twice.
- const signs = !(hero?.src === "logo");
- const mark = signs ? brandMark(c, { maxW: S * (side ? 0.32 : 0.42), h: S * (c.tall ? 0.08 : 0.065), color: pal.ink, minName: 0.036 }) : null;
- const markRoom = mark && !side ? mark.h + S * 0.06 : 0;
- const gapT = S * 0.035;
- const ctaH = cta ? cta.size * 1.6 : 0;
- const textH = (head?.height ?? 0) + (cta ? (head ? gapT : 0) + ctaH : 0) + (mark && side ? S * 0.06 + mark.h : 0);
- // Stacked, the picture takes what the words leave, and the whole is centred.
- const gapPic = S * 0.08;
- const avail = safe.h - markRoom;
- const picH = side ? safe.h * 0.84 : Math.min(avail * 0.66, avail - textH - gapPic);
- const block = picH + gapPic + textH;
- const picTop = safe.y + markRoom + Math.max(0, (avail - block) / 2);
- const picBox = side ? { x: safe.x + safe.w * 0.02, y: safe.y + safe.h * 0.08, w: safe.w * 0.44, h: picH } : { x: safe.x + safe.w * 0.05, y: picTop, w: safe.w * 0.9, h: picH };
+ // The hero big enough that its hairlines hold at a thumbnail's size.
+ const head0 = c.set("headline", c.field("headline"), { role: "hero", x: textX, y: 0, width: textW, maxLines: 3, max: S * (side ? 0.12 : 0.15), min: S * 0.06, align: side ? "left" : "centre", preset: "cut-rise", even: 0.5 });
+ // The foot row, on one baseline at the safe line: the corner note (left), the call to action (centre, underlined),
+ // the address (right).
+ // The call to action a step above the two small facts, which are tracked out (their own quiet voice).
+ const ctaSize = S * (c.cover ? 0.032 : 0.028);
+ const metaSize = S * (c.cover ? 0.019 : 0.017);
+ const footBase = safe.y + safe.h - metaSize * 0.3;
+ const cta = onBaseline(c, "cta", c.field("cta"), { role: "meta", weight: 500, x: side ? textX : cx - safe.w * 0.22, width: side ? textW * 0.6 : safe.w * 0.44, maxLines: 1, max: ctaSize, min: S * 0.022, align: side ? "left" : "centre", preset: "track-in", y: 0 }, footBase);
+ const site = onBaseline(c, "website", c.field("website"), { role: "meta", x: safe.x + safe.w * 0.7, width: safe.w * 0.3, maxLines: 1, max: metaSize, min: metaSize * 0.8, align: "right", preset: "fade-rise", tracking: 0.12, y: 0 }, footBase);
+ const note = onBaseline(c, "note", c.field("note"), { role: "meta", x: safe.x, width: side ? safe.w * 0.4 : safe.w * 0.28, maxLines: 1, max: metaSize, min: metaSize * 0.8, align: "left", preset: "fade-rise", tracking: 0.12, y: 0 }, footBase);
+ const lastInk = head0 ? head0.lines[head0.lines.length - 1].ink : null;
+ const descent = head0 && lastInk ? Math.max(0, lastInk.y + lastInk.h - head0.lines[head0.lines.length - 1].baseline) : 0;
+ const headH = head0 ? capBand(head0).h + descent : 0;
+ const ctaH = (cta ? ctaSize * 1.6 : metaSize * 1.4) + S * 0.06;
+ const textH = headH;
+ // Stacked: the brand on top, the picture, then the words; the picture takes what the words leave.
+ const top = safe.y + (signsTop ? (sign0?.h ?? 0) + S * 0.075 : 0);
+ const gap = S * 0.05;
+ const picBox = side ? { x: safe.x, y: safe.y + safe.h * 0.04, w: safe.w * 0.46, h: safe.h * 0.92 - ctaH } : { x: safe.x + safe.w * 0.1, y: top, w: safe.w * 0.8, h: safe.y + safe.h - top - textH - gap * 1.4 - ctaH };
+ const textTop = side ? safe.y + (safe.h - ctaH - textH) / 2 + (sign?.h ?? 0) * 0.6 : picBox.y + picBox.h + gap;
+ const head = head0 ? c.set("headline", c.field("headline"), { role: "hero", x: textX, y: textTop, width: textW, maxLines: 3, max: head0.size, min: head0.size, align: side ? "left" : "centre", preset: "cut-rise" }) : null;
+ // The call to action's drawn underline.
+ const ruleY = footBase + Math.max(S * 0.007, ctaSize * 0.28);
- // The picture standing on its line.
- const img = hero ? fitBox(hero, picBox, true) : null;
- const outline = hero?.src === "product" ? (c.input.outlines?.product ?? null) : null;
+ const hero = prod ?? (logo ? { w: logo.w, h: logo.h } : null);
+ const img = hero ? fitBox(hero, prod ? picBox : { ...picBox, y: picBox.y + picBox.h * 0.3, h: picBox.h * 0.4 }, true) : null;
+ const outline = prod ? (c.input.outlines?.product ?? null) : null;
let trace: { d: string; length: number; m?: Matrix; scale: number } | null = null;
- let start: [number, number] = [design.w / 2, picBox.y + picBox.h];
+ let start: [number, number] = [cx, picBox.y + picBox.h];
if (img && outline) {
const k = img.w / outline.w;
trace = { d: outline.d, length: outline.length, m: [k, 0, 0, k, img.x, img.y], scale: k };
start = [img.x + outline.start[0] * k, img.y + outline.start[1] * k];
} else if (img) {
const pad = S * 0.03;
- const f = framePath(img.x - pad, img.y - pad, img.w + 2 * pad, img.h + 2 * pad, S * 0.035);
- trace = { ...f, scale: 1 };
+ trace = { ...framePath(img.x - pad, img.y - pad, img.w + 2 * pad, img.h + 2 * pad, S * 0.035), scale: 1 };
start = [img.x + img.w / 2, img.y + img.h + pad];
}
const foot = start[1];
const lineFrom = side ? picBox.x : safe.x;
const lineTo = side ? picBox.x + picBox.w : safe.x + safe.w;
- // The arch of the brand's colour behind the product (a soft tint of it on the ground).
- const archW = img ? Math.min(picBox.w * 0.92, Math.max(img.w * 1.35, img.h * 0.62)) : 0;
- const archH = img ? Math.min(foot - picBox.y + S * 0.02, Math.max(img.h * 1.08, archW * 0.9)) : 0;
- const archFill = mixHex(pal.ground, pal.look === "light" ? pal.accent : pal.mark, pal.look === "light" ? 0.12 : 0.2);
- const arch = img ? archPath(start[0], foot, archW, archH) : "";
+ const archW = img ? Math.min(picBox.w * 0.95, Math.max(img.w * 1.5, img.h * 0.66)) : 0;
+ const archH = img ? Math.min(foot - picBox.y + S * 0.03, Math.max(img.h * 1.12, archW * 0.95)) : 0;
const archBox = { x: start[0] - archW / 2, y: foot - archH, w: archW, h: archH };
- // The words under the picture (beside it on a wide frame).
- const textTop = side ? safe.y + (safe.h - textH) / 2 : Math.min(safe.y + safe.h - textH, foot + gapPic);
- const headB = head ? textBlock("headline", head, { y: textTop, color: pal.ink, ...(side ? { left: textLeft, width: textW } : { cx: design.w / 2 }) }) : null;
- const ctaY = textTop + (head ? head.height + gapT : 0);
- const ctaB = cta ? textBlock("cta", cta, { y: ctaY, color: pal.ink, ...(side ? { left: textLeft, width: textW } : { cx: design.w / 2 }) }) : null;
- const markTop = side ? ctaY + ctaH + S * 0.06 : safe.y;
- const markCx = side ? textLeft + (mark?.w ?? 0) / 2 : design.w / 2;
+ const k = c.spread(3.3, 1.6);
+ const traceDur = Math.min(1.3, 1.05 * k);
+ c.ev("ground.a", "draw", 0, 0.4 * k, "draw");
+ if (trace) c.ev("trace", "draw", 0.3 * k, traceDur, "draw");
+ c.ev("ground.b", "draw", 0.3 * k + traceDur - 0.08, 0.35 * k, "draw");
+ const fillAt = 0.3 * k + traceDur * 0.75;
+ if (img) {
+ c.ev("arch", "draw", fillAt - 0.15, 0.85, "glide");
+ c.ev("fill", "draw", fillAt, 0.75, "glide");
+ c.ev("trace.out", "fade", fillAt + 0.5, 0.5, "enter");
+ }
+ // The headline starts while the line is still tracing (by 0.9 s).
+ const headPlan = head ? c.move(head, { in: "cut-rise", at: Math.min(0.9, fillAt - 0.2), hero: true }) : null;
+ const headDone = headPlan?.settled ?? fillAt + 0.6;
+ c.ev("sweep", "move", headDone - 0.3, 0.85, "move");
+ const ctaPlan = cta ? c.move(cta, { in: "slow-drift", at: headDone - 0.35 }) : null;
+ c.ev("cta.rule", "draw", headDone + 0.05, 0.55, "draw");
+ const signPlan = signIn(c, sign, "brand", 0.15);
+ const sitePlan = site ? c.move(site, { in: "fade-rise", at: headDone + 0.2, rate: 30 }) : null;
+ const notePlan = note ? c.move(note, { in: "fade-rise", at: headDone + 0.1, rate: 30 }) : null;
- // Paced to the clip: a longer one draws more slowly (up to a point) and leaves more room between the beats.
- const k = spread(c, 3.1, 1.8);
- const traceDur = Math.min(1.8, 1.25 * k);
- const lines = head?.lines.length ?? 0;
- const fillAt = 0.32 * k + traceDur * 0.75;
- const wordsAt = fillAt + 0.55 * k;
- const ctaAt = wordsAt + 0.3 * k + lines * 0.09;
- const events = [
- ev("ground.a", "draw", 0, 0.4 * k, "draw"),
- ...(trace ? [ev("trace", "draw", 0.32 * k, traceDur, "draw")] : []),
- ev("ground.b", "draw", 0.32 * k + traceDur - 0.08, 0.35 * k, "draw"),
- ...(img ? [ev("arch", "draw", fillAt - 0.15, 0.85 * k, "glide"), ev("fill", "draw", fillAt, 0.75 * k, "glide"), ev("shadow", "fade", fillAt + 0.1, 0.6, "enter"), ev("trace.out", "fade", fillAt + 0.55 * k, 0.5, "enter")] : []),
- ...Array.from({ length: lines }, (_, i) => ev(`head.${i}`, "enter", wordsAt + i * 0.09, 0.55, "glide", { group: "head", unit: "elements" })),
- ...(cta ? [ev("cta", "enter", ctaAt, 0.45, "glide"), ev("cta.line", "draw", ctaAt + 0.15, 0.5, "draw")] : []),
- ...(mark ? [ev("brand", "enter", ctaAt + 0.45 * k, 0.6, "glide")] : []),
- ];
+ const lineColor = c.dark ? pal.accent : mixOk(pal.brand[0], pal.ink, 0.2);
+ const archFill = mixOk(pal.ground, pal.brand[1], c.dark ? 0.12 : 0.22);
return {
- events,
- overflow: [...(head?.overflow ? ["headline"] : []), ...(cta?.overflow ? ["cta"] : []), ...(mark?.overflow ? ["brand"] : [])],
- signature: 0.32 * k + traceDur * 0.6,
- frame(_t, P, Lp) {
- const nodes: DisplayNode[] = [];
- const a = P("arch");
- if (a > 0 && img) nodes.push(riseReveal([{ type: "path", d: arch, fill: archFill }], archBox, a, archH * 0.1));
- const ga = P("ground.a");
- const gb = P("ground.b");
- if (ga > 0) nodes.push({ type: "path", d: `M${lineFrom} ${foot}H${start[0]}`, stroke: { paint: line, width, trim: ga, length: start[0] - lineFrom, cap: "round" } });
- if (gb > 0) nodes.push({ type: "path", d: `M${start[0]} ${foot}H${lineTo}`, stroke: { paint: line, width, trim: gb, length: lineTo - start[0], cap: "round" } });
- if (img && hero) {
- const sh = P("shadow");
- if (sh > 0) nodes.push(contactShadow(start[0], foot, img.w * 0.8, archFill, 0.3, sh));
- const fill = P("fill");
- const pic: DisplayNode = hero.src === "logo" ? logoNode(c, img, pal.ink) : { type: "image", src: hero.src, x: img.x, y: img.y, w: img.w, h: img.h };
- if (fill > 0) nodes.push(riseReveal([pic], img, fill, img.h * 0.12));
+ overflow: [...(head?.overflow ? ["headline"] : []), ...(cta?.overflow ? ["cta"] : []), ...(sign?.overflow ? ["brand"] : []), ...(site?.overflow ? ["website"] : []), ...(note?.overflow ? ["note"] : [])],
+ signature: 0.3 * k + traceDur * 0.6,
+ draw(t, kit) {
+ const field = c.dark ? litField(c, t, { from: "tl" }) : paperField(c, t, { tint: pal.brand[1], light: 0.6 });
+ const atmosphere: DisplayNode[] = [];
+ const a = kit.P("arch");
+ // The arch grows up from the floor, an arch at every moment (never a box).
+ if (a > 0 && img) {
+ const h = Math.max(archW / 2 + 1, archH * a);
+ atmosphere.push({ type: "path", d: archPath(start[0], foot, archW, h), fill: { kind: "linear", x0: 0, y0: archBox.y, x1: 0, y1: foot, stops: [{ at: 0, color: mixOk(archFill, pal.ground, 0.3) }, { at: 1, color: archFill }] }, ...(a < 0.35 && { opacity: a / 0.35 }) });
+ }
+ // (no frame: one line system)
+ const subject: DisplayNode[] = [];
+ const ga = kit.P("ground.a");
+ const gb = kit.P("ground.b");
+ if (ga > 0) subject.push({ type: "path", d: `M${lineFrom} ${foot}H${start[0]}`, stroke: { paint: lineColor, width, trim: ga, length: Math.max(1, start[0] - lineFrom), cap: "round" } });
+ if (gb > 0) subject.push({ type: "path", d: `M${start[0]} ${foot}H${lineTo}`, stroke: { paint: lineColor, width, trim: gb, length: Math.max(1, lineTo - start[0]), cap: "round" } });
+ if (img) {
+ const fill = kit.P("fill");
+ if (fill > 0) {
+ const pic: DisplayNode = prod ? productNode({ src: "product", box: img, ground: archFill, t, sweepAt: headDone - 0.3, sweepDur: 0.85, key: "lr" }) : logoNode(c, img, pal.ink);
+ subject.push(riseReveal([pic], { x: img.x - img.w * 0.5, y: img.y, w: img.w * 2, h: img.h + S * 0.02 }, fill, img.h * 0.12));
+ }
}
if (trace) {
- const tr = P("trace");
- const out = P("trace.out");
- if (tr > 0 && out < 1) nodes.push({ type: "path", d: trace.d, ...(trace.m && { transform: trace.m }), stroke: { paint: line, width: width / trace.scale, trim: tr, length: trace.length, cap: "round", join: "round" }, ...(out > 0 && { opacity: 1 - out }) });
+ const tr = kit.P("trace");
+ const out = kit.P("trace.out");
+ if (tr > 0 && out < 1) subject.push({ type: "path", d: trace.d, ...(trace.m && { transform: trace.m }), stroke: { paint: lineColor, width: width / trace.scale, trim: tr, length: trace.length, cap: "round", join: "round" }, ...(out > 0 && { opacity: 1 - out }) });
}
- if (headB) nodes.push(...risingLines(headB, (i) => P(`head.${i}`)));
- if (ctaB && cta) {
- const p = P("cta");
- if (p > 0) nodes.push(group([lineRuns(ctaB)], { transform: [1, 0, 0, 1, 0, (1 - p) * S * 0.02], ...(p < 1 && { opacity: p }) }));
- const u = P("cta.line");
- if (u > 0) {
- const w0 = cta.lines[0]?.width ?? 0;
- const x0 = side ? (cta.dir === "rtl" ? textLeft + textW - w0 : textLeft) : design.w / 2 - w0 / 2;
- const y0 = ctaY + cta.size * 1.32;
- nodes.push({ type: "path", d: `M${x0} ${y0}H${x0 + w0}`, stroke: { paint: pal.mark, width: Math.max(2, S * 0.004), trim: u, length: w0, cap: "round" } });
- }
+ const heroN: DisplayNode[] = headPlan ? kit.type(headPlan, { fill: pal.ink }) : [];
+ const meta: DisplayNode[] = [];
+ if (ctaPlan && cta) {
+ meta.push(...kit.type(ctaPlan, { fill: metaInk(pal) }));
+ const u = kit.P("cta.rule");
+ if (u > 0) meta.push(rule({ x: cta.ink.x, y: ruleY, w: cta.ink.w, color: lineColor, p: u, width: Math.max(1.5, S * 0.0019) }));
}
- if (mark) nodes.push(...mark.draw(markCx, markTop, P("brand"), Lp("brand")));
- return { nodes };
+ if (sitePlan) meta.push(...kit.type(sitePlan, { fill: metaInk(pal) }));
+ if (notePlan) meta.push(...kit.type(notePlan, { fill: metaInk(pal) }));
+ meta.push(...signNodes(c, kit, sign, signPlan, "brand", side ? textX : cx - (sign?.w ?? 0) / 2, safe.y, pal.ink));
+ return [
+ { role: "ground", nodes: field },
+ { role: "atmosphere", nodes: atmosphere },
+ { role: "subject", nodes: subject, push: 0.04 },
+ { role: "hero", nodes: heroN },
+ { role: "meta", nodes: meta },
+ ];
},
};
},
diff --git a/src/lib/motion/scenes/marketing/logo-sting.ts b/src/lib/motion/scenes/marketing/logo-sting.ts
index 9ee55758..54c33fcf 100644
--- a/src/lib/motion/scenes/marketing/logo-sting.ts
+++ b/src/lib/motion/scenes/marketing/logo-sting.ts
@@ -1,220 +1,107 @@
/**
- * Logo Sting: the mark is made from itself. Two hairlines sweep out from the middle and fall away; then the mark
- * assembles: an SVG logo traces its own outlines on and fills in, any other logo (or the brand's name set in type) comes
- * together from shards cut out of it, which drift or fly home from round the frame. The instant it is whole, a flash
- * and a ring of light go out from it, it settles, a glint crosses it, and the line under it rises.
- *
- * The Pace sets the language: Calm is fine and quiet (short drifts, little turn, long hairlines), Punchy flies the shards
- * in from farther with more turn and a kick of the camera. The shards' cuts and paths come from the recipe's seed.
+ * Logo Sting: a type event. The brand's name, as written, is set as a justified stack that fills the width in the
+ * hero face and rises letter by letter from under its own line in polished light metal; the brand's mark lands after
+ * it as the punctuation, and the line under it cuts up in the accent italic. Behind, rows of the name in giant filled
+ * tonal type cross the frame and drift opposite ways; a soft horizon of light sits under the name. The address and a
+ * corner note sit on the corners, an index arrow in the last. Through the hold the type plane pushes in and a band of
+ * light crosses the name twice. The last frame is the poster.
*/
-import { about, group, multiply, translate, withAlpha, type DisplayNode } from "../../display";
-import { noise1, rng, rngRange } from "../../random";
-import { local } from "../../time";
-import { lineRuns, logoPaths } from "../end-card/shared";
-import { ev, logoNode, marketingScene, MIN_BODY, MIN_HEAD, sampleMark, setText, spread, textBlock } from "./kit";
+import { about, group, type DisplayNode, type Paint } from "../../display";
+import { ensureContrast, fieldStops, mixOk, withLightness } from "../../color";
+import { bands, capBand, fitLines, footRow, ghost, litField, metaInk, moveLines, posterScene, shadowed, stackLanded, topSite } from "./poster";
+import { logoNode, sampleMark } from "./kit";
-interface Shard {
- d: string;
- /** Its middle, and where it starts from (relative), its turn and when it leaves. */
- cx: number;
- cy: number;
- dx: number;
- dy: number;
- turn: number;
- at: number;
-}
-
-/** A box cut into triangles on a jittered grid (the inner points moved by the seed), as closed paths. */
-export function shardCuts(box: { x: number; y: number; w: number; h: number }, cols: number, rows: number, seed: number): { d: string; cx: number; cy: number }[] {
- const pt = (i: number, j: number): [number, number] => {
- const inner = i > 0 && i < cols && j > 0 && j < rows;
- const jx = inner ? rngRange(-0.32, 0.32, seed, "jx", i, j) : 0;
- const jy = inner ? rngRange(-0.32, 0.32, seed, "jy", i, j) : 0;
- return [box.x + ((i + jx) / cols) * box.w, box.y + ((j + jy) / rows) * box.h];
- };
- const out: { d: string; cx: number; cy: number }[] = [];
- const tri = (a: [number, number], b: [number, number], c: [number, number]) =>
- out.push({ d: `M${a[0].toFixed(2)} ${a[1].toFixed(2)}L${b[0].toFixed(2)} ${b[1].toFixed(2)}L${c[0].toFixed(2)} ${c[1].toFixed(2)}Z`, cx: (a[0] + b[0] + c[0]) / 3, cy: (a[1] + b[1] + c[1]) / 3 });
- for (let j = 0; j < rows; j++)
- for (let i = 0; i < cols; i++) {
- const p00 = pt(i, j);
- const p10 = pt(i + 1, j);
- const p01 = pt(i, j + 1);
- const p11 = pt(i + 1, j + 1);
- // The diagonal alternates, so the cuts read as facets, not a grid.
- if ((i + j) % 2 === 0) {
- tri(p00, p10, p11);
- tri(p00, p11, p01);
- } else {
- tri(p00, p10, p01);
- tri(p10, p11, p01);
- }
- }
- return out;
-}
-
-export default marketingScene({
+export default posterScene({
id: "marketing/logo-sting",
name: "Logo Sting",
- look: "brand",
+ pairing: "T3",
+ look: "dark",
build(c) {
- const { S, safe, palette: pal, design, recipe } = c;
- const seed = recipe.seed;
- const cx = design.w / 2;
- const logo = c.input.logo;
- const calm = recipe.controls?.pace === "calm";
- const punchy = recipe.controls?.pace === "punchy";
- // The mark's box, a little above the middle.
- const markW = Math.min(safe.w * 0.86, S * 0.84);
- const markH = S * (logo && logo.w / logo.h > 3 ? 0.24 : 0.32);
- const tagline = setText(c, c.field("tagline"), { family: "body", weight: 500, width: Math.min(safe.w, S * 1.1), maxLines: 2, max: S * 0.056, min: S * MIN_BODY, lineHeight: 1.25 });
- const name = !logo ? setText(c, recipe.brand.name, { weight: 800, width: Math.min(safe.w, S * 1.2), maxLines: 2, max: S * 0.14, min: S * MIN_HEAD, lineHeight: 1.04 }) : null;
- const box = logo
- ? (() => {
- const s = Math.min(markW / logo.w, markH / logo.h);
- return { w: logo.w * s, h: logo.h * s };
- })()
- : name
- ? { w: name.width, h: name.height }
- : { w: S * 0.2, h: S * 0.1 };
- const gap = S * 0.06;
- const stackH = box.h + (tagline ? gap + tagline.height : 0);
- const top = design.h / 2 - stackH / 2 - S * 0.02;
- const mark = { x: cx - box.w / 2, y: top, w: box.w, h: box.h };
- const mcx = mark.x + mark.w / 2;
- const mcy = mark.y + mark.h / 2;
- const nameB = name ? textBlock("brand", name, { y: top, color: pal.ink, cx }) : null;
- const tagB = tagline ? textBlock("tagline", tagline, { y: top + box.h + gap, color: pal.muted, cx }) : null;
- const tint = !!logo && sampleMark(c);
+ const { S, safe, pal, design } = c;
+ const name = c.recipe.brand.name.trim();
+ const logo = c.input.logo && c.input.logo.w > 0 && c.input.logo.h > 0 ? c.input.logo : null;
+ const metaSize = S * (c.cover ? 0.024 : 0.02);
+ // The mark, never the name again (the name is the hero): a symbol logo as it is; the sample lockups by their
+ // symbol alone (the square at their left); a wide wordmark is left out of the corner.
+ const markH = S * (c.cover ? 0.06 : 0.05);
+ const aspect = logo ? logo.w / logo.h : 0;
+ const crop = logo && aspect > 1.6 && sampleMark(c) ? { x: 0, y: 0, w: 1 / aspect, h: 1 } : undefined;
+ const mark = logo && (aspect <= 1.6 || crop) ? { w: crop ? markH : Math.min(S * 0.2, markH * aspect), h: markH, crop } : null;
+ const site = topSite(c, mark ? { w: mark.w, h: mark.h, overflow: false, set: null, nodes: () => [] } : null, metaSize, { width: safe.w * 0.55 });
- /** The mark as it rests (a sample lockup set in the look's ink; a person's own logo as it is). */
- const whole = (): DisplayNode[] => (logo ? [logoNode(c, mark, pal.ink)] : nameB ? [lineRuns(nameB)] : []);
- /** The mark's raw pieces (untinted), for the shards. */
- const raw = (): DisplayNode[] => (logo ? [{ type: "image", src: "logo", ...mark }] : nameB ? [lineRuns(nameB)] : []);
+ const b = bands(c, { topRow: mark?.h ?? metaSize, gap: S * 0.07 });
+ const tagSize = S * (c.cover ? 0.058 : 0.05);
+ const width = c.wide ? safe.w * 0.7 : safe.w;
+ // The name fills the width; the tagline hangs under it (its room kept below).
+ const tag0 = c.set("tagline", c.field("tagline"), { role: "accent", x: safe.x, y: 0, width, maxLines: 2, max: tagSize, min: S * 0.036, align: "left", preset: "cut-rise" });
+ const tagH = tag0 ? capBand(tag0).h + S * 0.07 : 0;
+ const hero = name ? fitLines(c, "brand", name, { family: c.recipe.brand.fonts.heading?.trim() || undefined, weight: 700, tracking: 0, x: safe.x, top: b.top, room: b.bottom - b.top - tagH, centre: design.h * 0.45 - tagH / 2, width, maxLines: 2, max: c.wide ? design.h * 0.32 : S * 0.42, min: S * 0.08, align: "left", preset: "focus-in", fill: 0.99, ratio: 1.5, gap: 0.16 }) : null;
+ const tagY = hero ? hero.band.y + hero.band.h + S * 0.06 : b.top;
+ const tag = tag0 && hero ? c.set("tagline", c.field("tagline"), { role: "accent", x: safe.x, y: tagY, width, maxLines: 2, max: tag0.size, min: tag0.size, align: "left", preset: "cut-rise" }) : tag0;
- // An SVG logo traces its own outlines; anything else assembles from shards of itself.
- const svg = logo?.kind === "svg" && logo.paths?.length ? logoPaths(logo, mark) : null;
- const traceGroups = svg ? Math.min(svg.length, 8) : 0;
- const pad = S * 0.01;
- const cutBox = { x: mark.x - pad, y: mark.y - pad, w: mark.w + 2 * pad, h: mark.h + 2 * pad };
- const cols = Math.max(3, Math.min(8, Math.round((cutBox.w / cutBox.h) * 2)));
- const rows = cutBox.h / cutBox.w > 0.5 ? 3 : 2;
- const reach = S * (calm ? 0.09 : punchy ? 0.5 : 0.3);
- const spin = calm ? 0.18 : punchy ? 1.3 : 0.7;
- const shards: Shard[] = svg
- ? []
- : shardCuts(cutBox, cols, rows, seed).map((s, i) => {
- // Out from the middle of the mark, bent a little by the seed.
- const a = Math.atan2(s.cy - mcy, (s.cx - mcx) * 0.6) + rngRange(-0.5, 0.5, seed, "a", i);
- const r = reach * rngRange(0.65, 1.15, seed, "r", i);
- return { ...s, dx: Math.cos(a) * r, dy: Math.sin(a) * r * 0.8, turn: rngRange(-1, 1, seed, "t", i) * spin, at: rng(seed, "at", i) };
- });
+ const k = c.spread(2.8, 1.6);
+ // Its own move: the name racks into focus word by word from a soft, slightly larger blur (a lens finding it); a
+ // glint of light crosses the metal once it has settled, and again later.
+ const plans = hero ? moveLines(c, hero, { in: "focus-in", at: 0, hero: true, loop: "light-sweep", loopAt: 1.6, loopEvery: 1.8 }, "brand", 0.16) : [];
+ const landed = plans.length ? stackLanded(plans) : 0.8;
+ const tagPlan = tag ? c.move(tag, { in: "cut-rise", at: landed + 0.1 * k }) : null;
+ // The mark lands last, the punctuation: it pops in with a small turn that settles.
+ if (mark) c.ev("mark", "pop", Math.max(landed + 0.25, (tagPlan?.settled ?? landed) - 0.1), 0.55, "pop");
+ const sitePlan = site ? c.move(site, { in: "fade-rise", at: 0.3, rate: 26 }) : null;
+ const row = footRow(c, (tagPlan?.settled ?? landed) + 0.1);
- // The beats, spread over the length.
- const k = spread(c, 2.8, 2.4);
- const lines0 = 0.05;
- const lineDur = (calm ? 0.95 : 0.7) * Math.min(1.4, k);
- const build0 = lines0 + lineDur * 0.45;
- const buildDur = (calm ? 1.35 : punchy ? 0.95 : 1.1) * Math.min(1.5, k);
- const fly = calm ? 0.95 * Math.min(1.4, k) : punchy ? 0.6 : 0.75;
- const click = build0 + buildDur;
- const events = [
- ev("lines", "draw", lines0, lineDur, "draw"),
- ev("lines.out", "exit", lines0 + lineDur * 0.8, 0.5 * Math.min(1.4, k), "move"),
- ...(svg
- ? [
- ...Array.from({ length: traceGroups }, (_, g) => ev(`trace.${g}`, "draw", build0 + g * Math.min(0.08, Math.max(0.04, (buildDur - 0.7) / Math.max(1, traceGroups))), 0.7, "draw", { group: "trace", unit: "words" })),
- ev("fill", "fade", click - 0.25, 0.4, "enter"),
- ]
- : shards.map((s, i) => ev(`shard.${i}`, "enter", build0 + s.at * (buildDur - fly), fly, calm ? "glide" : "enter"))),
- ev("flash", "fade", click, 0.45, "enter"),
- ev("ring", "fade", click - 0.02, 0.75, "enter"),
- ev("settle", "enter", click, 0.8, "settle"),
- ev("glint", "move", click + 0.35 * k, 0.9, "move"),
- ...(tagline ? [ev("tagline", "enter", click + 0.5 * k, 0.6, "glide")] : []),
- ];
- const shake = punchy ? { from: click, to: click + 0.3, amp: S * 0.007 } : null;
- const hair = Math.max(1.2, S * 0.0022);
- const span = Math.min(safe.w * 0.48, mark.w * 0.75 + S * 0.08);
- const ly = [mark.y - S * 0.05, mark.y + mark.h + S * 0.05 - (tagline ? gap * 0.3 : 0)];
- const flashTone = pal.look === "light" ? pal.mark : "#ffffff";
+ // One row of the name behind, at the foot: below the corner row, whole words from the left margin, cropped only by
+ // the bottom edge, one faint step from the field.
+ const stops = fieldStops(pal);
+ const ghostGround = mixOk(stops.dark, stops.light, 0.25);
+ const rowSize = S * (c.wide ? 0.3 : 0.36);
+ const repeat = name ? Array.from({ length: 3 }, () => name).join(" ") : "";
+ const rowY = safe.y + safe.h + S * 0.045;
+ // Light metal (dark looks): a bright top, a cool tinted shoulder, a soft darker horizon at the middle, paper again,
+ // then a pale tinted foot, smoothly blended (chrome, never one hard stripe).
+ const tint = mixOk(pal.paper, pal.brand[0], 0.25);
+ const metal = (s: { lines: { y: number; baseline: number }[]; cap: { top: number } }): Paint => {
+ const top = s.lines[0].y + s.cap.top;
+ const bot = s.lines[0].baseline;
+ return c.dark
+ ? { kind: "linear", x0: 0, y0: top, x1: 0, y1: bot, stops: [{ at: 0, color: "#ffffff" }, { at: 0.38, color: ensureContrast(withLightness(tint, 0.88), pal.ground, 4.5) }, { at: 0.5, color: ensureContrast(withLightness(tint, 0.68), pal.ground, 4.5) }, { at: 0.62, color: pal.paper }, { at: 1, color: ensureContrast(withLightness(tint, 0.93), pal.ground, 4.5) }] }
+ : pal.ink;
+ };
return {
- events,
- overflow: [...(name?.overflow ? ["brand"] : []), ...(tagline?.overflow ? ["tagline"] : [])],
- signature: click - 0.12,
- cuts: [],
- camera: (t) => {
- if (!shake || t < shake.from || t >= shake.to) return { zoom: 1, x: 0, y: 0 };
- const fade = 1 - local(t, shake.from, shake.to);
- return { zoom: 1 + 0.01 * fade, x: noise1(seed, "kx", t * 38) * shake.amp * fade, y: noise1(seed, "ky", t * 38) * shake.amp * fade };
- },
- frame(_t, P, Lp) {
- const nodes: DisplayNode[] = [];
- // The hairlines: out from the middle above and below, then away to the sides.
- const grow = P("lines");
- const gone = P("lines.out");
- if (grow > 0 && gone < 1)
- for (const y of ly)
- for (const dir of [-1, 1]) {
- const a = cx + dir * span * gone;
- const b = cx + dir * span * Math.max(gone, grow);
- if (Math.abs(b - a) > 0.5) nodes.push({ type: "path", d: `M${a.toFixed(2)} ${y.toFixed(2)}H${b.toFixed(2)}`, stroke: { paint: pal.mark, width: hair, cap: "round" } });
- }
- // The ring of light where it comes together.
- const ring = Lp("ring");
- if (ring > 0 && ring < 1) {
- const r = Math.max(mark.w, mark.h) * (0.45 + 0.4 * P("ring"));
- nodes.push({ type: "ellipse", cx: mcx, cy: mcy, rx: r, ry: r * (mark.h / mark.w > 0.6 ? 1 : 0.62), stroke: { paint: pal.mark, width: hair * 1.4 + S * 0.006 * (1 - ring) }, opacity: 1 - ring });
+ overflow: [...(hero?.overflow ? ["brand"] : []), ...(tag?.overflow ? ["tagline"] : []), ...(site?.overflow ? ["website"] : []), ...row.overflow],
+ signature: landed + 0.3,
+ camera: (t) => ({ x: 0, y: -18 * (1 - Math.min(1, t / c.last)) ** 2 }),
+ draw(t, kit) {
+ const field = litField(c, t, { from: "tl", stops });
+ const ghosts: DisplayNode[] = repeat ? [ghost(c, { field: "brand", lines: [repeat], size: rowSize, x: safe.x, y: rowY, t, leading: 1, ground: ghostGround, dir: 1, weight: 700, family: c.recipe.brand.fonts.heading?.trim() || undefined })] : [];
+ const atmosphere: DisplayNode[] = [];
+ const heroNodes: DisplayNode[] = [];
+ if (hero) {
+ const words = hero.sets.flatMap((s, i) => kit.type(plans[i], { fill: metal(s), sweep: "#ffffff", sweepAlpha: 0.55 }));
+ if (t >= landed) heroNodes.push(...shadowed(c, words, hero.size, hero.band, `ls|${name}|${hero.size}`));
+ heroNodes.push(...words);
}
- const settle = P("settle");
- const s = Lp("settle") > 0 ? 1.035 - 0.035 * settle : 1;
- const fill = svg ? P("fill") : Lp("flash") > 0 ? 1 : 0;
- const ms: DisplayNode[] = [];
- if (svg) {
- // The outlines trace on in the words' colour, and the mark fills in under them.
- if (fill > 0) ms.push(fill < 1 ? group(whole(), { opacity: fill }) : group(whole()));
- if (fill < 1) {
- const width = Math.max(1.2, mark.h * 0.012);
- svg.forEach((p, i) => {
- const trim = P(`trace.${Math.floor((i * traceGroups) / svg.length)}`);
- if (trim > 0) ms.push({ type: "path", d: p.d, transform: p.m, stroke: { paint: pal.ink, width: width / p.scale, trim, length: p.length, cap: "round", join: "round" }, ...(fill > 0 && { opacity: 1 - fill }) });
- });
+ const meta: DisplayNode[] = [];
+ if (mark) {
+ const lin = kit.L("mark");
+ if (lin > 0) {
+ const p = kit.P("mark");
+ const node = logoNode(c, { x: safe.x, y: safe.y, w: mark.w, h: mark.h, ...(mark.crop && { crop: mark.crop }) }, pal.ink);
+ meta.push(group([node], { ...(p < 1 && { transform: about(safe.x + mark.w / 2, safe.y + mark.h / 2, 0.6 + 0.4 * p, (1 - Math.min(1, p)) * -0.105) }), ...(lin < 0.4 && { opacity: lin / 0.4 }) }));
}
- } else if (fill >= 1) ms.push(...whole());
- else {
- // The shards of the mark, each clipped to its own cut, coming home.
- const pieces: DisplayNode[] = [];
- shards.forEach((sh, i) => {
- const lin = Lp(`shard.${i}`);
- if (lin <= 0) return;
- const u = 1 - P(`shard.${i}`);
- const m = multiply(translate(u * sh.dx, u * sh.dy), about(sh.cx, sh.cy, 1 + u * (calm ? 0.08 : 0.25), u * sh.turn));
- pieces.push(group(raw(), { clip: { type: "path", d: sh.d }, transform: m, ...(lin < 0.35 && { opacity: lin / 0.35 }) }));
- });
- if (pieces.length) ms.push(tint ? group([...pieces, group([{ type: "rect", x: 0, y: 0, w: design.w, h: design.h, fill: pal.ink }], { blend: "source-atop" })], { isolate: { x: 0, y: 0, w: design.w, h: design.h } }) : group(pieces));
- }
- // The glint crosses the whole mark once it has settled.
- const g = Lp("glint");
- if (fill >= 1 && g > 0 && g < 1) {
- const band = mark.w * 0.3;
- const x = mark.x - band + (mark.w + 2 * band) * P("glint");
- const glint: DisplayNode = { type: "rect", x: x - band, y: mark.y - mark.h, w: band * 2, h: mark.h * 3, fill: { kind: "linear", x0: x - band, y0: 0, x1: x + band, y1: 0, stops: [{ at: 0, color: "rgba(255,255,255,0)" }, { at: 0.5, color: pal.look === "light" ? "rgba(255,255,255,0.7)" : "rgba(255,255,255,0.5)" }, { at: 1, color: "rgba(255,255,255,0)" }] } };
- const ink: DisplayNode[] = tint ? [group([{ type: "rect", x: mark.x - 4, y: mark.y - 4, w: mark.w + 8, h: mark.h + 8, fill: pal.ink }], { blend: "source-atop" })] : [];
- nodes.push(group([...raw(), ...ink, group([glint], { blend: "source-atop" })], { transform: about(mcx, mcy, s), isolate: { x: mark.x - 6, y: mark.y - 6, w: mark.w + 12, h: mark.h + 12 } }));
- } else if (ms.length) nodes.push(s !== 1 ? group(ms, { transform: about(mcx, mcy, s) }) : ms.length === 1 ? ms[0] : group(ms));
- // The flash: a bloom of light off the mark the instant it is whole.
- const f = P("flash");
- if (Lp("flash") > 0 && f < 1) {
- const R = Math.max(mark.w, mark.h) * 0.62;
- nodes.push(group([{ type: "ellipse", cx: mcx, cy: mcy, rx: R, ry: R * 0.7, fill: { kind: "radial", cx: mcx, cy: mcy, r0: 0, r1: R, stops: [{ at: 0, color: withAlpha(flashTone, 0.22 * (1 - f)) }, { at: 1, color: withAlpha(flashTone, 0) }] } }], { blend: pal.look === "light" ? "multiply" : "screen" }));
- }
- if (tagB) {
- const p = P("tagline");
- if (p > 0) nodes.push(group([lineRuns(tagB)], { transform: translate(0, (1 - p) * S * 0.025), ...(p < 1 && { opacity: p }) }));
}
- return { nodes };
+ if (tagPlan) meta.push(...kit.type(tagPlan, { fill: pal.ink }));
+ if (sitePlan) meta.push(...kit.type(sitePlan, { fill: metaInk(pal), caret: pal.accent }));
+ meta.push(...row.draw(kit, metaInk(pal), pal.ink));
+ return [
+ { role: "ground", nodes: field },
+ { role: "atmosphere", nodes: atmosphere },
+ { role: "ghost", nodes: ghosts },
+ { role: "hero", nodes: heroNodes },
+ { role: "meta", nodes: meta },
+ ];
},
};
},
diff --git a/src/lib/motion/scenes/marketing/lookbook.ts b/src/lib/motion/scenes/marketing/lookbook.ts
new file mode 100644
index 00000000..731bb456
--- /dev/null
+++ b/src/lib/motion/scenes/marketing/lookbook.ts
@@ -0,0 +1,112 @@
+/**
+ * Runway Titles: lookbook titles over a full-bleed editorial photograph. The photo pushes in from wide; a fine
+ * keyline frame draws round the page; the title cuts up letter by letter as a justified stack in a huge condensed face
+ * at the foot, a line every 140 ms, and a single script word draws itself on across the top of its first line's last
+ * word at −8°, in the accent with a dark keyline so it reads on the caps and the photo alike. The house and the address
+ * sit on the top corners, the line and the corner note on the bottom ones, small against the title.
+ */
+
+import { group, type DisplayNode } from "../../display";
+import { ensureContrast, mixOk } from "../../color";
+import { photo as photoNode } from "../../fx/photo";
+import { rotation } from "../../fx/overlays";
+import { brandSign, capAt, capBand, fadeScrim, fitLines, meshField, moveLines, onBaseline, posterScene, rgba, shadowed, signIn, signNodes, stackLanded, topSite } from "./poster";
+
+export default posterScene({
+ id: "marketing/lookbook",
+ name: "Runway Titles",
+ pairing: "T1",
+ look: "dark",
+ build(c) {
+ const { S, safe, pal, design } = c;
+ const side = c.wide;
+ const pic = c.recipe.media?.product ? c.input.images?.product : undefined;
+ const colW = side ? safe.w * 0.56 : safe.w;
+ const signH = S * (c.cover ? 0.066 : 0.05);
+ const sign = brandSign(c, { maxW: S * 0.42, h: signH, x: safe.x, y: safe.y, min: S * (c.cover ? 0.06 : 0.03) });
+ const metaSize = S * (c.cover ? 0.02 : 0.018);
+ // The address on the top-right corner (beside the house), the line and the corner note on the bottom corners.
+ const site = topSite(c, sign, metaSize, { width: safe.w * 0.45 });
+ const footBase = safe.y + safe.h - metaSize * 0.25;
+ const line = onBaseline(c, "line", c.field("line"), { role: "meta", x: safe.x, width: safe.w * 0.6, maxLines: 1, max: metaSize, min: S * 0.016, align: "left", preset: "fade-rise", y: 0 }, footBase);
+ const note = onBaseline(c, "note", c.field("note"), { role: "meta", x: safe.x + safe.w * 0.6, width: safe.w * 0.4, maxLines: 1, max: metaSize, min: S * 0.016, align: "right", preset: "fade-rise", y: 0 }, footBase);
+
+ // The title: as big as the foot of the frame allows, above the bottom corner row (on a tall frame, low on the dress).
+ const floor = footBase - metaSize * 1.2 - S * 0.05;
+ const room = floor - (safe.y + (sign?.h ?? 0) + S * 0.2);
+ const head = fitLines(c, "headline", c.field("headline"), { x: safe.x, top: floor - Math.min(room, design.h * 0.5), room: Math.min(room, design.h * 0.5), anchor: 1, width: colW, maxLines: 2, max: S * (side ? 0.3 : 0.34), min: S * 0.09, preset: "cut-rise-glyph", fill: 0.97, ratio: 1.3, gap: 0.06, stack: true });
+ const headB = head ? head.band : { x: safe.x, y: floor, w: 0, h: 0 };
+ // The script word rides just above the first line, over the gap between its words: its baseline dips at most 8 % of
+ // the cap height into the capitals (it never covers a letter's counter, so the title always reads).
+ const first = head?.sets[0] ?? null;
+ const firstWord = first ? first.words[0] : null;
+ const capH = first ? first.cap.bottom - first.cap.top : 0;
+ const accSize = first ? first.size * 0.55 : S * 0.12;
+ const accX = firstWord && first && first.words.length > 1 ? Math.max(safe.x, firstWord.x + firstWord.w * 0.45) : safe.x + S * 0.04;
+ const accW = Math.max(S * 0.2, safe.x + colW - accX);
+ const acc0 = c.set("accent", c.field("accent"), { role: "accent", x: accX, y: 0, width: accW, maxLines: 1, max: accSize, min: S * 0.05, preset: "ink-draw" });
+ const accY = headB.y + capH * 0.06 - (acc0 ? capBand(acc0).h : 0);
+ // Too little room between the brand and the title: the script gets smaller (never pushed down onto the title).
+ const accRoom = headB.y + capH * 0.06 - (safe.y + (sign?.h ?? 0) + S * 0.03);
+ const accH0 = acc0 ? capBand(acc0).h : 0;
+ const accSizeFit = acc0 && accH0 > accRoom ? Math.max(S * 0.035, (acc0.size * Math.max(0, accRoom)) / accH0) : (acc0?.size ?? 0);
+ const accFit = acc0 && accSizeFit < acc0.size ? c.set("accent", c.field("accent"), { role: "accent", x: accX, y: 0, width: accW, maxLines: 1, max: accSizeFit, min: accSizeFit, preset: "ink-draw" }) : acc0;
+ const accY2 = accFit ? headB.y + capH * 0.06 - capBand(accFit).h : accY;
+ const acc = accFit ? capAt(c, "accent", c.field("accent"), { role: "accent", x: accX, y: accY2, width: accW, maxLines: 1, max: accFit.size, min: accFit.size, preset: "ink-draw" }) : null;
+ const accB = acc ? capBand(acc) : null;
+
+ const k = c.spread(3, 1.6);
+ const headPlans = head ? moveLines(c, head, { in: "cut-rise-glyph", at: 0.05, hero: true, loop: "light-sweep", loopAt: 2.6, loopEvery: 1.9 }, "headline", 0.14) : [];
+ const headDone = headPlans.length ? stackLanded(headPlans) : 1.1;
+ // The script draws itself on once the title has landed.
+ const accPlan = acc ? c.move(acc, { in: "ink-draw", at: headDone + 0.05 }) : null;
+ const linePlan = line ? c.move(line, { in: "fade-rise", at: headDone + 0.2 * k, rate: 30 }) : null;
+ const notePlan = note ? c.move(note, { in: "fade-rise", at: headDone + 0.3 * k, rate: 30 }) : null;
+ const sitePlan = site ? c.move(site, { in: "fade-rise", at: 0.5, rate: 30 }) : null;
+ const signPlan = signIn(c, sign, "brand", 0.3);
+
+ const gold = mixOk(pal.accent, "#e2bd78", 0.3);
+ // On a light look the scrim is light, so the words take the ink.
+ const titleInk = c.dark ? pal.paper : pal.ink;
+ // The script in the kit's accent at full strength, so it reads apart from the title it crosses.
+ const accInk = c.dark ? ensureContrast(mixOk(pal.accent, "#fff4dc", 0.45), pal.ground, 4.5) : ensureContrast(gold, pal.ground, 4.5);
+
+ return {
+ overflow: [...(head?.overflow ? ["headline"] : []), ...(acc?.overflow ? ["accent"] : []), ...(line?.overflow ? ["line"] : []), ...(sign?.overflow ? ["brand"] : []), ...(site?.overflow ? ["website"] : []), ...(note?.overflow ? ["note"] : [])],
+ signature: headDone + 0.3,
+ camera: (t) => ({ x: -14 * (1 - Math.min(1, t / c.last)) ** 2, y: 0 }),
+ grain: 0.06,
+ draw(t, kit) {
+ const field: DisplayNode[] = pic
+ ? [{ type: "rect", x: 0, y: 0, w: design.w, h: design.h, fill: pal.ground }, photoNode({ bleed: true, src: "product", img: pic, box: { x: 0, y: 0, w: design.w, h: design.h }, t, duration: c.last, push: { from: 1.0, to: 1.06 }, focus: { x: side ? 0.5 : 0.47, y: 0.4 }, grade: { dark: mixOk(pal.ground, "#000000", 0.3), light: gold, darkAlpha: 0.26, lightAlpha: 0.08 } })]
+ : meshField(c, t, { glow: gold, glowAlpha: 0.2 });
+ // Scrims: the foot under the title, and the top third under the brand and the line (they read on any photo).
+ const atmosphere: DisplayNode[] = [
+ fadeScrim(c, pal.ground, side ? 0.4 : 0.5, 1, 0.85),
+ { type: "rect", x: 0, y: 0, w: design.w, h: design.h * 0.32, fill: { kind: "linear", x0: 0, y0: 0, x1: 0, y1: design.h * 0.32, stops: [{ at: 0, color: rgba(pal.night, 0.62) }, { at: 0.55, color: rgba(pal.night, 0.38) }, { at: 1, color: rgba(pal.night, 0) }] } },
+ ];
+ const overlay: DisplayNode[] = [];
+ const hero: DisplayNode[] = head ? head.sets.flatMap((_, i) => kit.type(headPlans[i], { fill: titleInk, sweep: gold, sweepAlpha: 0.4 })) : [];
+ if (accPlan && accB && acc) {
+ const cx = accB.x + accB.w / 2;
+ const cy = accB.y + accB.h / 2;
+ const nodes = kit.type(accPlan, { fill: accInk });
+ // Solid gold script lifted by its own soft shadow (no outline).
+ hero.push(group([...(t >= accPlan.settled ? shadowed(c, nodes, acc.size * 0.4, { x: accB.x - acc.size * 0.3, y: accB.y - acc.size * 0.3, w: accB.w + acc.size * 0.6, h: accB.h + acc.size * 0.6 }, `rt|${acc.text}|${acc.size}`) : []), ...nodes], { transform: rotation(-6, cx, cy) }));
+ }
+ const metaInk2 = c.dark ? mixOk(pal.paper, gold, 0.15) : pal.ink;
+ const meta: DisplayNode[] = [...signNodes(c, kit, sign, signPlan, "brand", safe.x, safe.y, titleInk)];
+ if (linePlan) meta.push(...kit.type(linePlan, { fill: metaInk2, caret: gold }));
+ if (notePlan) meta.push(...kit.type(notePlan, { fill: metaInk2 }));
+ if (sitePlan) meta.push(...kit.type(sitePlan, { fill: metaInk2 }));
+ return [
+ { role: "ground", nodes: field, push: 0 },
+ { role: "atmosphere", nodes: atmosphere, push: 0 },
+ { role: "hero", nodes: hero },
+ { role: "overlay", nodes: overlay },
+ { role: "meta", nodes: meta },
+ ];
+ },
+ };
+ },
+});
diff --git a/src/lib/motion/scenes/marketing/offer-badge.ts b/src/lib/motion/scenes/marketing/offer-badge.ts
index 8dd95d0a..69b1137c 100644
--- a/src/lib/motion/scenes/marketing/offer-badge.ts
+++ b/src/lib/motion/scenes/marketing/offer-badge.ts
@@ -1,136 +1,151 @@
/**
- * Offer Badge: a starburst badge pops on with a turn that settles a few degrees off square, the offer set on it as
- * typed; the product slides in under it from the side and lands on its shadow; the headline rises line by line and the
- * call-to-action pill pops last. The badge sits where it covers none of the product (its own outline, not just its
- * box), sized to the product; when no spot is clear the product steps back a little. While it holds, the product floats
- * and the badge rocks gently. On the brand colour a soft lighter pool sits behind the product. Without a product the
- * logo (or the name) takes its place.
+ * Offer Badge: a sale poster. The headline is a justified stack, each line fitted to the width (a short last word
+ * lands huge), swiping in on bars of a deep tone of the brand; the product rises out of its floor in the middle band
+ * with a soft column of light behind it and a band of light crossing it; a badge in the hero's ink with a fine inner
+ * ring stamps down beside it as one piece (the offer, as typed, rides on it and never leaves the disc), clear of the
+ * product. A giant filled copy of the offer one tone off the field drifts behind; the call to action lands in a pill
+ * of the badge's colour above the bottom corners. The brand, the address, a corner note and an index arrow sit on the
+ * corners; through the hold the type plane pushes in.
*/
-import { about, group, mixHex, multiply, translate, withAlpha, type DisplayNode } from "../../display";
-import { lineRuns } from "../end-card/shared";
-import { badgeSpot, contactShadow, ev, fitBox, heroOf, holdFloat, logoNode, marketingScene, MIN_BODY, MIN_HEAD, readable, risingLines, setText, spread, starPath, textBlock, type BadgeSpot } from "./kit";
+import { group, type DisplayNode } from "../../display";
+import { ensureContrast, fieldStops, mixOk } from "../../color";
+import { pool, rgba } from "../../fx/background";
+import { product as productNode } from "../../fx/photo";
+import { rotation } from "../../fx/overlays";
+import { twoShadow } from "../../fx/depth";
+import { badgeSpot, fitBox, logoNode, type BadgeSpot } from "./kit";
+import { bands, brandSign, capBand, fitLines, footRow, ghost, litField, metaInk, moveLines, pillOn, posterScene, signIn, signNodes, stackLanded, topSite } from "./poster";
-export default marketingScene({
+export default posterScene({
id: "marketing/offer-badge",
name: "Offer Badge",
- look: "light",
+ pairing: "T2",
+ look: "brand",
build(c) {
- const { S, safe, palette: pal, design, recipe } = c;
- const hero = heroOf(c);
+ const { S, safe, pal, design } = c;
const side = c.wide;
- const textW = side ? safe.w * 0.46 : safe.w;
- const textLeft = side ? safe.x + safe.w * 0.54 : safe.x;
- const head = setText(c, c.field("headline"), { weight: 800, width: textW, maxLines: 2, max: S * (side ? 0.1 : c.tall ? 0.13 : 0.11), min: S * MIN_HEAD, lineHeight: 1.04 });
- const ctaSize = S * (c.tall ? 0.056 : 0.05);
- const cta = setText(c, c.field("cta"), { family: "body", weight: 700, width: textW - ctaSize * 2.4, maxLines: 1, max: ctaSize, min: S * MIN_BODY });
- const bMax = S * (side ? 0.15 : 0.17);
- const pillH = cta ? cta.size * 2.3 : 0;
- const gap = S * 0.05;
- // Where things go: the headline over the product and the pill under it (beside it on a wide frame).
- let heroBox: { x: number; y: number; w: number; h: number };
- let headY: number;
- let pillY: number;
- if (side) {
- heroBox = { x: safe.x, y: safe.y + safe.h * 0.08, w: safe.w * 0.48, h: safe.h * 0.86 };
- const stack = (head?.height ?? 0) + (cta ? gap + pillH : 0);
- headY = safe.y + (safe.h - stack) / 2;
- pillY = headY + (head ? head.height + gap : 0);
- } else {
- headY = safe.y;
- const top = headY + (head ? head.height + gap : 0);
- pillY = safe.y + safe.h - pillH;
- heroBox = { x: safe.x + safe.w * 0.06, y: top + bMax * 0.3, w: safe.w * 0.88, h: pillY - gap - (top + bMax * 0.3) };
- }
- const product = hero?.src === "product" ? (c.input.outlines?.product ?? null) : null;
- const name = !hero ? setText(c, recipe.brand.name, { weight: 800, width: heroBox.w * 0.8, maxLines: 2, max: S * 0.12, min: S * MIN_HEAD, lineHeight: 1.04 }) : null;
- const nameB = name ? textBlock("brand", name, { y: heroBox.y + (heroBox.h - name.height) / 2, color: pal.ink, cx: heroBox.x + heroBox.w / 2 }) : null;
- // The badge by the product, under the headline and over the pill.
- const below = side ? safe.y : headY + (head ? head.height + gap * 0.3 : 0);
- const bounds = { x: side ? heroBox.x : safe.x, y: below, w: side ? heroBox.w : safe.w, h: (side ? safe.y + safe.h : pillY - gap * 0.3) - below };
- let img = hero ? fitBox(hero, heroBox, hero.src === "product") : null;
- let spot: BadgeSpot;
- const pic = () => img ?? (nameB && name ? { x: nameB.cx - name.width / 2, y: nameB.y, w: name.width, h: name.height } : heroBox);
- spot = badgeSpot(pic(), product, bMax, bounds);
- // No clear spot: the product steps back (smaller, on the same foot) until one is.
- for (let i = 0; img && product && spot.cover > 0.04 && i < 3; i++) {
- const k = 0.88;
- img = { x: img.x + (img.w * (1 - k)) / 2, y: img.y + img.h * (1 - k), w: img.w * k, h: img.h * k };
- spot = badgeSpot(img, product, bMax, bounds);
- }
- const bc: [number, number] = [spot.cx, spot.cy];
- const bR = spot.r;
- const offer = setText(c, c.field("offer"), { family: "figures", weight: 800, width: bR * 1.3, maxLines: 2, max: bR * 0.5, min: S * 0.035, lineHeight: 0.98 });
- const headB = head ? textBlock("headline", head, { y: headY, color: pal.ink, ...(side ? { left: textLeft, width: textW } : { cx: design.w / 2 }) }) : null;
- const pillW = cta ? Math.min(textW, cta.width + cta.size * 2.4) : 0;
- const pillX = side ? (cta?.dir === "rtl" ? textLeft + textW - pillW : textLeft) : design.w / 2 - pillW / 2;
- const ctaB = cta ? textBlock("cta", cta, { y: pillY + (pillH - cta.size * 1.12) / 2, color: pal.highlight.ink, cx: pillX + pillW / 2 }) : null;
- const badgeFill = pal.mark;
- const offerB = offer ? textBlock("offer", offer, { y: bc[1] - offer.height / 2, color: readable(badgeFill, pal.ground, pal.highlight.ink, pal.ink), cx: bc[0] }) : null;
+ const prod = c.recipe.media?.product ? c.input.images?.product : undefined;
+ const outline = prod ? (c.input.outlines?.product ?? null) : null;
+ const textX = side ? safe.x + safe.w * 0.5 : safe.x;
+ const textW = side ? safe.w * 0.5 : safe.w;
+ const signH = S * (c.cover ? 0.056 : 0.044);
+ const sign = brandSign(c, { maxW: S * 0.34, h: signH, x: safe.x, y: safe.y, min: S * (c.cover ? 0.05 : 0.03) });
+ const metaSize = S * (c.cover ? 0.024 : 0.02);
+ const site = topSite(c, sign, metaSize);
+ const b = bands(c, { topRow: sign?.h ?? metaSize, gap: S * 0.05 });
+ const foot = metaSize * 1.1 + S * 0.04;
+ const ctaSize = S * (c.cover ? 0.05 : 0.042);
+ const ctaPadY = ctaSize * 0.35;
+ const ctaY = safe.y + safe.h - foot - ctaSize * 1.1 - ctaPadY;
+ const cta = c.set("cta", c.field("cta"), { role: "body", weight: 700, x: side ? textX + ctaSize * 0.6 : design.w / 2 - safe.w * 0.4, y: ctaY, width: side ? textW - ctaSize * 1.2 : safe.w * 0.8, maxLines: 1, max: ctaSize, min: S * 0.034, align: side ? "left" : "centre" });
+ const head = fitLines(c, "headline", c.field("headline"), { x: textX, top: b.top, room: side ? (ctaY - ctaPadY - S * 0.06 - b.top) : (b.bottom - b.top) * 0.44, anchor: side ? 0.4 : 0, width: textW, maxLines: 3, max: S * (side ? 0.16 : 0.26), min: S * 0.07, preset: "bar-swipe", fill: 0.985, ratio: 2.4, gap: 0.09, stack: true });
+ const headB = head ? head.band : { x: textX, y: b.top, w: 0, h: 0 };
- // The beats, spread over the length: the badge, the product, the headline, the pill.
- const k = spread(c, 1.95, 2.4);
- const lines = head?.lines.length ?? 0;
- const slideAt = 0.5 * k;
- const headAt = 0.95 * k;
- const ctaAt = 1.45 * k + lines * 0.09;
- const events = [
- ...(offer ? [ev("badge", "pop", 0.12, 0.6, "pop"), ev("badge.turn", "enter", 0.12, 0.7, "settle")] : []),
- ev("slide", "enter", slideAt, 0.7, "enter"),
- ev("shadow", "fade", slideAt + 0.2, 0.45, "enter"),
- ...Array.from({ length: lines }, (_, i) => ev(`head.${i}`, "enter", headAt + i * 0.09, 0.55, "glide", { group: "head", unit: "elements" })),
- ...(cta ? [ev("cta", "pop", ctaAt, 0.45, "pop")] : []),
- ];
- const holdFrom = slideAt + 0.75;
+ // The product in the middle band (the left half on a wide frame), on its floor; on a tall frame it stands up behind
+ // the headline's last line (type in front of the product), so it can be a third of the frame's width.
+ // A short last line leaves its right free: the product stands up beside it, its top level with the line's caps.
+ const lastLine = head ? head.sets[head.sets.length - 1] : null;
+ const lastRight = lastLine ? lastLine.ink.x + lastLine.ink.w : safe.x + safe.w;
+ const besideLast = !side && !!lastLine && head!.sets.length > 1 && lastRight < safe.x + safe.w * 0.5;
+ const bandTop = side ? b.top + S * 0.02 : besideLast ? lastLine!.lines[0].y + lastLine!.cap.top : headB.y + headB.h + S * 0.04;
+ const bandBottom = side ? safe.y + safe.h - foot : ctaY - ctaPadY - S * 0.05;
+ const box = side ? { x: safe.x, y: bandTop, w: safe.w * 0.24, h: bandBottom - bandTop } : besideLast ? { x: lastRight + S * 0.05, y: bandTop, w: Math.min(safe.w * 0.4, safe.x + safe.w - lastRight - S * 0.05), h: bandBottom - bandTop } : { x: safe.x + safe.w * 0.02, y: bandTop, w: safe.w * 0.5, h: bandBottom - bandTop };
+ const img = prod ? fitBox(prod, box, true) : c.input.logo ? fitBox(c.input.logo, { ...box, y: box.y + box.h * 0.3, h: box.h * 0.4 }) : null;
+ const bR = S * (side ? 0.13 : 0.15);
+ // On a wide frame the badge has the room right of the product to itself, at least 16.5 % below the top.
+ const right = img ? img.x + img.w + S * 0.02 : safe.x;
+ const wideTop = Math.max(safe.y, design.h * 0.165);
+ const bounds = side ? (img && safe.x + safe.w * 0.5 - right >= bR * 2 ? { x: right, y: wideTop, w: safe.x + safe.w * 0.5 - right, h: safe.y + safe.h - wideTop } : { x: safe.x, y: wideTop, w: safe.w * 0.5, h: safe.y + safe.h - wideTop }) : { x: safe.x, y: headB.y + headB.h + S * 0.03, w: safe.w, h: bandBottom - (headB.y + headB.h + S * 0.03) };
+ const spot: BadgeSpot = img ? badgeSpot(img, outline, bR, bounds, 0.75) : { cx: box.x + box.w / 2, cy: box.y + box.h / 2, r: bR, cover: 0 };
+ // The offer sits well inside the disc (its widest line in 1.3 r).
+ const offer = c.set("offer", c.field("offer"), { role: "figures", x: spot.cx - spot.r * 0.65, y: 0, width: spot.r * 1.3, maxLines: 2, max: spot.r * 0.62, min: S * 0.04, align: "centre", preset: "cut-rise", leading: 0.86 });
+ const offerSet = offer ? c.set("offer", c.field("offer"), { role: "figures", x: spot.cx - spot.r * 0.65, y: spot.cy - capBand(offer).h / 2 - (offer.lines[0].y + offer.cap.top), width: spot.r * 1.3, maxLines: 2, max: offer.size, min: offer.size, align: "centre", preset: "cut-rise", leading: 0.86 }) : null;
+
+ const k = c.spread(3.2, 1.6);
+ const headPlans = head ? moveLines(c, head, { in: "bar-swipe", at: 0.03, hero: true }, "headline", 0.12) : [];
+ const headDone = headPlans.length ? stackLanded(headPlans) : 0.6;
+ c.ev("product", "hero", Math.max(0.3, headDone - 0.4), 0.9, "enter");
+ // The badge stamps down as one piece (a slam in 167 ms from 125 %, a little squash); the offer rises on it.
+ const slamAt = Math.max(0.9 * k, headDone + 0.25);
+ c.ev("badge", "slam", slamAt, 0.167, "slam");
+ c.ev("squash", "pop", slamAt + 0.167, 0.4, "land");
+ c.ev("ring", "fade", slamAt + 0.167, 0.5, "glide");
+ const offerPlan = offerSet ? c.move(offerSet, { in: "cut-rise", at: slamAt + 0.05 }) : null;
+ const offerDone = Math.max(slamAt + 0.6, offerPlan?.settled ?? 1.4);
+ c.ev("sweep", "move", offerDone + 0.05, 0.8, "move");
+ const ctaPlan = cta ? c.move(cta, { in: "word-lift", at: offerDone + 0.15 * k }) : null;
+ if (cta) c.ev("pill", "pop", offerDone + 0.08 * k, 0.5, "pop");
+ const signPlan = signIn(c, sign, "brand", 0.2);
+ const sitePlan = site ? c.move(site, { in: "fade-rise", at: 0.35, rate: 26 }) : null;
+ const row = footRow(c, (ctaPlan?.settled ?? offerDone) + 0.1);
+
+ // The badge: the hero's ink as the disc, the ground's colour for the offer on it (in the kit, never black on cream).
+ const badgeFill = pal.ink;
+ const offerInk = ensureContrast(pal.ground, badgeFill, 4.5);
+ const stops = fieldStops(pal);
+ const ghostGround = mixOk(stops.dark, stops.light, 0.5);
+ // The ghost is the offer's sign alone (a giant %), never an echo of the badge's words; none without one.
+ const ghostText = /%/.test(c.field("offer")) ? "%" : "";
+ const floorY = img ? img.y + img.h : bandBottom;
return {
- events,
- overflow: [...(offer?.overflow ? ["offer"] : []), ...(head?.overflow ? ["headline"] : []), ...(cta?.overflow ? ["cta"] : []), ...(name?.overflow ? ["brand"] : [])],
- signature: slideAt + 0.35,
- frame(t, P, Lp) {
- const nodes: DisplayNode[] = [];
- if (headB) nodes.push(...risingLines(headB, (i) => P(`head.${i}`)));
- // The product slides in from the right and lands on its shadow, then floats while it holds.
- const s = P("slide");
- const lin = Lp("slide");
- const fl = holdFloat(t, holdFrom, c.last, S * 0.012, 0.01);
- if (img && hero) {
- const sh = P("shadow");
- // On the brand colour a product in that same colour would lose its edge: a soft pool of lighter ground
- // behind it keeps it apart (it fades in as the product lands).
- if (pal.look === "brand" && hero.src === "product" && lin > 0) {
- const gx = img.x + img.w / 2;
- const gy = img.y + img.h * 0.52;
- const gr = Math.max(img.w, img.h) * 0.62;
- const lift = mixHex(pal.ground, "#ffffff", 0.5);
- const stops = [
- { at: 0, color: withAlpha(lift, 0.55) },
- { at: 0.55, color: withAlpha(lift, 0.25) },
- { at: 1, color: withAlpha(lift, 0) },
- ];
- const sx = Math.min(1, Math.max(0.75, (img.w * 1.5) / gr));
- nodes.push(group([{ type: "ellipse", cx: gx, cy: gy, rx: gr, ry: gr, fill: { kind: "radial", cx: gx, cy: gy, r0: 0, r1: gr, stops } }], { transform: about(gx, gy, sx, 0, 1), ...(lin < 1 && { opacity: lin }) }));
- }
- if (sh > 0 && hero.src === "product") nodes.push(contactShadow(img.x + img.w / 2, img.y + img.h, img.w * 0.85 * (1 + fl.dy / (S * 0.2)), pal.ground, 0.3, sh));
- const pic: DisplayNode = hero.src === "logo" ? logoNode(c, img, pal.ink) : { type: "image", src: hero.src, x: img.x, y: img.y, w: img.w, h: img.h };
- if (lin > 0) nodes.push(group([pic], { transform: multiply(translate((1 - s) * S * 0.7, fl.dy), about(img.x + img.w / 2, img.y + img.h, 1, (1 - s) * 0.12 + fl.roll)), ...(lin < 0.25 && { opacity: lin / 0.25 }) }));
- } else if (nameB && lin > 0) nodes.push(group([lineRuns(nameB)], { transform: translate((1 - s) * S * 0.5, 0), ...(lin < 0.25 && { opacity: lin / 0.25 }) }));
- if (offerB) {
- const b = P("badge");
- const rock = holdFloat(t, 0.9, c.last, 0, 0.05).roll;
- if (Lp("badge") > 0) nodes.push(group([{ type: "path", d: starPath(bc[0], bc[1], bR, bR * 0.86, 20), fill: badgeFill }, lineRuns(offerB)], { transform: about(bc[0], bc[1], Math.max(0, b), 0.14 - 0.65 * (1 - P("badge.turn")) + rock) }));
+ overflow: [...(head?.overflow ? ["headline"] : []), ...(offerSet?.overflow ? ["offer"] : []), ...(cta?.overflow ? ["cta"] : []), ...(sign?.overflow ? ["brand"] : []), ...(site?.overflow ? ["website"] : []), ...row.overflow],
+ signature: offerDone + 0.1,
+ sandwich: false,
+ camera: (t) => ({ x: 0, y: 16 * (1 - Math.min(1, t / c.last)) ** 2 }),
+ draw(t, kit) {
+ const field = litField(c, t, { from: "tl", stops });
+ // A soft column of light behind the product (one band, drifting a little), never stripes.
+ const cx = img ? img.x + img.w / 2 : design.w / 2;
+ const u = Math.min(1, t / Math.max(0.01, c.last));
+ // A soft round key light behind the product (no hard edge anywhere), drifting a little.
+ const lc = mixOk(pal.brand[1], "#ffffff", 0.3);
+ const ly = img ? img.y + img.h * 0.45 : design.h * 0.55;
+ const atmosphere: DisplayNode[] = [{ type: "rect", x: 0, y: 0, w: design.w, h: design.h, fill: pool(cx + (1 - u) * S * 0.04, ly, Math.max(design.w, design.h) * 0.42, lc, 0.32) }];
+ // The offer's sign, giant, one faint tone off the field, cropped by the right edge in the lower half (never
+ // behind the headline's column).
+ const gSize = S * (side ? 0.7 : 0.95);
+ const ghosts: DisplayNode[] = ghostText ? [ghost(c, { field: "offer", lines: [ghostText], size: gSize, x: design.w + gSize * 0.18, align: "right", y: Math.max(headB.y + headB.h + S * 0.04, design.h * 0.5), t, family: c.pairing.figures.family, weight: c.pairing.figures.weight, ground: ghostGround })] : [];
+ // The product (or the logo) rising out of its floor, light crossing it once.
+ const subject: DisplayNode[] = [];
+ const pl = kit.L("product");
+ if (img && pl > 0) {
+ const p = kit.P("product");
+ const dy = (1 - p) * img.h * 0.5;
+ const nodes: DisplayNode[] = prod ? [productNode({ src: "product", box: img, ground: pal.ground, t, sweepAt: offerDone + 0.05, sweepDur: 0.8, key: "ob" })] : [logoNode(c, img, pal.ink)];
+ subject.push(group([group(nodes, { transform: [1, 0, 0, 1, 0, dy] })], { ...(p < 1 && { clip: { type: "rect", x: img.x - img.w, y: img.y - img.h, w: img.w * 3, h: floorY + S * 0.012 - (img.y - img.h) } }) }));
}
- if (ctaB && cta) {
- const p = P("cta");
- const l = Lp("cta");
- if (l > 0) {
- const label = Math.min(1, Math.max(0, (l - 0.08) / 0.3));
- const children: DisplayNode[] = [{ type: "rect", x: pillX, y: pillY, w: pillW, h: pillH, r: pillH / 2, fill: pal.highlight.fill }];
- if (label > 0) children.push({ ...lineRuns(ctaB), ...(label < 1 && { opacity: label }) });
- nodes.push(group(children, { transform: about(pillX + pillW / 2, pillY + pillH / 2, 0.6 + 0.4 * p), ...(l < 0.12 && { opacity: l / 0.12 }) }));
- }
+ const hero: DisplayNode[] = head ? head.sets.flatMap((_, i) => kit.type(headPlans[i], { fill: pal.ink, bar: pal.accent })) : [];
+ const overlay: DisplayNode[] = [];
+ const bl = kit.L("badge");
+ if (bl > 0) {
+ const bp = kit.P("badge");
+ const sq = kit.L("squash");
+ const squash = sq > 0 && sq < 1 ? 0.06 * Math.sin(Math.PI * Math.min(1, sq * 2.2)) * (1 - sq) : 0;
+ const s = 1.25 - 0.25 * bp;
+ const sx = s * (1 + squash);
+ const sy = s * (1 - squash);
+ const disc: DisplayNode = { type: "ellipse", cx: spot.cx, cy: spot.cy, rx: spot.r, ry: spot.r, fill: badgeFill };
+ const ring: DisplayNode = { type: "ellipse", cx: spot.cx, cy: spot.cy, rx: spot.r * 0.92, ry: spot.r * 0.92, stroke: { paint: offerInk, width: Math.max(2, S * 0.002) } };
+ const offerNodes = offerPlan ? kit.type(offerPlan, { fill: offerInk }) : [];
+ const rl = kit.L("ring");
+ if (rl > 0 && rl < 1) overlay.push({ type: "ellipse", cx: spot.cx, cy: spot.cy, rx: spot.r * (1 + 0.4 * kit.P("ring")), ry: spot.r * (1 + 0.4 * kit.P("ring")), stroke: { paint: rgba(badgeFill, 0.6 * (1 - rl)), width: Math.max(2, S * 0.004) } });
+ const shadows = bp >= 1 ? twoShadow({ nodes: [disc], size: spot.r * 2, ground: pal.ground, bounds: { x: spot.cx - spot.r, y: spot.cy - spot.r, w: spot.r * 2, h: spot.r * 2 }, key: `ob|${spot.r.toFixed(0)}` }) : [];
+ // The offer never leaves its disc.
+ overlay.push(group([...shadows, group([disc, ring, group(offerNodes, { clip: { type: "ellipse", cx: spot.cx, cy: spot.cy, rx: spot.r * 0.9, ry: spot.r * 0.9 } })], { transform: rotation(-8, spot.cx, spot.cy) })], { transform: [sx, 0, 0, sy, spot.cx - sx * spot.cx, spot.cy - sy * spot.cy], ...(bl < 0.25 && { opacity: bl / 0.25 }) }));
}
- return { nodes };
+ if (cta && ctaPlan && kit.L("pill") > 0) overlay.push(pillOn(cta, kit.type(ctaPlan, { fill: offerInk }), badgeFill, { deg: 0, p: kit.P("pill") }));
+ const meta = [...signNodes(c, kit, sign, signPlan, "brand", safe.x, safe.y, pal.ink), ...(sitePlan ? kit.type(sitePlan, { fill: metaInk(pal), caret: pal.accent }) : []), ...row.draw(kit, metaInk(pal), pal.ink)];
+ return [
+ { role: "ground", nodes: field },
+ { role: "atmosphere", nodes: atmosphere },
+ { role: "ghost", nodes: ghosts },
+ { role: "subject", nodes: subject },
+ { role: "hero", nodes: hero },
+ { role: "overlay", nodes: overlay },
+ { role: "meta", nodes: meta },
+ ];
},
};
},
diff --git a/src/lib/motion/scenes/marketing/poster.ts b/src/lib/motion/scenes/marketing/poster.ts
new file mode 100644
index 00000000..6429b3d0
--- /dev/null
+++ b/src/lib/motion/scenes/marketing/poster.ts
@@ -0,0 +1,733 @@
+/**
+ * The poster kit (pure): what the Kinetic templates are built from. A template is a poster that moves: one voice (a
+ * type pairing), a palette from the brand kit, a field that is never flat (gradient, light, photography, texture,
+ * grain), huge type set to fill its box and moved letter by letter with the text presets, tiny facts on the grid's
+ * corners, one overlay, and depth. Layers are drawn bottom to top (fx/stack.ts) so a camera move parallaxes them and
+ * each pushes in at its own rate; grain sits under the readable type and the last frame is the poster.
+ *
+ * Every typed word is set exactly as typed (type/glyphs.ts). A field that doesn't fit at its smallest size is named in
+ * `overflow` and nothing renders. Readable copy stays inside the safe area of where the piece is shown (grid.ts);
+ * only fields, shapes, photos and decorative ghost copies (text nodes marked `decor`) bleed.
+ */
+
+import { group, translate, type Box, type DisplayList, type DisplayNode, type Paint, type TextNode, type TextRun } from "../../display";
+import type { CurveName } from "../../ease";
+import { curve } from "../../ease";
+import { chroma, contrastOf, ensureContrast, fieldStops, kineticPalette, mixOk, okStops, withLightness, toLab, type KineticPalette, type Look } from "../../color";
+import { bokeh as bokehField, meshGradient, nightGround, orbGlow, pool, rgba } from "../../fx/background";
+import { flash as flashNode, grain, vignette } from "../../fx/finish";
+import { pillBox } from "../../fx/materials";
+import { arrow, pillTag } from "../../fx/overlays";
+import { stack, type Layer } from "../../fx/stack";
+import { twoShadow } from "../../fx/depth";
+import { gridFor, placementOf, type Grid, type Placement } from "../../grid";
+import type { Recipe } from "../../recipe";
+import type { Scene, SceneInput, ScenePlan } from "../../scene";
+import { designSize } from "../../sizes";
+import { frameCount, local } from "../../time";
+import { DURATION_LIMITS, timeline, type EventKind, type MotionEvent, type StaggerUnit, type Timeline } from "../../tween";
+import { drawType, planType, type TextMotion, type TypePlan, type TypeStyle } from "../../type/animate";
+import { fontOf } from "../../type/faces";
+import { setType, type BoxMeasure, type TypeSet, type TypeSpec } from "../../type/glyphs";
+import { PAIRINGS, type Pairing, type PairingId, type RoleFace } from "../../type/pairings";
+import { PRESETS, type PresetId } from "../../type/presets";
+import { logoNode, sampleMark } from "./kit";
+
+export type Role = "hero" | "accent" | "meta" | "body" | "figures";
+
+export interface SetOptions {
+ role: Role;
+ x: number;
+ y: number;
+ width: number;
+ maxLines: number;
+ max: number;
+ min: number;
+ align?: "left" | "centre" | "right";
+ /** The preset it enters with (its widest state is what has to fit). */
+ preset?: PresetId;
+ family?: string;
+ weight?: number;
+ style?: "normal" | "italic";
+ tracking?: number;
+ leading?: number;
+ tabular?: boolean;
+ /** Even lines (see layoutText). */
+ even?: number;
+ /** The narrowest a word space may look (em); by size and style when absent. */
+ wordSpace?: number;
+}
+
+export interface PosterContext {
+ recipe: Recipe;
+ input: SceneInput;
+ measure: BoxMeasure;
+ design: { w: number; h: number };
+ /** The short side (1080). */
+ S: number;
+ grid: Grid;
+ /** Where readable copy may go. */
+ safe: Box;
+ placement: Placement;
+ cover: boolean;
+ pairing: Pairing;
+ pal: KineticPalette;
+ look: Look;
+ dark: boolean;
+ /** Text presets' speed: calm 0.85, punchy 1.15. */
+ speed: number;
+ /** How far apart a scene's beats are for the clip's length (1 at its own timing for `base` seconds). */
+ spread(base: number, hi?: number): number;
+ /** Everything is set by then (the last second holds). */
+ room: number;
+ duration: number;
+ /** The last frame's time. */
+ last: number;
+ seed: number;
+ wide: boolean;
+ tall: boolean;
+ /** A typed field (trimmed), or the fallback. */
+ field(key: string, fallback?: string): string;
+ /** Lay out a field in the pairing's face for a role (null when it is empty). */
+ set(field: string, text: string, o: SetOptions): TypeSet | null;
+ /** Plan a type set's motion; its events join the timeline. */
+ move(set: TypeSet, motion: TextMotion, id?: string): TypePlan;
+ /** Add an event (its length held to its kind's limits). */
+ ev(id: string, kind: EventKind, start: number, dur: number, c: CurveName, g?: { group: string; unit: StaggerUnit }): void;
+}
+
+export interface DrawKit {
+ /** An event's eased and plain progress. */
+ P(id: string): number;
+ L(id: string): number;
+ /** A planned type set at this time, in a style (its stomp nudges and flashes are kept for the frame). */
+ type(plan: TypePlan, style: TypeStyle): DisplayNode[];
+}
+
+export interface PosterBuilt {
+ overflow: string[];
+ /** The frame's layers at `t`. */
+ draw(t: number, k: DrawKit): Layer[];
+ /** The camera's pan at the hero's plane (design units); home (0, 0) on the last frame. */
+ camera?: (t: number) => { x: number; y: number };
+ /** The subject goes in front of the hero type (the magazine cover). */
+ sandwich?: boolean;
+ /** Layers push in over the clip (default on). */
+ push?: boolean;
+ signature?: number;
+ cuts?: number[];
+ /** Grain amount (default by the ground), or none. */
+ grain?: number | false;
+ /** Vignette strength (default 0.14), or none. */
+ vignette?: number | false;
+ /** The list's background (the ground by default). */
+ background?: string;
+}
+
+export interface PosterDef {
+ id: string;
+ name: string;
+ pairing: PairingId;
+ look?: Look;
+ durations?: { min: number; max: number; default: number };
+ build(c: PosterContext): PosterBuilt;
+}
+
+export const POSTER_DURATIONS = { min: 5, max: 8, default: 5 } as const;
+
+const round6 = (v: number) => Math.round(v * 1e6) / 1e6;
+
+/** The face a role is set in (the pairing's). */
+export const faceOf = (p: Pairing, role: Role): RoleFace => (role === "accent" ? (p.accent ?? p.hero) : p[role]);
+
+/** The Kinetic families a pairing draws with (for loading). */
+export function pairingFamilies(id: PairingId): string[] {
+ const p = PAIRINGS[id];
+ return [...new Set([p.hero, p.accent, p.meta, p.body, p.figures].filter((f): f is RoleFace => !!f).map((f) => f.family))];
+}
+
+export function posterScene(def: PosterDef): Scene {
+ return {
+ id: def.id,
+ name: def.name,
+ durations: def.durations ?? POSTER_DURATIONS,
+ pairing: def.pairing,
+ sizes: ["9:16", "1:1", "16:9", "4:5"],
+ plan(input: SceneInput): ScenePlan {
+ const recipe = input.recipe;
+ const design = designSize(recipe.size);
+ const S = Math.min(design.w, design.h);
+ const placement = placementOf(recipe);
+ const grid = gridFor(design, placement);
+ const look = (["light", "dark", "brand"] as const).find((l) => l === recipe.controls?.look) ?? def.look ?? "light";
+ const pal = kineticPalette(recipe.brand.colors, look);
+ const last = (frameCount(recipe.duration, recipe.fps) - 1) / recipe.fps;
+ const pace = recipe.controls?.pace === "calm" ? 1.2 : recipe.controls?.pace === "punchy" ? 0.85 : 1;
+ const room = Math.max(1.5, recipe.duration - 1.3);
+ const events: MotionEvent[] = [];
+ const plans: TypePlan[] = [];
+ const pairing = PAIRINGS[def.pairing];
+ const measure = input.measure as BoxMeasure;
+ const ctx: PosterContext = {
+ recipe,
+ input,
+ measure,
+ design,
+ S,
+ grid,
+ safe: grid.safe,
+ placement,
+ cover: placement === "cover",
+ pairing,
+ pal,
+ look,
+ dark: toLab(pal.ground).L < 0.5,
+ speed: pace > 1 ? 0.85 : pace < 1 ? 1.15 : 1,
+ spread: (base, hi = 2) => Math.max(0.9, Math.min(hi, (room / base) * pace, room / base)),
+ room,
+ duration: recipe.duration,
+ last,
+ seed: recipe.seed,
+ wide: design.w / design.h > 1.2,
+ tall: design.h / design.w > 1.5,
+ field: (key, fallback = "") => (recipe.fields[key] ?? fallback).trim(),
+ set(field, text, o) {
+ if (!text.trim()) return null;
+ const f = faceOf(pairing, o.role);
+ const brand = o.family !== undefined;
+ const spec: TypeSpec = {
+ field,
+ text,
+ family: o.family ?? f.family,
+ weight: o.weight ?? (brand ? 700 : f.weight),
+ style: o.style ?? (brand ? "normal" : f.style),
+ max: o.max,
+ min: Math.min(o.min, o.max),
+ x: o.x,
+ y: o.y,
+ width: o.width,
+ maxLines: o.maxLines,
+ leading: o.leading ?? f.leading,
+ tracking: o.tracking ?? f.tracking,
+ align: o.align ?? "left",
+ ...(o.preset && PRESETS[o.preset].widest && { widest: PRESETS[o.preset].widest }),
+ ...(o.tabular && { tabular: true }),
+ even: o.even ?? 0.5,
+ ...(o.wordSpace !== undefined && { wordSpace: o.wordSpace }),
+ };
+ return setType(spec, measure);
+ },
+ move(set, motion, id) {
+ const plan = planType(id ?? set.field, set, { seed: recipe.seed, speed: Math.min(1.4, Math.max(0.7, (motion.speed ?? 1) * ctx.speed)), dark: ctx.dark, loopUntil: last - 0.1, ...motion }, design);
+ plans.push(plan);
+ events.push(...plan.events);
+ return plan;
+ },
+ ev(id, kind, start, dur, c, g) {
+ const [lo, hi] = DURATION_LIMITS[kind];
+ events.push({ id, kind, start: round6(start), dur: round6(Math.min(hi, Math.max(lo, dur))), curve: c, ...(g && { group: g.group, unit: g.unit }) });
+ },
+ };
+ const built = def.build(ctx);
+ const tl: Timeline = timeline(events);
+ const settled = Math.min(last, events.filter((e) => e.kind !== "camera").reduce((m, e) => Math.max(m, e.start + e.dur), 0));
+ const P = (t: number) => (id: string) => {
+ const e = tl.byId.get(id);
+ return e ? curve(e.curve)(local(t, e.start, e.start + e.dur)) : 1;
+ };
+ const Lp = (t: number) => (id: string) => {
+ const e = tl.byId.get(id);
+ return e ? local(t, e.start, e.start + e.dur) : 1;
+ };
+ const background = built.background ?? pal.ground;
+ const draw = (t: number, home: boolean): DisplayList => {
+ let nudge = { x: 0, y: 0 };
+ let flash = 0;
+ const kit: DrawKit = {
+ P: P(t),
+ L: Lp(t),
+ type(plan, style) {
+ const f = drawType(plan, style, t);
+ nudge = { x: nudge.x + f.camera.x, y: nudge.y + f.camera.y };
+ flash = Math.max(flash, f.flash);
+ return f.nodes;
+ },
+ };
+ const layers = built.draw(t, kit);
+ if (built.grain !== false) layers.push({ role: "grain", nodes: [grain({ w: design.w, h: design.h, seed: recipe.seed, frame: Math.round(t * recipe.fps), dark: ctx.dark, ...(typeof built.grain === "number" && { amount: built.grain }) })] });
+ if (built.vignette !== false) layers.push({ role: "finish", nodes: [vignette({ w: design.w, h: design.h, strength: typeof built.vignette === "number" ? built.vignette : 0.14, color: withLightness(pal.ground, 0.08) })] });
+ const fl = flashNode(design.w, design.h, flash);
+ if (fl) layers.push({ role: "light", nodes: [fl] });
+ const cam = home ? { x: 0, y: 0 } : built.camera?.(t) ?? { x: 0, y: 0 };
+ const camera = { x: cam.x + nudge.x, y: cam.y + nudge.y };
+ return { w: design.w, h: design.h, background, nodes: stack(layers, { w: design.w, h: design.h, t, duration: last, camera, sandwich: built.sandwich, push: built.push }) };
+ };
+ const still = draw(last, true);
+ return {
+ design,
+ timeline: tl,
+ rest: last,
+ settled,
+ ...(built.signature !== undefined && { signature: Math.min(last, built.signature) }),
+ cuts: built.cuts ?? [],
+ overflow: [...new Set(built.overflow)],
+ evaluate: (t) => (t >= last ? still : draw(Math.max(0, t), false)),
+ still: (t) => t >= last,
+ };
+ },
+ };
+}
+
+// ---------------------------------------------------------------------------
+// Fields (L0–L1)
+
+/** A field of moving colour: the ground, its tonal steps and the accent in soft pools (light added on a dark ground). */
+export function meshField(c: PosterContext, t: number, o: { colors?: string[]; amplitude?: number; glow?: string; glowAlpha?: number } = {}): DisplayNode[] {
+ const { design, pal } = c;
+ const colors = o.colors ?? (c.dark ? [pal.tone2, pal.accent, pal.brand[0], pal.tone1] : [pal.tone1, pal.brand[1], pal.tone2, pal.accent]);
+ const nodes: DisplayNode[] = [];
+ if (c.dark) nodes.push(...nightGround({ w: design.w, h: design.h, night: pal.ground, glow: o.glow ?? pal.accent, alpha: o.glowAlpha ?? 0.3 }));
+ else nodes.push({ type: "rect", x: 0, y: 0, w: design.w, h: design.h, fill: pal.ground });
+ nodes.push(group([meshGradient({ w: design.w, h: design.h, colors, seed: c.seed, t, duration: c.duration, dark: c.dark, amplitude: o.amplitude })], { opacity: c.dark ? 0.55 : 0.7 }));
+ return nodes;
+}
+
+/**
+ * The lit field (§3.2): a two-stop analogous gradient from the look's `fieldStops` (deep brand hue to a lighter turned
+ * hue; tinted paper on a light look), one off-axis light (an ellipse 140 % of the width at 25 %) drifting slowly, and
+ * visible grain from the poster's finish. `from` is the light's corner.
+ */
+export function litField(c: PosterContext, t: number, o: { from?: "tl" | "tr" | "bl" | "br"; light?: string; lightAlpha?: number; stops?: { dark: string; light: string } } = {}): DisplayNode[] {
+ const { design, pal } = c;
+ const { w, h } = design;
+ const st = o.stops ?? fieldStops(pal);
+ const from = o.from ?? "tr";
+ const lx = from === "tl" || from === "bl" ? 0 : w;
+ const ly = from === "tl" || from === "tr" ? 0 : h;
+ const u = curve("drift")(Math.min(1, t / Math.max(0.01, c.last)));
+ const W = Math.max(w, h);
+ const lightColor = o.light ?? (c.dark ? mixOk(st.light, "#ffffff", 0.35) : "#ffffff");
+ return [
+ { type: "rect", x: 0, y: 0, w, h, fill: { kind: "linear", x0: lx, y0: ly, x1: w - lx, y1: h - ly, stops: okStops(st.light, st.dark, 6) } },
+ // The off-axis light: an ellipse 140 % of the width, its centre drifting 6 % over the clip.
+ { type: "rect", x: 0, y: 0, w, h, fill: pool(lx + (lx ? -1 : 1) * w * (0.12 + 0.06 * u), ly + (ly ? -1 : 1) * h * (0.08 + 0.03 * u), W * 0.7, lightColor, o.lightAlpha ?? 0.25) },
+ ];
+}
+
+/** Paper: a warm light ground with a soft pool of window light drifting across it (for serif and quiet looks). */
+export function paperField(c: PosterContext, t: number, o: { tint?: string; light?: number } = {}): DisplayNode[] {
+ const { design, pal } = c;
+ const u = curve("drift")(Math.min(1, t / Math.max(0.01, c.last)));
+ const W = Math.max(design.w, design.h);
+ return [
+ { type: "rect", x: 0, y: 0, w: design.w, h: design.h, fill: pal.ground },
+ { type: "rect", x: 0, y: 0, w: design.w, h: design.h, fill: { kind: "linear", x0: 0, y0: 0, x1: design.w * 0.3, y1: design.h, stops: [{ at: 0, color: rgba(o.tint ?? pal.brand[1], 0.1) }, { at: 1, color: rgba(o.tint ?? pal.brand[1], 0) }] } },
+ { type: "rect", x: 0, y: 0, w: design.w, h: design.h, fill: pool(design.w * (0.25 + 0.2 * u), design.h * (0.18 + 0.06 * u), W * 0.75, "#ffffff", o.light ?? 0.55) },
+ ];
+}
+
+/** Soft bokeh and an orb of glow behind the hero (dark grounds). */
+export function glowAtmosphere(c: PosterContext, t: number, o: { cx: number; cy: number; r: number; color?: string; alpha?: number; bokeh?: number }): DisplayNode[] {
+ const nodes: DisplayNode[] = [orbGlow({ cx: o.cx, cy: o.cy, r: o.r, color: o.color ?? c.pal.accent, alpha: o.alpha ?? 0.4 })];
+ if (o.bokeh) nodes.push(bokehField({ w: c.design.w, h: c.design.h, count: o.bokeh, colors: [c.pal.accent, c.pal.brand[1]], seed: c.seed, t, duration: c.duration }));
+ return nodes;
+}
+
+// ---------------------------------------------------------------------------
+// Ghost type (L2): a giant tonal copy of the hero, drifting, decorative only
+
+/** The ghost's tone: one step from the ground (OKLab ΔL 0.045 lighter on a dark ground, 0.04 darker on a light one), the ground's own hue. */
+export const ghostTone = (ground: string, step = 1): string => {
+ const L = toLab(ground).L;
+ return withLightness(ground, L < 0.5 ? Math.min(0.95, L + 0.045 * step) : Math.max(0.05, L - 0.04 * step));
+};
+
+/**
+ * A ghost: the words set huge in the hero face, one run per line from (x, y), filled one tonal step from the ground
+ * (`ghostTone`; never a hairline outline), cropped by the frame. It drifts at a steady 2.5 % of the frame's width a second
+ * (or `drift` design units over the clip, whichever is more) and arrives at its place on the last frame, so the holds keep
+ * moving and the cover rests on a still frame. Decorative: never the readable copy. `color` overrides the tone (a ghost
+ * over a photo); `outline` and `alpha` are kept for callers but a ghost is always filled and opaque.
+ */
+export function ghost(c: PosterContext, o: { field: string; lines: string[]; size: number; x: number; y: number; leading?: number; color?: string; outline?: number; drift?: number; t: number; family?: string; weight?: number; tracking?: number; alpha?: number; align?: "left" | "right" | "centre"; tone?: boolean; ground?: string; dir?: 1 | -1; vertical?: boolean; step?: number }): DisplayNode {
+ const f = c.pairing.hero;
+ const family = o.family ?? f.family;
+ const weight = o.weight ?? f.weight;
+ const font = fontOf(family, o.size, weight, f.style);
+ const lh = o.size * (o.leading ?? f.leading);
+ const color = o.tone === false && o.color ? o.color : ghostTone(o.ground ?? c.pal.ground, o.step);
+ let x0 = Infinity;
+ let x1 = -Infinity;
+ const runs: TextRun[] = o.lines.map((line, i) => {
+ const w = c.measure(line, font);
+ const x = o.align === "right" ? o.x - w : o.align === "centre" ? o.x - w / 2 : o.x;
+ x0 = Math.min(x0, x);
+ x1 = Math.max(x1, x + w);
+ return { text: line, gap: i ? " " : "", font, x, y: o.y + i * lh, fill: color };
+ });
+ const node: TextNode = { type: "text", field: o.field, runs, decor: true };
+ // A steady drift that arrives on the last frame.
+ const u = c.last > 0 ? Math.min(1, o.t / c.last) : 1;
+ const span = Math.max(o.drift ?? 0, 0.025 * c.design.w * c.last);
+ const d = (o.dir ?? 1) * span * (1 - u);
+ // Drawn once and reused while it drifts (it only moves).
+ const pad = o.size * 0.35;
+ const bounds = { x: x0 - pad, y: o.y - pad, w: x1 - x0 + 2 * pad, h: (o.lines.length - 1) * lh + o.size + 2 * pad };
+ const cache = { key: `ghost|${font}|${o.lines.join("|")}|${color}|${bounds.x.toFixed(1)}|${bounds.y.toFixed(1)}`, bounds };
+ return group([node], { id: "ghost", cache, ...(d && { transform: o.vertical ? translate(0, d) : translate(-d, 0) }) });
+}
+
+/**
+ * A ghost word that spans the frame: one line of the hero's words set so it runs 6 % past both side edges, its cap top
+ * at `top` (share of the height) and cropped by the bottom edge, so every letter shows whole across and nothing reads as
+ * a cut-off word. It rises 2.5 % of the height a second into place (arriving on the last frame).
+ */
+export function ghostSpan(c: PosterContext, o: { field: string; text: string; top: number; t: number; ground?: string; family?: string; weight?: number; span?: number; maxSize?: number }): DisplayNode {
+ const f = c.pairing.hero;
+ const family = o.family ?? f.family;
+ const weight = o.weight ?? f.weight;
+ const w100 = c.measure(o.text, fontOf(family, 100, weight, f.style));
+ const span = o.span ?? 1.12;
+ const size = Math.min(o.maxSize ?? Infinity, w100 > 0 ? (100 * c.design.w * span) / w100 : c.S * 0.5);
+ const w = (w100 * size) / 100;
+ const box = c.measure.box?.(o.text, fontOf(family, size, weight, f.style));
+ const capTop = box ? box.top : size * 0.1;
+ return ghost(c, { field: o.field, lines: [o.text], size, x: (c.design.w - w) / 2, y: c.design.h * o.top - capTop, t: o.t, family, weight, ground: o.ground, vertical: true, dir: 1, drift: 0.025 * c.design.h * c.last });
+}
+
+/** A tone between the ground and the ink (0: the ground, 1: the ink). */
+export const toneOf = (pal: KineticPalette, k: number): string => mixOk(pal.ground, pal.ink, k);
+
+/** Quieter words on the ground (still 4.5:1). */
+export const metaInk = (pal: KineticPalette): string => ensureContrast(mixOk(pal.ink, pal.ground, 0.25), pal.ground, 4.5);
+
+/** Words on the accent (4.5:1). */
+export const onAccentInk = (pal: KineticPalette): string => ensureContrast(pal.onAccent, pal.accent, 4.5);
+
+// ---------------------------------------------------------------------------
+// The brand's sign-off
+
+export interface Sign {
+ w: number;
+ h: number;
+ overflow: boolean;
+ /** Its nodes with its top-left at (x, y). */
+ nodes(x: number, y: number, color: Paint): DisplayNode[];
+ /** Its type set when it is the brand's name (for a type preset), else null. */
+ set: TypeSet | null;
+}
+
+/**
+ * The brand: its logo (a lockup at most `maxW` × `h`), else its name in the brand's own heading face (its look is
+ * the brand's), sized to fit `maxW` from `h` down to `min`.
+ */
+export function brandSign(c: PosterContext, o: { maxW: number; h: number; min?: number; x?: number; y?: number; align?: "left" | "centre" | "right" }): Sign | null {
+ const logo = c.input.logo;
+ if (logo && logo.w > 0 && logo.h > 0) {
+ const s = Math.min(o.maxW / logo.w, o.h / logo.h);
+ const w = logo.w * s;
+ const h = logo.h * s;
+ return { w, h, overflow: false, set: null, nodes: (x, y, color) => [logoNode(c, { x, y, w, h }, color)] };
+ }
+ const name = c.recipe.brand.name.trim();
+ if (!name) return null;
+ const family = c.recipe.brand.fonts.heading?.trim() || c.pairing.hero.family;
+ const set = c.set("brand", name, { role: "hero", family, weight: 700, tracking: 0, leading: 1.1, x: o.x ?? 0, y: o.y ?? 0, width: o.maxW, maxLines: 1, max: o.h * 0.9, min: Math.min(o.h * 0.9, o.min ?? c.S * 0.03), align: o.align });
+ if (!set) return null;
+ return { w: set.ink.w, h: set.cap.bottom - set.cap.top, overflow: set.overflow, set, nodes: () => [] };
+}
+
+// ---------------------------------------------------------------------------
+// Corner facts (L8): tiny type on the grid's corners, for scale contrast against the hero
+
+export type Corner = "tl" | "tr" | "bl" | "br";
+
+export interface CornerFact {
+ at: Corner;
+ /** The field it shows (its words exactly as typed), or "" for a fixed mark such as an index. */
+ field: string;
+ text: string;
+}
+
+export interface CornerFacts {
+ overflow: string[];
+ /** Where each fact's ink sits (for keeping other things clear of them). */
+ boxes: Box[];
+ draw(kit: DrawKit, fill: Paint): DisplayNode[];
+}
+
+/**
+ * Up to four facts on the corners of a box (the safe area by default), in the pairing's meta face: the top ones hang
+ * from its top edge, the bottom ones stand on its bottom edge, left ones flush left, right ones flush right. Each
+ * types on from `at`, a beat apart. An empty fact is skipped.
+ */
+export function corners(c: PosterContext, facts: CornerFact[], o: { at: number; size?: number; box?: Box; width?: number }): CornerFacts {
+ const box = o.box ?? c.safe;
+ const size = o.size ?? c.S * (c.cover ? 0.024 : 0.02);
+ const width = o.width ?? box.w * 0.46;
+ const sets: { set: TypeSet; plan: TypePlan; mark: boolean }[] = [];
+ const overflow: string[] = [];
+ facts
+ .filter((f) => f.text.trim())
+ .forEach((f, i) => {
+ const right = f.at === "tr" || f.at === "br";
+ const x = right ? box.x + box.w - width : box.x;
+ const opts: SetOptions = { role: "meta", x, y: box.y, width, maxLines: 1, max: size, min: Math.max(c.S * 0.017, size * 0.8), align: right ? "right" : "left", preset: "fade-rise" };
+ let set = c.set(f.field || `corner.${f.at}`, f.text, opts);
+ if (!set) return;
+ // Top facts hang their em box from the top edge; bottom ones stand theirs on the bottom edge.
+ set = c.set(f.field || `corner.${f.at}`, f.text, { ...opts, max: set.size, min: set.size, y: f.at === "bl" || f.at === "br" ? box.y + box.h - set.size + set.cap.top : box.y + set.cap.top });
+ if (!set) return;
+ if (set.overflow && f.field) overflow.push(f.field);
+ sets.push({ set, mark: !f.field, plan: c.move(set, { in: "fade-rise", at: o.at + i * 0.12, rate: 34 }, `corner.${f.at}`) });
+ });
+ return {
+ overflow,
+ boxes: sets.map((s) => s.set.ink),
+ // A fixed mark (an index, an arrow) is part of the design, not anyone's words.
+ draw: (kit, fill) => sets.flatMap((s) => (s.mark ? asDecor(kit.type(s.plan, { fill })) : kit.type(s.plan, { fill }))),
+ };
+}
+
+/** Nodes marked decorative (not the typed words). */
+export const asDecor = (nodes: readonly DisplayNode[]): DisplayNode[] => nodes.map((n): DisplayNode => (n.type === "text" ? { ...n, decor: true } : n.type === "group" ? { ...n, children: asDecor(n.children) } : n));
+
+/** The two-shadow rule under type or a shape (contact and ambient, tinted to the ground): never a glow on a mid-tone ground. */
+export const shadowed = (c: PosterContext, nodes: readonly DisplayNode[], size: number, bounds: Box, key: string, opacity = 1): DisplayNode[] => twoShadow({ nodes, size, ground: c.pal.ground, bounds, key, opacity });
+
+/** Whether a ground is dark enough for light to glow on it (OKLab L under 0.2). */
+export const glowsOn = (ground: string): boolean => toLab(ground).L < 0.2;
+
+/** Whether the logo is one of Fuobe's sample marks (drawn in one colour). */
+export { sampleMark };
+
+// ---------------------------------------------------------------------------
+// Overlays
+
+/** A pill round a set (its ink box), tilted, popping in with `p`. */
+export function pillOn(set: TypeSet, content: DisplayNode[], fill: Paint, o: { deg?: number; p?: number; stroke?: { paint: Paint; width: number } } = {}): DisplayNode {
+ const ink = { x: set.ink.x, y: set.lines[0].y + set.cap.top, w: set.ink.w, h: set.cap.bottom - set.cap.top };
+ return pillTag(pillBox(ink, set.size), fill, content, o);
+}
+
+/** A set's cap band (top of the first line's capitals to the last baseline). */
+export const capBand = (set: TypeSet): Box => {
+ const top = set.lines[0].y + set.cap.top;
+ const bottom = set.lines[set.lines.length - 1].baseline;
+ return { x: set.ink.x, y: top, w: set.ink.w, h: bottom - top };
+};
+
+/** A set's total height from its first cap top to its last baseline. */
+export const setHeight = (set: TypeSet): number => capBand(set).h;
+
+/** Shift a set so its first cap top sits at `y` (setType places the em box). */
+export function capAt(c: PosterContext, field: string, text: string, o: SetOptions): TypeSet | null {
+ const first = c.set(field, text, o);
+ if (!first) return null;
+ const dy = o.y - (first.lines[0].y + first.cap.top);
+ if (Math.abs(dy) < 0.01) return first;
+ return c.set(field, text, { ...o, y: o.y + dy });
+}
+
+/** A set whose first line follows a typed break or space (a line of a block set line by line, spelled as typed). */
+export function withLeadGap(set: TypeSet, gap: string): TypeSet {
+ if (!gap) return set;
+ const first = set.lines[0];
+ return {
+ ...set,
+ lines: set.lines.map((l, i) => (i ? l : { ...l, gap })),
+ words: set.words.map((w, i) => (i ? w : { ...w, gap })),
+ glyphs: set.glyphs.map((g, i) => (i || !first.glyphs ? g : { ...g, gap })),
+ };
+}
+
+export interface LineStack {
+ /** One set per line, top to bottom, each fitted to the width on its own. */
+ sets: TypeSet[];
+ overflow: boolean;
+ /** From the first line's cap top to the last line's baseline (ink below the last baseline not counted). */
+ band: Box;
+ /** The smallest line's size (for the scale of everything round it). */
+ size: number;
+}
+
+/**
+ * Display type set line by line, each line fitted to the width on its own (the poster's justified stack): the words
+ * break as one set would break them (balanced, never on a little joining word, best after a clause's comma), then each
+ * line takes the largest size at which it fills `fill` of the width, no line more than `ratio` times the smallest. The
+ * block shrinks until it fits `room` and sits at `anchor` (0 top, 0.5 middle, 1 bottom) of it. The lines are spelled
+ * exactly as typed (the break's space is kept on the next line). Null when the text is empty.
+ */
+export function fitLines(c: PosterContext, field: string, text: string, o: { role?: Role; x: number; top: number; room: number; width: number; maxLines: number; max: number; min: number; anchor?: number; centre?: number; stack?: boolean; align?: "left" | "centre" | "right"; preset?: PresetId; fill?: number; ratio?: number; gap?: number; family?: string; weight?: number; tracking?: number; leading?: number; style?: "normal" | "italic"; wordSpace?: number }): LineStack | null {
+ if (!text.trim()) return null;
+ const role = o.role ?? "hero";
+ const common = { role, x: o.x, width: o.width, align: o.align ?? "left", ...(o.preset && { preset: o.preset }), ...(o.family && { family: o.family }), ...(o.weight && { weight: o.weight }), ...(o.tracking !== undefined && { tracking: o.tracking }), ...(o.leading && { leading: o.leading }), ...(o.style && { style: o.style }), ...(o.wordSpace !== undefined && { wordSpace: o.wordSpace }) } as const;
+ const build = (max: number, top: number): LineStack | null => {
+ let base = c.set(field, text, { ...common, y: top, maxLines: o.maxLines, max, min: Math.min(o.min, max) });
+ if (!base) return null;
+ // A stack wants two lines or more: a text of several words that set on one line breaks as it would in a narrower box.
+ for (const narrow of o.stack ? [0.72, 0.58, 0.46] : []) {
+ if (base.lines.length > 1 || base.words.length < 2 || base.overflow) break;
+ const n = c.set(field, text, { ...common, y: top, width: o.width * narrow, maxLines: o.maxLines, max, min: Math.min(o.min, max) });
+ if (n && !n.overflow) base = n;
+ }
+ if (base.overflow) return { sets: [base], overflow: true, band: capBand(base), size: base.size };
+ const fill = o.fill ?? 0.96;
+ const lines = base.lines.map((l) => ({ text: l.text, gap: l.gap }));
+ // Each line on its own: the largest size (up to `ratio` × the block's) that fills the width.
+ const own = lines.map((l) => c.set(field, l.text, { ...common, y: top, width: o.width * fill, maxLines: 1, max: base.size * (o.ratio ?? 1.45), min: base.size })?.size ?? base.size);
+ const smallest = Math.min(...own);
+ const sizes = own.map((s) => Math.min(s, smallest * (o.ratio ?? 1.45)));
+ const sets: TypeSet[] = [];
+ let y = top;
+ for (let i = 0; i < lines.length; i++) {
+ let s = capAt(c, field, lines[i].text, { ...common, y, maxLines: 1, max: sizes[i], min: sizes[i] });
+ if (!s) return null;
+ const capH = s.cap.bottom - s.cap.top;
+ // Ascenders taller than the capitals (b, d, l) never reach into the line above.
+ const rise = s.lines[0].y + s.cap.top - s.lines[0].ink.y;
+ if (i && rise > capH * 0.02) s = capAt(c, field, lines[i].text, { ...common, y: y + rise, maxLines: 1, max: sizes[i], min: sizes[i] }) ?? s;
+ sets.push(i ? withLeadGap(s, lines[i].gap) : s);
+ const l = s.lines[0];
+ const descends = l.ink.y + l.ink.h > l.baseline + capH * 0.06;
+ y = Math.max(l.baseline + capH * (o.gap ?? 0.11), descends ? l.ink.y + l.ink.h + capH * 0.06 : -Infinity);
+ }
+ const first = sets[0];
+ const last = sets[sets.length - 1];
+ const top0 = first.lines[0].y + first.cap.top;
+ const x0 = Math.min(...sets.map((s) => s.ink.x));
+ const x1 = Math.max(...sets.map((s) => s.ink.x + s.ink.w));
+ return { sets, overflow: sets.some((s) => s.overflow), band: { x: x0, y: top0, w: x1 - x0, h: last.lines[0].baseline - top0 }, size: Math.min(...sets.map((s) => s.size)) };
+ };
+ let max = o.max;
+ let st = build(max, o.top);
+ for (let i = 0; st && !st.overflow && i < 16 && st.band.h > o.room; i++) {
+ max *= 0.93;
+ st = build(max, o.top);
+ }
+ if (!st || st.overflow) return st;
+ const free = Math.max(0, o.room - st.band.h);
+ const y = o.centre !== undefined ? o.top + Math.min(free, Math.max(0, o.centre - st.band.h / 2 - o.top)) : o.top + free * (o.anchor ?? 0.5);
+ return Math.abs(y - o.top) < 0.01 ? st : build(max, y);
+}
+
+/** A line stack's sets moved together: each line's entrance `each` seconds after the one above. */
+export function moveLines(c: PosterContext, st: LineStack, motion: TextMotion, id: string, each = 0.12): TypePlan[] {
+ return st.sets.map((s, i) => c.move(s, { ...motion, at: motion.at + i * each, ...(motion.loopAt !== undefined && { loopAt: motion.loopAt + i * 0.12 }) }, `${id}.${i}`));
+}
+
+/** When the last of a stack's lines has landed. */
+export const stackLanded = (plans: TypePlan[]): number => Math.max(0, ...plans.map((p) => p.settled));
+
+/**
+ * The vertical bands of a frame: the top corner row (brand, address) hangs from the safe area's top, the bottom
+ * corner row stands on its bottom (the safe line), and the hero lives between, its optical centre near 45 % of the
+ * height. `top` and `bottom` are the room left between the rows (after a gap); `centre` the hero's target.
+ */
+export function bands(c: PosterContext, o: { topRow?: number; bottomRow?: number; gap?: number } = {}): { top: number; bottom: number; centre: number; room: number } {
+ const { safe, S, design } = c;
+ const gap = o.gap ?? S * 0.05;
+ const top = safe.y + (o.topRow ?? S * 0.05) + gap;
+ const bottom = safe.y + safe.h - (o.bottomRow ?? S * 0.03) - gap;
+ return { top, bottom, centre: design.h * 0.45, room: bottom - top };
+}
+
+/**
+ * The highlighter's colour: of the kit's colours (and paper / night), the one at least 0.25 OKLab lightness away from
+ * the ground that the ink reads best on (3:1 or more), so the bar always shows against the field and the words on it read.
+ */
+export function markColor(c: PosterContext, ground: string, ink: string): string {
+ const { pal } = c;
+ const gL = toLab(ground).L;
+ const cands = [pal.accent, pal.brand[1], pal.brand[0], pal.paper, pal.night];
+ const far = cands.filter((k) => Math.abs(toLab(k).L - gL) >= 0.25 && contrastOf(ink, k) >= 3);
+ if (far.length) return far.sort((a, b) => contrastOf(ink, b) + chroma(b) * 4 - (contrastOf(ink, a) + chroma(a) * 4))[0];
+ // None qualifies: the accent moved in lightness until it stands 0.25 off the ground.
+ return withLightness(pal.accent, gL < 0.5 ? Math.min(0.92, gL + 0.3) : Math.max(0.12, gL - 0.3));
+}
+
+/**
+ * The bottom corner row: the corner note (field "note") standing on the safe line at the left, and a drawn ↗ index
+ * at the right. `rowH` is the room it takes above the safe line.
+ */
+export function footRow(c: PosterContext, at: number, o: { box?: Box; size?: number; arrow?: boolean } = {}): { overflow: string[]; boxes: Box[]; rowH: number; draw(kit: DrawKit, fill: Paint, mark?: Paint): DisplayNode[] } {
+ const box = o.box ?? c.safe;
+ const size = o.size ?? c.S * (c.cover ? 0.024 : 0.02);
+ const facts = corners(c, [{ at: "bl", field: "note", text: c.field("note") }], { at, size, box, width: box.w * 0.55 });
+ c.ev("foot.arrow", "draw", at + 0.15, 0.5, "draw");
+ const a = size * 0.9;
+ const ax = box.x + box.w - a;
+ const ay = box.y + box.h - a - size * 0.05;
+ return {
+ overflow: facts.overflow,
+ boxes: [...facts.boxes, ...(o.arrow === false ? [] : [{ x: ax, y: ay, w: a, h: a }])],
+ rowH: size * 1.1,
+ draw(kit, fill, mark) {
+ const out = facts.draw(kit, fill);
+ if (o.arrow !== false && kit.L("foot.arrow") > 0) out.push(arrow({ x: ax, y: ay, size: a, color: mark ?? fill, p: kit.P("foot.arrow"), width: Math.max(1.5, size * 0.08) }));
+ return out;
+ },
+ };
+}
+
+/** A one-line set whose baseline sits on `baseline` (for rows of facts of different sizes on one line). */
+export function onBaseline(c: PosterContext, field: string, text: string, o: SetOptions, baseline: number): TypeSet | null {
+ const probe = c.set(field, text, { ...o, y: 0 });
+ if (!probe) return null;
+ const dy = baseline - probe.lines[0].baseline;
+ return c.set(field, text, { ...o, max: probe.size, min: probe.size, y: dy });
+}
+
+/** Seconds: when a set's entrance has landed (from its plan). */
+export const landed = (p: TypePlan): number => p.settled;
+
+/** A whole frame of one colour at an alpha (a scrim over a photo). */
+export const scrim = (c: PosterContext, paint: Paint): DisplayNode => ({ type: "rect", x: 0, y: 0, w: c.design.w, h: c.design.h, fill: paint });
+
+/** A vertical scrim: transparent at `from` (share of the height) to the colour at `to`. */
+export function fadeScrim(c: PosterContext, color: string, from: number, to: number, alpha = 0.85): DisplayNode {
+ const { w, h } = c.design;
+ return { type: "rect", x: 0, y: 0, w, h, fill: { kind: "linear", x0: 0, y0: h * from, x1: 0, y1: h * to, stops: [{ at: 0, color: rgba(color, 0) }, { at: 0.6, color: rgba(color, alpha * 0.75) }, { at: 1, color: rgba(color, alpha) }] } };
+}
+
+export { rgba, pool };
+
+/**
+ * The brand's sign-off as it enters: a name set in type moves with its own plan; a logo rises 2 % and fades in on the
+ * event `id` (its plain progress for the fade).
+ */
+export function signNodes(c: PosterContext, kit: DrawKit, sign: Sign | null, plan: TypePlan | null, id: string, x: number, y: number, color: string): DisplayNode[] {
+ if (!sign) return [];
+ if (plan) return kit.type(plan, { fill: color });
+ const lin = kit.L(id);
+ if (lin <= 0) return [];
+ const p = kit.P(id);
+ const nodes = sign.nodes(x, y, color);
+ if (p >= 1 && lin >= 1) return nodes;
+ return [group(nodes, { transform: translate(0, (1 - p) * c.S * 0.02), ...(lin < 0.5 && { opacity: lin / 0.5 }) })];
+}
+
+/** Bring the sign in at `at`: its own text motion when it is the name, else a logo event `id`. */
+export function signIn(c: PosterContext, sign: Sign | null, id: string, at: number, preset: PresetId = "word-lift"): TypePlan | null {
+ if (!sign) return null;
+ if (sign.set) return c.move(sign.set, { in: preset, at }, id);
+ c.ev(id, "enter", at, 0.55, "glide");
+ return null;
+}
+
+/**
+ * The address on the top corner row, flush right, its baseline on the brand's (the name's baseline, or a logo's
+ * foot), so the two top corners read as one line.
+ */
+export function topSite(c: PosterContext, sign: Sign | null, size: number, o: { width?: number; field?: string } = {}): TypeSet | null {
+ const { safe } = c;
+ const width = o.width ?? safe.w * 0.5;
+ const base = sign ? (sign.set ? sign.set.lines[0].baseline : safe.y + sign.h) : safe.y + size;
+ return onBaseline(c, o.field ?? "website", c.field(o.field ?? "website"), { role: "meta", x: safe.x + safe.w - width, y: 0, width, maxLines: 1, max: size, min: size * 0.8, align: "right", preset: "fade-rise" }, base);
+}
+
+/** Place a sign's name set at (x, y) (its em box top-left), re-laid out there. */
+export function placeSign(c: PosterContext, sign: Sign | null, o: { x: number; y: number; maxW: number; h: number; min?: number; align?: "left" | "centre" | "right" }): Sign | null {
+ if (!sign?.set) return sign;
+ return brandSign(c, { ...o });
+}
diff --git a/src/lib/motion/scenes/marketing/quote.ts b/src/lib/motion/scenes/marketing/quote.ts
index c7865545..29fad367 100644
--- a/src/lib/motion/scenes/marketing/quote.ts
+++ b/src/lib/motion/scenes/marketing/quote.ts
@@ -1,92 +1,152 @@
/**
- * Five-Star Quote: five stars draw their outlines and fill one by one with a small spring, then the customer's words
- * set line by line, exactly as typed (their own quotation marks, hung in the margin so the letters line up), the name
- * follows under a short rule, and the brand signs off at the foot (its logo, else its name). The whole is centred in
- * the frame, and the beats spread over the clip's length.
+ * Five-Star Quote: an editorial page. A portrait in an arched panel stands at the top right (the left side of a wide
+ * frame), seated on a hairline with its shadow under it, its photo graded softly into the brand's tones, rising out of
+ * a mask from its foot and pushing in slowly. Five stars pop in one after another beside it; the customer's words are
+ * the hero, set large across the page in a soft serif with the opening mark hung in the margin, cutting up line by
+ * line; their name follows on one line, and the brand and its web address settle at the foot. A giant tonal
+ * quotation mark sits off to one side behind it all.
*/
-import { group, translate, type DisplayNode } from "../../display";
-import { lineRuns } from "../end-card/shared";
-import { brandMark, ev, marketingScene, MIN_BODY, risingLines, setText, spread, starPath, textBlock } from "./kit";
+import { group, type DisplayNode } from "../../display";
+import { ensureContrast, mixOk } from "../../color";
+import { duotone, coverCrop, pushIn } from "../../fx/photo";
+import { rings } from "../../fx/background";
+import { twoShadow } from "../../fx/depth";
+import { rule } from "../../fx/overlays";
+import { brandSign, capBand, corners, metaInk, paperField, meshField, posterScene, signIn, signNodes, toneOf, type SetOptions } from "./poster";
+import { starPath } from "./kit";
-/** Opening quotation marks that hang into the margin. */
-const OPENERS = new Set(["“", '"', "‘", "'", "«", "„", "‹", "「", "『"]);
-
-export default marketingScene({
+export default posterScene({
id: "marketing/quote",
name: "Five-Star Quote",
+ pairing: "T5",
look: "light",
build(c) {
- const { S, safe, palette: pal, design } = c;
- const width = c.wide ? Math.min(safe.w, S * 1.4) : safe.w;
- const left0 = (design.w - width) / 2;
- const text = c.field("quote");
- const first = [...text][0] ?? "";
- const mark = brandMark(c, { maxW: S * (c.wide ? 0.32 : 0.46), h: S * (c.tall ? 0.085 : 0.065), color: pal.ink, minName: 0.04 });
- const footH = mark ? mark.h + S * 0.07 : 0;
- // Probe the size first, then hang the opening mark by its own width.
- const size = { weight: 500, maxLines: c.tall ? 8 : 6, max: S * (c.tall ? 0.13 : c.wide ? 0.08 : 0.1), min: S * 0.045, lineHeight: 1.16 };
- const probe = setText(c, text, { ...size, width });
- const hang = probe && probe.dir === "ltr" && OPENERS.has(first) ? c.measure(first, probe.font) : 0;
- const quote = hang ? setText(c, text, { ...size, width: width - hang }) : probe;
- const name = setText(c, c.field("name"), { family: "body", weight: 600, width: width - S * 0.075, maxLines: 2, max: S * (c.tall ? 0.056 : 0.048), min: S * 0.038, lineHeight: 1.25 });
- const star = S * (c.wide ? 0.06 : c.tall ? 0.075 : 0.068);
- const starGap = star * 0.32;
- const g1 = S * 0.06;
- const g2 = S * 0.055;
- const total = star + g1 + (quote?.height ?? 0) + (name ? g2 + name.height : 0);
- const top = safe.y + Math.max(0, (safe.h - footH - total) / 2);
- const quoteLeft = left0 + hang;
- const quoteB = quote ? textBlock("quote", quote, { y: top + star + g1, color: pal.ink, left: quoteLeft, width: width - hang }) : null;
- const nameY = top + star + g1 + (quote?.height ?? 0) + g2;
- // A short rule leads the name (left-to-right names; a right-to-left one is set without it).
- const ruleW = name && name.dir !== "rtl" ? S * 0.05 : 0;
- const nameB = name ? textBlock("name", name, { y: nameY, color: pal.muted, left: left0 + (ruleW ? ruleW + S * 0.025 : 0), width: width - (ruleW ? ruleW + S * 0.025 : 0) }) : null;
- const stars = Array.from({ length: 5 }, (_, i) => ({ cx: left0 + star / 2 + i * (star + starGap), cy: top + star / 2 }));
- const starD = stars.map((s) => starPath(s.cx, s.cy, star / 2, star * 0.21, 5));
- const footY = safe.y + safe.h - (mark?.h ?? 0);
+ const { S, safe, pal, design } = c;
+ const photo = c.recipe.media?.product ? c.input.images?.product : undefined;
+ const side = c.wide;
+ // The panel: the top right of the page (the left 40 % of a wide frame), an arch on top.
+ const panelW = Math.round(design.w * (side ? 0.34 : c.tall ? 0.58 : 0.52));
+ const panelTop = Math.round(c.cover ? safe.y : design.h * 0.04);
+ // An arch at every size (on a wide frame, standing on the left).
+ const panel = side ? { x: Math.round(S * 0.07), y: Math.round(S * 0.07), w: panelW, h: design.h - Math.round(S * 0.14) } : { x: design.w - panelW + Math.round(design.w * 0.04), y: panelTop, w: panelW, h: Math.round(design.h * (c.tall ? 0.45 : 0.42)) - panelTop };
+ const colX = side ? panel.x + panelW + S * 0.08 : safe.x;
+ const colW = side ? safe.x + safe.w - colX : safe.w;
+ const signH = S * (c.cover ? 0.046 : 0.04);
+ const starR = S * (c.cover ? 0.026 : 0.022);
+ const starsTop = safe.y + starR;
+ // The brand at the foot, well clear of anything under the frame's lower edge.
+ const footY = safe.y + safe.h - (c.cover ? S * 0.04 : 0);
+ const sign0 = brandSign(c, { maxW: colW * 0.5, h: signH, x: colX, y: 0, min: S * (c.cover ? 0.056 : 0.03) });
+ const signY = footY - (sign0?.h ?? 0);
+ const sign = sign0?.set ? brandSign(c, { maxW: colW * 0.5, h: signH, x: colX, y: signY, min: S * (c.cover ? 0.056 : 0.03) }) : sign0;
+ const nameSize = S * (c.cover ? 0.036 : 0.03);
+ const nameOpts = (y: number, max: number, min: number): SetOptions => ({ role: "meta", weight: 600, x: colX, y, width: colW, maxLines: 1, max, min, tracking: 0.02 });
+ let name0 = c.set("name", c.field("name"), nameOpts(0, nameSize, S * 0.022));
+ // Kept to one line where it fits; two when it is long.
+ if (name0?.overflow) name0 = c.set("name", c.field("name"), { ...nameOpts(0, nameSize, S * 0.022), maxLines: 2 });
+ const nameH = name0 ? capBand(name0).h : 0;
+ const quoteTop = side ? starsTop + starR * 2 + S * 0.06 : panel.y + panel.h + S * 0.07;
+ const quoteRoom = signY - S * 0.06 - (name0 ? nameH + S * 0.045 : 0) - quoteTop;
+ const qo = (max: number, x = colX, w = colW) => ({ role: "hero" as const, x, y: quoteTop, width: w, maxLines: 7, max, min: S * 0.036, leading: 1.04, preset: "cut-rise" as const, even: 0.45 });
+ let quote = c.set("quote", c.field("quote"), qo(Math.min(S * (side ? 0.11 : 0.17), quoteRoom / 2)));
+ for (let i = 0; quote && i < 24 && capBand(quote).h > quoteRoom && quote.size > S * 0.0365; i++) quote = c.set("quote", c.field("quote"), qo(Math.max(S * 0.036, quote.size * 0.93)));
+ // Too long for the page even at its smallest: ask for fewer words.
+ const quoteTall = !!quote && capBand(quote).h > quoteRoom + 1;
+ // The opening quote hangs into the column's own room, never past the safe area's edge.
+ const hang = quote ? Math.max(0, colX - quote.ink.x) : 0;
+ if (quote && hang > 0.5) quote = c.set("quote", c.field("quote"), { ...qo(quote.size, colX + hang, colW - hang), min: Math.min(quote.size, S * 0.036) });
+ // Hanging the mark can add a line: shrink again until it fits.
+ for (let i = 0; quote && hang > 0.5 && i < 24 && capBand(quote).h > quoteRoom && quote.size > S * 0.0365; i++) quote = c.set("quote", c.field("quote"), { ...qo(Math.max(S * 0.036, quote.size * 0.94), colX + hang, colW - hang), min: S * 0.036 });
+ const qBand = quote ? capBand(quote) : { x: colX, y: quoteTop, w: 0, h: 0 };
+ const name = name0 ? c.set("name", c.field("name"), { ...nameOpts(qBand.y + qBand.h + S * 0.045, name0.size, name0.size), maxLines: name0.lines.length }) : null;
+
+ const k = c.spread(3.2, 1.6);
+ c.ev("panel", "hero", 0, 0.8, "enter");
+ c.ev("seat", "draw", 0.3, 0.6, "draw");
+ const quotePlan = quote ? c.move(quote, { in: "cut-rise", at: 0.2, hero: true }) : null;
+ const qDone = quotePlan?.settled ?? 1.2;
+ // The stars pop in one after another as the words settle.
+ for (let i = 0; i < 5; i++) c.ev(`star.${i}`, "pop", Math.max(0.3, qDone - 0.35) + i * 0.08, 0.4, "pop", { group: "stars", unit: "elements" });
+ const namePlan = name ? c.move(name, { in: "word-lift", at: qDone + 0.05 * k }) : null;
+ const signPlan = signIn(c, sign, "brand", Math.min(1.2, qDone + 0.25 * k));
+ const facts = corners(c, [{ at: "br", field: "website", text: c.field("website") }], { at: qDone + 0.35 * k, box: { x: colX, y: safe.y, w: colW, h: footY - safe.y - Math.max(0, ((sign?.h ?? 0) - S * 0.024) / 2) } });
+ // The corner note rides the stars' line, after them.
+ const noteSize = S * (c.cover ? 0.024 : 0.02);
+ // Under the stars, on its own line.
+ const note = c.set("note", c.field("note"), { role: "meta", x: colX, y: starsTop + starR + S * 0.025, width: Math.max(S * 0.2, (side ? colX + colW : panel.x - S * 0.03) - colX), maxLines: 1, max: noteSize, min: noteSize * 0.8, tracking: 0.08, preset: "fade-rise" });
+ const notePlan = note ? c.move(note, { in: "fade-rise", at: 0.9, rate: 30 }) : null;
+ c.ev("sweep", "move", Math.min(c.last - 1.2, Math.max(qDone + 0.6, 3.0)), 0.8, "move");
- // The beats, spread over the length: the stars, the words, the name, the sign-off.
- const k = spread(c, 2.4);
- const lines = quote?.lines.length ?? 0;
- const qAt = 0.6 * k;
- const each = Math.max(0.08, Math.min(0.14, 0.11 * k));
- const nameAt = qAt + lines * each + 0.3 * k;
- const events = [
- ev("outline", "fade", 0.08, 0.35, "enter"),
- ...stars.map((_, i) => ev(`star.${i}`, "pop", 0.2 + i * 0.08 * Math.max(1, Math.min(1.5, k)), 0.45, "pop", { group: "stars", unit: "elements" })),
- ...Array.from({ length: lines }, (_, i) => ev(`line.${i}`, "enter", qAt + i * each, 0.6, "glide", { group: "quote", unit: "elements" })),
- ...(name ? [ev("rule", "draw", nameAt - 0.1, 0.45, "draw"), ev("name", "enter", nameAt, 0.5, "glide")] : []),
- ...(mark ? [ev("brand", "enter", nameAt + 0.55 * k, 0.6, "glide")] : []),
- ];
- const outlineW = Math.max(1.5, star * 0.045);
+ const arch = (b: { x: number; y: number; w: number; h: number }) => {
+ const r = b.w / 2;
+ return `M${b.x} ${b.y + b.h}V${b.y + r}A${r} ${r} 0 0 1 ${b.x + b.w} ${b.y + r}V${b.y + b.h}Z`;
+ };
+ const panelPath = arch(panel);
+ // Stars read at 3:1 or more on every look: gold on a dark field, the brand's deep tone on paper.
+ const starFill = ensureContrast(c.dark ? mixOk("#d9b26b", pal.accent, 0.15) : mixOk(pal.brand[0], pal.accent, 0.15), pal.ground, 3.2);
return {
- events,
- overflow: [...(quote?.overflow ? ["quote"] : []), ...(name?.overflow ? ["name"] : []), ...(mark?.overflow ? ["brand"] : [])],
- signature: 0.2 + 0.18,
- frame(_t, P, Lp) {
- const nodes: DisplayNode[] = [];
- const o = P("outline");
- stars.forEach((s, i) => {
- const f = P(`star.${i}`);
- const l = Lp(`star.${i}`);
- if (o > 0 && f < 1) nodes.push({ type: "path", d: starD[i], stroke: { paint: pal.mark, width: outlineW, join: "round" }, opacity: o });
- if (l > 0) {
- const sc = Math.max(0, 0.4 + 0.6 * f);
- nodes.push(group([{ type: "path", d: starD[i], fill: pal.mark }], { transform: [sc, 0, 0, sc, s.cx - sc * s.cx, s.cy - sc * s.cy], ...(l < 0.2 && { opacity: l / 0.2 }) }));
+ overflow: [...(quote?.overflow || quoteTall ? ["quote"] : []), ...(name?.overflow ? ["name"] : []), ...(sign?.overflow ? ["brand"] : []), ...(note?.overflow ? ["note"] : []), ...facts.overflow],
+ signature: qDone + 0.3,
+ draw(t, kit) {
+ const field = c.dark ? meshField(c, t) : [...paperField(c, t, { tint: pal.brand[1], light: 0.6 }), ...meshField(c, t, { colors: [mixOk(pal.brand[1], pal.ground, 0.55), mixOk(pal.brand[0], pal.ground, 0.9), mixOk(pal.brand[1], pal.ground, 0.75)], amplitude: 0.08 }).slice(1)];
+ const pl = kit.L("panel");
+ const pp = kit.P("panel");
+ const subject: DisplayNode[] = [];
+ if (pl > 0) {
+ const content: DisplayNode[] = [];
+ if (photo) {
+ const { zoom } = pushIn(t, c.last, { from: 1.02, to: 1.07 });
+ // Framed on the face (both eyes in, whatever the panel's shape).
+ content.push({ type: "image", bleed: true, src: "product", x: panel.x, y: panel.y, w: panel.w, h: panel.h, crop: coverCrop(photo, panel, { x: 0.55, y: 0.32 }, zoom) }, ...duotone(panel, { dark: mixOk(pal.brand[0], "#000000", 0.4), light: pal.brand[1], darkAlpha: 0.16, lightAlpha: 0.12 }));
+ } else {
+ content.push({ type: "rect", ...panel, fill: { kind: "linear", x0: 0, y0: panel.y, x1: 0, y1: panel.y + panel.h, stops: [{ at: 0, color: mixOk(pal.brand[1], pal.ground, 0.3) }, { at: 1, color: mixOk(pal.brand[0], pal.ground, 0.4) }] } }, rings({ cx: panel.x + panel.w / 2, cy: panel.y + panel.h * 0.6, count: 6, gap: panel.w * 0.12, colors: [pal.paper], alpha: 0.35 }));
}
- });
- if (quoteB) nodes.push(...risingLines(quoteB, (i) => P(`line.${i}`), (i) => (i === 0 ? -hang : 0)));
- if (nameB && name) {
- const r = P("rule");
- const ry = nameY + name.lineHeight / 2;
- if (r > 0 && ruleW) nodes.push({ type: "path", d: `M${left0} ${ry}H${left0 + ruleW}`, stroke: { paint: pal.mark, width: Math.max(1.5, S * 0.003), trim: r, length: ruleW, cap: "round" } });
- const p = P("name");
- if (p > 0) nodes.push(group([lineRuns(nameB)], { transform: translate(0, (1 - p) * S * 0.02), ...(p < 1 && { opacity: p }) }));
+ // A light band crosses the portrait once in the hold.
+ const sw = kit.L("sweep");
+ if (sw > 0 && sw < 1) {
+ const bw = panel.w * 0.35;
+ const x = panel.x - bw + kit.P("sweep") * (panel.w + 2 * bw);
+ content.push({ type: "rect", x: x - bw / 2, y: panel.y, w: bw, h: panel.h, fill: { kind: "linear", x0: x - bw / 2, y0: 0, x1: x + bw / 2, y1: 0, stops: [{ at: 0, color: "rgba(255,255,255,0)" }, { at: 0.5, color: "rgba(255,255,255,0.22)" }, { at: 1, color: "rgba(255,255,255,0)" }] } });
+ }
+ const shape: DisplayNode = { type: "path", d: panelPath, fill: "#000000" };
+ // It opens as an arch at every moment: the arch grows from its foot's middle (never a square strip, never a fade).
+ const shown = Math.min(1, pl * 1.15);
+ const e = Math.max(0.001, pp);
+ const gw = panel.w * (0.35 + 0.65 * e);
+ const gh = panel.h * (0.35 + 0.65 * e);
+ const grow = arch({ x: panel.x + (panel.w - gw) / 2, y: panel.y + panel.h - gh, w: gw, h: gh });
+ const clip = shown < 1 || pp < 1 ? grow : panelPath;
+ subject.push(group([...twoShadow({ nodes: [{ ...shape, d: clip }], size: panel.h * 0.5, ground: pal.ground, bounds: panel, key: `fq|${panel.w}x${panel.h}|${clip === panelPath ? 1 : e.toFixed(2)}`, opacity: Math.min(1, shown) }), group(content, { clip: { type: "path", d: clip }, isolate: panel })]));
+ }
+ // The hairline the arch stands on.
+ const sp = kit.P("seat");
+ const em = quote?.size ?? S * 0.08;
+ // The shelf runs from the text's margin to the frame's edge, under the arch.
+ if (!side && sp > 0) subject.push(rule({ x: safe.x, y: panel.y + panel.h, w: design.w - safe.x, color: toneOf(pal, 0.45), p: sp, width: Math.max(1, S * 0.0016) }));
+ void em;
+ const ghosts: DisplayNode[] = [];
+ const hero: DisplayNode[] = [];
+ for (let i = 0; i < 5; i++) {
+ const q = kit.P(`star.${i}`);
+ if (kit.L(`star.${i}`) <= 0) continue;
+ const x = colX + starR + i * starR * 2.5;
+ const s = Math.max(0, q);
+ hero.push(group([{ type: "path", d: starPath(x, starsTop, starR, starR * 0.45, 5), fill: starFill }], { transform: [s, 0, 0, s, x - s * x, starsTop - s * starsTop] }));
}
- if (mark) nodes.push(...mark.draw(design.w / 2, footY, P("brand"), Lp("brand")));
- return { nodes };
+ if (quotePlan) hero.push(...kit.type(quotePlan, { fill: pal.ink }));
+ const meta: DisplayNode[] = [];
+ if (namePlan) meta.push(...kit.type(namePlan, { fill: metaInk(pal) }));
+ if (notePlan) meta.push(...kit.type(notePlan, { fill: metaInk(pal) }));
+ meta.push(...signNodes(c, kit, sign, signPlan, "brand", colX, signY, pal.ink), ...facts.draw(kit, metaInk(pal)));
+ return [
+ { role: "ground", nodes: field },
+ { role: "ghost", nodes: ghosts },
+ { role: "subject", nodes: subject, push: 0 },
+ { role: "hero", nodes: hero },
+ { role: "meta", nodes: meta },
+ ];
},
};
},
diff --git a/src/lib/motion/scenes/marketing/starburst.ts b/src/lib/motion/scenes/marketing/starburst.ts
index e714570b..74a30926 100644
--- a/src/lib/motion/scenes/marketing/starburst.ts
+++ b/src/lib/motion/scenes/marketing/starburst.ts
@@ -1,141 +1,153 @@
/**
- * Retro Starburst: 24 rays in two kit colours turn slowly behind the product the whole clip long. The product drops in
- * with a squash and a half turn that springs square onto a disc of light, and then sways and floats while it holds,
- * well inside the disc; an optional sticker badge pops on with a tilt where it covers none of the product; and the
- * headline, set big, lands on a full-width band at the foot that slides in at a slight tilt, so it reads on any ray.
- * Without a product the logo (or the name) takes its place.
+ * Retro Starburst: a collage poster. On bright paper, rays in a blush tint of the brand turn steadily round a point
+ * behind the product and a halftone of the brand's colour fades in from the far corner (never under the brand). The
+ * headline pops in word by word as a justified stack in a chunky display face with a solid extruded side in a deep
+ * tone of its own ink. The product drops in front of the words on its own shadow, a squiggle draws under the last
+ * line with one sparkle at its start, and the badge lands as a sticker with a white keyline, a little off true,
+ * wiggling once in the hold. The brand, the address, a corner note and an index arrow sit on the corners.
*/
-import { contrast } from "@/components/ads/layout";
-import { about, group, mixHex, multiply, translate, type DisplayNode } from "../../display";
-import { lineRuns } from "../end-card/shared";
-import { badgeSpot, contactShadow, ev, fitBox, heroOf, holdFloat, logoNode, marketingScene, MIN_BODY, MIN_HEAD, readable, risingLines, setText, spread, starPath, textBlock } from "./kit";
+import { group, type DisplayNode } from "../../display";
+import { ensureContrast, mixOk, toLab, withLightness } from "../../color";
+import { extrude, floorShadow } from "../../fx/depth";
+import { halftone, keyline, rotation, squiggle } from "../../fx/overlays";
+import { badgeSpot, fitBox, logoNode, starPath } from "./kit";
+import { brandSign, capBand, fitLines, footRow, litField, metaInk, moveLines, posterScene, signIn, signNodes, stackLanded, toneOf, topSite } from "./poster";
-const RAYS = 24;
-
-/** The rays as one path: every other wedge of a full turn, from (cx, cy) out to radius r, turned by `rot`. */
-export function raysPath(cx: number, cy: number, r: number, rot: number, n = RAYS): string {
- const parts: string[] = [];
- const step = (Math.PI * 2) / n;
- for (let i = 0; i < n; i += 2) {
- const a = rot + i * step;
- const b = a + step;
- parts.push(`M${cx.toFixed(1)} ${cy.toFixed(1)}L${(cx + Math.cos(a) * r).toFixed(1)} ${(cy + Math.sin(a) * r).toFixed(1)}L${(cx + Math.cos(b) * r).toFixed(1)} ${(cy + Math.sin(b) * r).toFixed(1)}Z`);
+/** Rays round (cx, cy): `n` wedges out to radius R, turned by `a` radians. */
+function rays(cx: number, cy: number, R: number, n: number, a: number): string {
+ let d = "";
+ for (let i = 0; i < n; i++) {
+ const a0 = a + (i * 2 * Math.PI) / n;
+ const a1 = a0 + Math.PI / n;
+ d += `M${cx.toFixed(1)} ${cy.toFixed(1)}L${(cx + Math.cos(a0) * R).toFixed(1)} ${(cy + Math.sin(a0) * R).toFixed(1)}L${(cx + Math.cos(a1) * R).toFixed(1)} ${(cy + Math.sin(a1) * R).toFixed(1)}Z`;
}
- return parts.join("");
+ return d;
}
-/** The band's tilt (radians): a poster's slant, square enough to read. */
-const TILT = -0.035;
-
-export default marketingScene({
+export default posterScene({
id: "marketing/starburst",
name: "Retro Starburst",
+ pairing: "T8",
look: "brand",
build(c) {
- const { S, safe, palette: pal, design, recipe } = c;
- const hero = heroOf(c);
- // The headline is the hero type: big, on a band that runs off both edges.
- const head = setText(c, c.field("headline"), { weight: 800, width: safe.w * 0.9, maxLines: 2, max: S * (c.tall ? 0.16 : c.wide ? 0.11 : 0.13), min: S * MIN_HEAD, lineHeight: 1.0 });
- const badge = setText(c, c.field("badge"), { weight: 800, width: S * 0.2, maxLines: 2, max: S * 0.056, min: S * MIN_BODY, lineHeight: 1.0 });
- const bandPad = S * (c.tall ? 0.05 : 0.04);
- const bandH = head ? head.height + bandPad * 2 : 0;
- const gapB = S * 0.06;
- // The disc: as big as the room over the band allows; the product holds inside 70 % of it.
- const roomH = safe.h - (head ? bandH + gapB : 0);
- const R = Math.min(safe.w * 0.5, roomH * 0.5);
- const stackH = 2 * R + (head ? gapB + bandH : 0);
- const top = safe.y + Math.max(0, (safe.h - stackH) / 2);
- const centre: [number, number] = [design.w / 2, top + R];
- const hold = { x: centre[0] - R * 0.7, y: centre[1] - R * 0.7, w: R * 1.4, h: R * 1.4 };
- const img = hero ? fitBox(hero, hold, hero.src === "product") : null;
- const bandY = top + 2 * R + gapB;
- const name = !hero ? setText(c, recipe.brand.name, { weight: 800, width: R * 1.3, maxLines: 2, max: S * 0.13, min: S * MIN_HEAD, lineHeight: 1.04 }) : null;
- const dark = pal.look === "dark";
- // The rays: the brand's second colour over the brand colour (Brand colour); a rich tint of the bolder kit colour on
- // the light and dark looks.
- const rayColour = pal.look === "brand" ? pal.mark : mixHex(pal.ground, pal.mark, pal.look === "light" ? 0.34 : 0.3);
- const apart = (x: string) => Math.min(contrast(x, rayColour), contrast(x, pal.ground));
- const discColour = pal.look === "brand" ? mixHex(pal.ground, "#ffffff", 0.18) : dark ? mixHex(pal.ground, pal.mark, 0.22) : "#ffffff";
- const nameB = name ? textBlock("brand", name, { y: centre[1] - name.height / 2, color: readable(discColour, pal.ink, pal.highlight.fill), cx: centre[0] }) : null;
- // The band stands apart from both the rays and the ground: the highlight, a paper white or a deep shade, whichever
- // does best against the nearer of the two.
- const deepBand = mixHex(pal.ground, "#000000", 0.45);
- const bandFill = [pal.highlight.fill, mixHex("#ffffff", pal.ground, 0.06), deepBand].reduce((best, x) => (apart(x) > apart(best) + 0.2 ? x : best));
- const headB = head ? textBlock("headline", head, { y: bandY + bandPad, color: readable(bandFill, bandFill === pal.highlight.fill ? pal.highlight.ink : pal.ground, pal.ink, pal.mark), cx: design.w / 2 }) : null;
- const reach = Math.hypot(design.w, design.h);
- // The badge: a sticker by the product where it covers none of it.
- const product = hero?.src === "product" ? (c.input.outlines?.product ?? null) : null;
- const spot = img ? badgeSpot(img, product, S * 0.13, { x: safe.x, y: safe.y, w: safe.w, h: bandY - safe.y }) : { cx: centre[0] + R * 0.62, cy: centre[1] - R * 0.62, r: S * 0.12, cover: 0 };
- const bR = spot.r;
- const badgeFill = pal.look === "brand" ? pal.ink : pal.mark;
- const badgeB = badge ? textBlock("badge", badge, { y: spot.cy - badge.height / 2, color: readable(badgeFill, pal.ground, pal.highlight.ink), cx: spot.cx }) : null;
+ const { S, safe, pal, design } = c;
+ const side = c.wide;
+ const prod = c.recipe.media?.product ? c.input.images?.product : undefined;
+ const outline = prod ? (c.input.outlines?.product ?? null) : null;
+ const signH = S * (c.cover ? 0.056 : 0.044);
+ const sign = brandSign(c, { maxW: S * 0.34, h: signH, x: safe.x, y: safe.y, min: S * (c.cover ? 0.056 : 0.03) });
+ const metaSize = S * (c.cover ? 0.024 : 0.02);
+ const site = topSite(c, sign, metaSize);
+ const row = footRow(c, 2.4);
+ const footH = metaSize * 1.1 + S * 0.05;
+ const headTop = safe.y + (sign?.h ?? 0) + S * 0.05;
+ const headW = side ? safe.w * 0.56 : safe.w;
+ const head = fitLines(c, "headline", c.field("headline"), { x: safe.x, top: headTop, room: side ? safe.h * 0.8 : (safe.y + safe.h - headTop) * 0.5, anchor: 0, width: headW, maxLines: 3, max: S * (side ? 0.17 : 0.2), min: S * 0.08, preset: "pop-in", leading: 0.92, fill: 0.95, ratio: 1.35, gap: 0.24, wordSpace: 0.3, stack: true });
+ const headB = head ? head.band : { x: safe.x, y: headTop, w: 0, h: 0 };
+ // The product: under the words (beside them on a wide frame), standing on the safe area's foot, never over a letter.
+ const prodTop = headB.y + headB.h + S * 0.07;
+ const box = side ? { x: safe.x + safe.w * 0.56, y: safe.y, w: safe.w * 0.44, h: safe.h - footH } : { x: safe.x + safe.w * 0.08, y: prodTop, w: safe.w * 0.9, h: safe.y + safe.h - footH - prodTop };
+ const img = prod ? fitBox(prod, box, true) : c.input.logo ? fitBox(c.input.logo, { ...box, y: box.y + box.h * 0.5, h: box.h * 0.35 }) : null;
+ const bR = S * (c.cover ? 0.12 : 0.1);
+ const lowBounds = side ? { x: safe.x, y: headB.y + headB.h + S * 0.02, w: safe.w * 0.56, h: safe.y + safe.h - (headB.y + headB.h + S * 0.02) } : { x: safe.x, y: headB.y + headB.h + S * 0.02, w: safe.w, h: safe.y + safe.h - (headB.y + headB.h + S * 0.02) };
+ const spot = img ? badgeSpot(img, outline, bR, lowBounds.h > bR * 2 ? lowBounds : { x: safe.x, y: safe.y, w: safe.w, h: safe.h }, 0.5) : { cx: safe.x + safe.w - bR, cy: safe.y + safe.h - bR, r: bR, cover: 0 };
+ const badge = c.set("badge", c.field("badge"), { role: "accent", x: spot.cx - spot.r * 0.75, y: 0, width: spot.r * 1.5, maxLines: 2, max: spot.r * 0.62, min: S * 0.035, align: "centre", preset: "pop-in" });
+ const badgeSet = badge ? c.set("badge", c.field("badge"), { role: "accent", x: spot.cx - spot.r * 0.75, y: spot.cy - capBand(badge).h / 2, width: spot.r * 1.5, maxLines: 2, max: badge.size, min: badge.size, align: "centre", preset: "pop-in" }) : null;
+
+ const k = c.spread(3.2, 1.6);
+ // The words cut up line by line; the one stomp is the sticker's.
+ const headPlans = head ? moveLines(c, head, { in: "pop-in", at: 0.03, hero: true }, "headline", 0.14) : [];
+ const headDone = headPlans.length ? stackLanded(headPlans) : 0.8;
+ c.ev("halftone", "fade", 0, 1.2, "glide");
+ c.ev("product", "hero", headDone - 0.15, 0.85, "settle");
+ c.ev("squiggle", "draw", headDone + 0.2 * k, 0.55, "draw");
+ c.ev("sticker", "pop", headDone + 0.45 * k, 0.65, "land");
+ const badgePlan = badgeSet ? c.move(badgeSet, { in: "pop-in", at: headDone + 0.55 * k }) : null;
+ const signPlan = signIn(c, sign, "brand", 0.2);
+ const sitePlan = site ? c.move(site, { in: "fade-rise", at: 0.35, rate: 26 }) : null;
+ const wiggleAt = Math.min(c.last - 1.6, (badgePlan?.settled ?? headDone + 0.8) + 0.6);
+ c.ev("wiggle", "move", wiggleAt, 0.8, "linear");
- const k = spread(c, 1.7, 2.4);
- const dropAt = 0.3 * k;
- const bandAt = 1.15 * k;
- const events = [
- ev("rays", "fade", 0, 0.6, "enter"),
- ev("halo", "enter", 0.15 * k, 0.7, "enter"),
- ev("drop", "pop", dropAt, 0.65, "pop"),
- ev("spin", "enter", dropAt, 0.7, "settle"),
- ev("shadow", "fade", dropAt + 0.25, 0.5, "enter"),
- ...(badge ? [ev("badge", "pop", 0.85 * k, 0.55, "pop")] : []),
- ...(head ? [ev("band", "enter", bandAt, 0.6, "snap"), ...head.lines.map((_, i) => ev(`head.${i}`, "enter", bandAt + 0.12 + i * 0.09, 0.55, "glide", { group: "head", unit: "elements" }))] : []),
- ];
- const holdFrom = dropAt + 0.7;
- // The rays turn the whole clip long and stop on the last frame's angle.
- const turn = (t: number) => -0.2 + (Math.min(t, c.last) / Math.max(1, c.last)) * 0.2;
+ const rayCx = img ? img.x + img.w / 2 : design.w / 2;
+ const rayCy = img ? img.y + img.h * 0.45 : design.h / 2;
+ const R = Math.hypot(design.w, design.h);
+ // Rays in a blush tint of the brand (never grey); the extruded side a deep tone of the words' own ink.
+ const rayFill = c.dark ? toneOf(pal, 0.14) : mixOk(pal.paper, pal.brand[0], 0.16);
+ const side3d = withLightness(pal.ink, Math.min(0.32, toLab(pal.ink).L * 0.62));
+ const stickerFill = pal.accent;
+ const stickerInk = ensureContrast(withLightness(pal.ink, 0.28), stickerFill, 4.5);
return {
- events,
- overflow: [...(head?.overflow ? ["headline"] : []), ...(badge?.overflow ? ["badge"] : []), ...(name?.overflow ? ["brand"] : [])],
- signature: dropAt + 0.25,
- frame(t, P, Lp) {
- const r = P("rays");
- const under: DisplayNode[] = [{ type: "path", d: raysPath(centre[0], centre[1], reach, turn(t)), fill: rayColour, ...(r < 1 && { opacity: r }) }];
- const nodes: DisplayNode[] = [];
- const h = P("halo");
- if (h > 0) {
- const hr = R * (0.6 + 0.4 * h);
- nodes.push({ type: "ellipse", cx: centre[0], cy: centre[1], rx: hr, ry: hr, fill: discColour, ...(h < 1 && { opacity: h }) });
+ overflow: [...(head?.overflow ? ["headline"] : []), ...(badgeSet?.overflow ? ["badge"] : []), ...(sign?.overflow ? ["brand"] : []), ...(site?.overflow ? ["website"] : []), ...row.overflow],
+ signature: headDone + 0.6,
+ camera: (t) => ({ x: 0, y: 14 * (1 - Math.min(1, t / c.last)) ** 2 }),
+ draw(t, kit) {
+ // The rays turn a steady 8° a second.
+ const turn = t * ((8 * Math.PI) / 180);
+ const field: DisplayNode[] = c.dark ? [{ type: "rect", x: 0, y: 0, w: design.w, h: design.h, fill: { kind: "radial", cx: rayCx, cy: rayCy, r0: 0, r1: R * 0.7, stops: [{ at: 0, color: mixOk(pal.ground, pal.accent, 0.12) }, { at: 1, color: mixOk(pal.ground, "#000000", 0.18) }] } }] : litField(c, t, { from: "tl" });
+ const atmosphere: DisplayNode[] = [group([{ type: "path", d: rays(rayCx, rayCy, R, 18, turn), fill: rayFill }], { opacity: 0.6 })];
+ const texture: DisplayNode[] = [];
+ const hp = kit.P("halftone");
+ if (hp > 0) texture.push(group([halftone({ box: { x: design.w * 0.2, y: design.h * 0.4, w: design.w * 0.8, h: design.h * 0.6 }, spacing: S * 0.026, angle: 45, origin: [design.w, design.h], reach: S * 0.75, color: pal.brand[0], alpha: 0.18, key: `sb|${design.w}x${design.h}|${pal.brand[0]}` })], { opacity: hp }));
+ const hero: DisplayNode[] = [];
+ if (head) {
+ head.sets.forEach((s, i) => {
+ const words = kit.type(headPlans[i], { fill: pal.ink });
+ if (t >= headPlans[i].settled) {
+ const face = words.find((n) => n.type === "text");
+ if (face && face.type === "text") hero.push(extrude({ face, color: side3d, depth: 12, step: Math.max(1, s.size * 0.01), angle: 45, key: `sb|${s.text}|${s.size}`, bounds: capBand(s) }));
+ }
+ hero.push(...words);
+ });
}
- // While it holds: a slow sway and float, still again on the last frame.
- const fl = holdFloat(t, holdFrom, c.last, S * 0.014, 0.045);
- if (img && hero) {
- const sh = P("shadow");
- if (sh > 0 && hero.src === "product") nodes.push(contactShadow(centre[0], img.y + img.h, img.w * 0.8, discColour, 0.4, sh));
- const d = P("drop");
- const lin = Lp("drop");
- if (lin > 0) {
- // Squash on landing: wide and short as it hits, springing back to its shape.
- const over = d - 1;
- const sx = 1 + over * 0.9;
- const sy = 1 - over * 0.9;
- const foot = img.y + img.h;
- const m = multiply(translate(0, -(1 - Math.min(1, d)) * S * 0.45 + fl.dy), multiply(about(centre[0], foot, sx, fl.roll, sy), about(centre[0], img.y + img.h / 2, 0.7 + 0.3 * Math.min(1, d), (1 - P("spin")) * -0.35)));
- const pic: DisplayNode = hero.src === "logo" ? logoNode(c, img, pal.ink) : { type: "image", src: hero.src, x: img.x, y: img.y, w: img.w, h: img.h };
- nodes.push(group([pic], { transform: m, ...(lin < 0.15 && { opacity: lin / 0.15 }) }));
- }
- } else if (nameB) {
- const d = P("drop");
- if (Lp("drop") > 0) nodes.push(group([lineRuns(nameB)], { transform: multiply(translate(0, fl.dy), about(centre[0], centre[1], 0.6 + 0.4 * d, (1 - P("spin")) * -0.5 + fl.roll)) }));
+ const subject: DisplayNode[] = [];
+ const pl = kit.L("product");
+ if (img && pl > 0) {
+ const p = kit.P("product");
+ // It slides in from the right with a small turn that settles, fully there from its first frame.
+ const dx = (1 - p) * S * 0.3;
+ const turnIn = rotation((1 - p) * 4, img.x + img.w / 2, img.y + img.h);
+ const pic: DisplayNode = prod ? { type: "image", src: "product", ...img } : logoNode(c, img, pal.ink);
+ // A cut-out sticker: a paper keyline round the product and its shadow on the ground.
+ const kw = Math.max(5, S * 0.007);
+ const kb = { x: img.x - kw * 2, y: img.y - kw * 2, w: img.w + kw * 4, h: img.h + kw * 4 };
+ // The keyline: the cut-out stamped round itself in a ring, filled with paper (drawn once and reused).
+ const ring = Array.from({ length: 12 }, (_, i): DisplayNode => ({ type: "image", src: "product", decor: true, x: img.x + Math.cos((i * Math.PI) / 6) * kw, y: img.y + Math.sin((i * Math.PI) / 6) * kw, w: img.w, h: img.h }));
+ const cut: DisplayNode[] = prod ? [group([...ring, group([{ type: "rect", ...kb, fill: pal.paper }], { blend: "source-atop" })], { isolate: kb, cache: { key: `sb-key|${img.w.toFixed(0)}x${img.h.toFixed(0)}|${pal.paper}`, bounds: kb } }), pic] : [pic];
+ subject.push(floorShadow({ cx: img.x + img.w / 2, y: img.y + img.h, width: img.w * 0.9, ground: pal.ground, strength: 0.5 * Math.min(1, pl * 2), key: `sb|${img.w.toFixed(0)}` }), group(cut, { transform: [turnIn[0], turnIn[1], turnIn[2], turnIn[3], turnIn[4] + dx, turnIn[5]] }));
}
- if (badgeB) {
- const b = P("badge");
- if (Lp("badge") > 0) nodes.push(group([{ type: "path", d: starPath(spot.cx, spot.cy, bR, bR * 0.84, 16), fill: badgeFill }, lineRuns(badgeB)], { transform: about(spot.cx, spot.cy, Math.max(0, b), 0.14 * b - 0.4 * (1 - b)) }));
+ const overlay: DisplayNode[] = [];
+ const sq = kit.P("squiggle");
+ if (sq > 0 && head) {
+ const ls = head.sets[head.sets.length - 1];
+ const last = ls.lines[0];
+ // From the line's first letter to its last, 0.12 em clear of the extruded side's lowest point; one sparkle at its start.
+ const sy = last.baseline + ls.size * 0.12 * 2 + ls.size * 0.06;
+ // It runs to the headline's right edge (one device: no sparkle).
+ overlay.push(squiggle({ x: last.ink.x, y: sy, w: headB.x + headB.w - last.ink.x, amp: ls.size * 0.06, seed: c.seed, color: pal.accent, width: Math.max(3, ls.size * 0.035), p: sq }));
}
- if (headB) {
- const band = P("band");
- const lin = Lp("band");
- if (lin > 0) {
- // The band runs off both edges, sliding in from the left; the words rise on it.
- const over = S * 0.2;
- const children: DisplayNode[] = [{ type: "rect", x: -over - (1 - band) * (design.w + over), y: bandY, w: design.w + 2 * over, h: bandH, fill: bandFill }, ...risingLines(headB, (i) => P(`head.${i}`))];
- nodes.push(group(children, { transform: about(design.w / 2, bandY + bandH / 2, 1, TILT) }));
- }
+ const sl = kit.L("sticker");
+ if (sl > 0) {
+ const sp = kit.P("sticker");
+ const disc: DisplayNode = { type: "path", d: starPath(spot.cx, spot.cy, spot.r, spot.r * 0.86, 14), fill: stickerFill };
+ const content: DisplayNode[] = badgePlan ? kit.type(badgePlan, { fill: stickerInk }) : [];
+ // A wiggle in the hold (±4°, back to true).
+ const wl = kit.L("wiggle");
+ const wig = wl > 0 && wl < 1 ? 4 * Math.sin(wl * Math.PI * 3) * (1 - wl) : 0;
+ const sticker = group([group(keyline([disc], Math.max(4, S * 0.007))), disc, ...content], { transform: rotation(-8 + (1 - sp) * 25 + wig, spot.cx, spot.cy) });
+ overlay.push(group([sticker], { transform: [sp, 0, 0, sp, spot.cx - sp * spot.cx, spot.cy - sp * spot.cy] }));
}
- return { under, nodes };
+ const meta = [...signNodes(c, kit, sign, signPlan, "brand", safe.x, safe.y, pal.ink), ...(sitePlan ? kit.type(sitePlan, { fill: metaInk(pal), caret: pal.accent }) : []), ...row.draw(kit, metaInk(pal), pal.ink)];
+ return [
+ { role: "ground", nodes: field },
+ { role: "atmosphere", nodes: atmosphere },
+ { role: "texture", nodes: texture },
+ { role: "hero", nodes: hero },
+ { role: "subject", nodes: subject },
+ { role: "overlay", nodes: overlay },
+ { role: "meta", nodes: meta },
+ ];
},
};
},
diff --git a/src/lib/motion/scenes/marketing/stat-dashboard.ts b/src/lib/motion/scenes/marketing/stat-dashboard.ts
index e39a7523..627ef89a 100644
--- a/src/lib/motion/scenes/marketing/stat-dashboard.ts
+++ b/src/lib/motion/scenes/marketing/stat-dashboard.ts
@@ -1,164 +1,208 @@
/**
- * Dashboard Zoom: a designed dashboard panel rises, its grid fades up, the bars grow one by one, a trend line draws over
- * them and its last point pops, while the key number rolls up to the value the person typed (figure by figure, in
- * tabular cells, with their own separators) and the camera pushes in from a slight angle to rest square on the panel.
- * The panel carries the brand (its logo, else its name) in its header, and the number is set in lining figures (a face
- * whose default figures are old-style hands the number to the body face). The beats spread over the clip's length, and
- * the push runs the whole clip long. The last frame shows the typed number exactly.
+ * Dashboard Zoom: the key number is the hero, set huge above the evidence in the product face with tabular figures
+ * (the typed separators at their own width), rolling up column by column to exactly what was typed. Under it the label
+ * cuts up, and a glass panel rises from its foot with the chart: gridlines, a dashed comparison line at 25 %, and the
+ * main line in the brand's colour drawing across after the number lands, its area filling in and its last point
+ * pulsing once. A lit field of the brand's hue with a light from the top left sits behind a fine grid. The brand, the
+ * address, a corner note and an index sit on the corners. Through the hold the type plane pushes in.
*/
-import { about, group, multiply, translate, withAlpha, mixHex, type DisplayNode } from "../../display";
-import { rngRange } from "../../random";
-import { lineRuns } from "../end-card/shared";
-import { centreFigures, counterLayout, counterNode, ev, figureFamily, logoNode, marketingScene, MIN_BODY, readable, setText, shadowOf, spread, textBlock } from "./kit";
+import { about, group, type DisplayNode } from "../../display";
+import { contrastOf, fieldStops, mixOk, toLab, withLightness } from "../../color";
+import { rgba } from "../../fx/background";
+import { twoShadow } from "../../fx/depth";
+import { asDecor, bands, brandSign, capBand, footRow, litField, metaInk, posterScene, signIn, signNodes, toneOf, topSite } from "./poster";
-/** An open smooth curve through points (Catmull–Rom as cubic Béziers), and its length. */
-export function smoothOpenPath(pts: [number, number][]): { d: string; length: number } {
- const n = pts.length;
- const parts = [`M${pts[0][0].toFixed(2)} ${pts[0][1].toFixed(2)}`];
+/** A smooth rising line through seeded points (a sparkline), as path data, and its rough length. */
+function sparkline(x: number, y: number, w: number, h: number, seed: number, lift = 1): { d: string; area: string; length: number; end: [number, number]; pts: [number, number][] } {
+ const n = 9;
+ const pts: [number, number][] = [];
+ for (let i = 0; i < n; i++) {
+ const u = i / (n - 1);
+ // Mostly rising (a quarter of the noise of before, so it never dips against an "up" label).
+ const noise = Math.sin(i * 1.7 + seed) * 0.07 + Math.sin(i * 0.9 + seed * 0.3) * 0.05;
+ pts.push([x + u * w, y + h - (0.12 + 0.75 * lift * u ** 1.3 + noise * (1 - u * 0.6)) * h * 0.85]);
+ }
+ let d = `M${pts[0][0].toFixed(1)} ${pts[0][1].toFixed(1)}`;
let length = 0;
- for (let i = 0; i < n - 1; i++) {
- const p0 = pts[Math.max(0, i - 1)];
- const p1 = pts[i];
- const p2 = pts[i + 1];
- const p3 = pts[Math.min(n - 1, i + 2)];
- const c1 = [p1[0] + (p2[0] - p0[0]) / 6, p1[1] + (p2[1] - p0[1]) / 6];
- const c2 = [p2[0] - (p3[0] - p1[0]) / 6, p2[1] - (p3[1] - p1[1]) / 6];
- parts.push(`C${c1[0].toFixed(2)} ${c1[1].toFixed(2)} ${c2[0].toFixed(2)} ${c2[1].toFixed(2)} ${p2[0].toFixed(2)} ${p2[1].toFixed(2)}`);
- let px = p1[0];
- let py = p1[1];
- for (let k = 1; k <= 10; k++) {
- const t = k / 10;
- const u = 1 - t;
- const x = u * u * u * p1[0] + 3 * u * u * t * c1[0] + 3 * u * t * t * c2[0] + t * t * t * p2[0];
- const y = u * u * u * p1[1] + 3 * u * u * t * c1[1] + 3 * u * t * t * c2[1] + t * t * t * p2[1];
- length += Math.hypot(x - px, y - py);
- px = x;
- py = y;
- }
+ for (let i = 1; i < n; i++) {
+ const [x0, y0] = pts[i - 1];
+ const [x1, y1] = pts[i];
+ const mx = (x0 + x1) / 2;
+ d += `C${mx.toFixed(1)} ${y0.toFixed(1)} ${mx.toFixed(1)} ${y1.toFixed(1)} ${x1.toFixed(1)} ${y1.toFixed(1)}`;
+ length += Math.hypot(x1 - x0, y1 - y0) * 1.08;
}
- return { d: parts.join(""), length };
+ const area = `${d}L${(x + w).toFixed(1)} ${(y + h).toFixed(1)}L${x.toFixed(1)} ${(y + h).toFixed(1)}Z`;
+ return { d, area, length, end: pts[n - 1], pts };
}
-const BARS = 12;
-
-export default marketingScene({
+export default posterScene({
id: "marketing/stat-dashboard",
name: "Dashboard Zoom",
+ pairing: "T7",
look: "dark",
build(c) {
- const { S, safe, palette: pal, design, recipe } = c;
- const panel = c.wide ? { x: safe.x + safe.w * 0.05, y: safe.y, w: safe.w * 0.9, h: safe.h } : c.tall ? { x: safe.x, y: safe.y + safe.h * 0.07, w: safe.w, h: safe.h * 0.8 } : { x: safe.x, y: safe.y, w: safe.w, h: safe.h };
- const P0 = S * 0.055;
- const inner = panel.w - 2 * P0;
- const ink = pal.surfaceInk;
- const quiet = readable(pal.surface, mixHex(ink, pal.surface, 0.28), ink);
- // The header: the logo (at most this tall), else the name.
- const logo = c.input.logo;
- const logoH = S * 0.07;
- const logoBox = logo ? (() => {
- const s = Math.min((inner * 0.6) / logo.w, logoH / logo.h);
- return { x: panel.x + P0, y: panel.y + P0, w: logo.w * s, h: logo.h * s };
- })() : null;
- const brand = !logo ? setText(c, recipe.brand.name, { family: "body", weight: 700, width: inner * 0.7, maxLines: 1, max: S * 0.038, min: S * MIN_BODY }) : null;
+ const { S, safe, pal, design } = c;
+ const side = c.wide;
+ const signH = S * (c.cover ? 0.058 : 0.046);
+ const sign = brandSign(c, { maxW: S * 0.36, h: signH, x: safe.x, y: safe.y, min: S * (c.cover ? 0.05 : 0.03) });
+ const metaSize = S * (c.cover ? 0.024 : 0.02);
+ const site = topSite(c, sign, metaSize);
+ const b = bands(c, { topRow: sign?.h ?? metaSize, gap: S * 0.06 });
+ const foot = metaSize * 1.1 + S * 0.05;
const statText = c.field("stat", "0");
- const stat = centreFigures(counterLayout("stat", statText, figureFamily(c, 800), 800, inner, S * (c.wide ? 0.15 : 0.16), S * 0.07, c.measure), c.measure);
- const label = setText(c, c.field("label"), { family: "body", weight: 500, width: inner, maxLines: 2, max: S * 0.042, min: S * MIN_BODY, lineHeight: 1.25 });
- const headTop = panel.y + P0;
- const statTop = headTop + (logoBox ? logoBox.h + S * 0.045 : brand ? brand.size * 1.2 + S * 0.045 : 0);
- const labelTop = statTop + stat.size * 1.12 + S * 0.012;
- const chartTop = labelTop + (label ? label.height : 0) + S * 0.06;
- const chartBottom = panel.y + panel.h - P0;
- const chartH = Math.max(S * 0.12, chartBottom - chartTop);
- const numberInk = readable(pal.surface, pal.accent, ink);
- const brandB = brand ? textBlock("brand", brand, { y: headTop, color: quiet, left: panel.x + P0, width: inner * 0.7 }) : null;
- const labelB = label ? textBlock("label", label, { y: labelTop, color: quiet, left: panel.x + P0, width: inner }) : null;
+ // The number: the hero, in the product face with fixed-width figures, filling the width (the left column on a wide frame).
+ const numW = side ? safe.w * 0.52 : safe.w;
+ // Proportional figures at rest (a fixed-width "1" leaves holes in a settled number).
+ const stat0 = c.set("stat", statText, { role: "hero", weight: 800, x: safe.x, y: b.top, width: numW, maxLines: 1, max: side ? design.h * 0.3 : S * 0.36, min: S * 0.08, preset: "odometer", tracking: -0.01, leading: 0.95 });
+ const lift = stat0 ? stat0.lines[0].y + stat0.cap.top - b.top : 0;
+ const labelSize = S * (c.cover ? 0.05 : 0.042);
+ const label0 = c.set("label", c.field("label"), { role: "body", weight: 500, x: safe.x, y: 0, width: numW, maxLines: 2, max: labelSize, min: S * 0.03, leading: 1.2 });
+ const labelH = label0 ? capBand(label0).h : 0;
+ const statH = stat0 ? capBand(stat0).h : 0;
+ // Wide: the number and label centred in the left column, the panel in the right. Tall: number, label, then the panel to the foot.
+ const blockH = statH + (label0 ? S * 0.05 + labelH : 0);
+ const statTop = side ? b.top + Math.max(0, (b.bottom - foot - b.top - blockH) * 0.5) : b.top;
+ const stat = stat0 ? c.set("stat", statText, { role: "hero", weight: 800, x: safe.x, y: statTop - lift, width: numW, maxLines: 1, max: stat0.size, min: stat0.size, preset: "odometer", tracking: -0.01, leading: 0.95 }) : null;
+ const statBand = stat ? capBand(stat) : { x: safe.x, y: statTop, w: 0, h: 0 };
+ const label = label0 ? c.set("label", c.field("label"), { role: "body", weight: 500, x: safe.x, y: statBand.y + statBand.h + S * 0.05 - (label0.lines[0].y + label0.cap.top - label0.lines[0].y), width: numW, maxLines: 2, max: label0.size, min: label0.size, leading: 1.2 }) : null;
+ const below = label ? label.lines[label.lines.length - 1].baseline + label.size * 0.3 : statBand.y + statBand.h;
+ const panel = side ? { x: safe.x + safe.w * 0.58, y: b.top, w: safe.w * 0.42, h: b.bottom - foot - b.top } : { x: safe.x, y: below + S * 0.06, w: safe.w, h: Math.max(S * 0.25, safe.y + safe.h - foot - S * 0.02 - below - S * 0.06) };
+ const pad = S * 0.05;
+ const chart = { x: panel.x + pad * 1.3, y: panel.y + pad * 1.2, w: panel.w - pad * 2.3, h: panel.h - pad * 2.4 };
+ const spark = sparkline(chart.x, chart.y, chart.w, chart.h, c.seed);
+ const shadowSeries = sparkline(chart.x, chart.y, chart.w, chart.h, c.seed + 3, 0.6);
- // The data: a seeded climb, the last bar the highest.
- const values = Array.from({ length: BARS }, (_, i) => Math.min(1, Math.max(0.14, 0.24 + 0.62 * (i / (BARS - 1)) ** 1.25 + rngRange(-0.09, 0.09, recipe.seed, "bar", i))));
- values[BARS - 1] = 1;
- const slot = inner / BARS;
- const barW = slot * 0.56;
- const bars = values.map((v, i) => ({ x: panel.x + P0 + i * slot + (slot - barW) / 2, h: v * chartH * 0.86 }));
- const pts = bars.map((b, i) => [b.x + barW / 2, chartBottom - b.h - chartH * 0.08 - rngRange(0, 0.05, recipe.seed, "pt", i) * chartH] as [number, number]);
- const line = smoothOpenPath(pts);
- const area = `${line.d}L${pts[BARS - 1][0]} ${chartBottom}L${pts[0][0]} ${chartBottom}Z`;
- const barColour = mixHex(pal.surface, pal.mark2, pal.look === "light" ? 0.32 : 0.45);
- const grid = mixHex(pal.surface, ink, 0.1);
+ const k = c.spread(3.4, 1.5);
+ const statPlan = stat ? c.move(stat, { in: "odometer", at: 0.03, hero: true, loop: "light-sweep", loopAt: 2.6, loopEvery: 1.8 }) : null;
+ const landed = statPlan?.settled ?? 1.4;
+ // The panel rises at once and the line draws while the number is still rolling, so number and evidence land
+ // together; the change pops in as a tag on the line's last point.
+ c.ev("panel", "enter", 0.1, 0.6, "glide");
+ c.ev("grid", "draw", 0.25, 0.6, "draw");
+ const sparkAt = Math.max(0.6, landed - 0.7);
+ c.ev("spark", "draw", sparkAt, 0.9, "draw");
+ c.ev("ghost", "fade", sparkAt - 0.1, 0.7, "glide");
+ c.ev("area", "fade", sparkAt + 0.4, 0.7, "glide");
+ c.ev("dot", "pop", sparkAt + 0.9, 0.5, "pop");
+ c.ev("change", "pop", sparkAt + 1.02, 0.4, "pop");
+ const labelPlan = label ? c.move(label, { in: "cut-rise", at: Math.min(landed - 0.3, 1.0 * k) }) : null;
+ const signPlan = signIn(c, sign, "brand", 0.2);
+ const sitePlan = site ? c.move(site, { in: "fade-rise", at: 0.35, rate: 26 }) : null;
+ const row = footRow(c, landed + 0.3);
- const k = spread(c, 1.95);
- const events = [
- ev("panel", "enter", 0.08, 0.65, "enter"),
- ev("grid", "fade", 0.35 * k, 0.5, "enter"),
- ...bars.map((_, i) => ev(`bar.${i}`, "enter", 0.5 * k + i * 0.08, 0.5, "enter", { group: "bars", unit: "elements" })),
- ev("line", "draw", 0.75 * k, 1.2, "draw"),
- ev("area", "fade", 0.75 * k + 0.9, 0.6, "enter"),
- ev("dot", "pop", 0.75 * k + 1.05, 0.4, "pop"),
- ev("count", "move", 0.45 * k, Math.min(2.2, 1.5 * k), "linear"),
- ev("brand", "fade", 0.3, 0.4, "enter"),
- ...(label ? [ev("label", "enter", 0.62 * k, 0.45, "glide")] : []),
- ev("push", "camera", 0, c.last, "drift"),
- ];
- const shadow = shadowOf(pal.ground, pal.look === "light" ? 0.14 : 0.45);
- // Pulses 1.6 s apart from when the point lands, the last one done before the last frame.
- const dotEnd = 0.75 * k + 1.45;
- const pulse = (t: number): number => {
- if (t <= dotEnd) return 0;
- const n = Math.floor((t - dotEnd) / 1.6);
- return dotEnd + (n + 1) * 1.6 > c.last ? 0 : ((t - dotEnd) % 1.6) / 1.6;
- };
+ // Glass: a lighter tone of the ground at 78 %, a hairline of light along its top edge.
+ const surface = c.dark ? mixOk(fieldStops(pal).dark, mixOk(pal.paper, pal.brand[0], 0.5), 0.14) : mixOk(pal.ground, pal.paper, 0.85);
+ const edge = c.dark ? mixOk(pal.ground, pal.paper, 0.26) : mixOk(pal.paper, pal.brand[0], 0.25);
+ // The line: the brand's own colour, lifted until it reads on the panel.
+ const b0 = pal.brand[0];
+ const lineColor = contrastOf(b0, surface) >= 3 ? b0 : withLightness(b0, toLab(surface).L < 0.5 ? 0.68 : 0.42);
+ const stops = fieldStops(pal);
+ const ticks = 4;
+ // The change the label names ("up 38%"): its figure, as typed, in a tag pinned to the line's last point (a copy of
+ // the label's words, so it is decorative), with a drawn arrow for the direction.
+ const pct = /(\p{Nd}+(?:[.,]\p{Nd}+)?\s?%)/u.exec(c.field("label"))?.[1] ?? "";
+ const tagSize = S * (c.cover ? 0.034 : 0.03);
+ const tag = pct ? c.set("label", pct, { role: "figures", weight: 700, x: 0, y: 0, width: S * 0.4, maxLines: 1, max: tagSize, min: tagSize }) : null;
+ const tagW = tag ? tag.ink.w + tagSize * 2.2 : 0;
+ const tagH = tagSize * 1.9;
+ const tagX = Math.min(chart.x + chart.w - tagW, spark.end[0] - tagW / 2);
+ const tagY = Math.max(panel.y + S * 0.02, spark.end[1] - tagH - S * 0.045);
+ const tagSet = tag ? c.set("label", pct, { role: "figures", weight: 700, x: tagX + tagSize * 1.5, y: tagY + (tagH - tagSize) / 2 - tagSize * 0.05, width: S * 0.4, maxLines: 1, max: tagSize, min: tagSize }) : null;
+ const labelInk = c.dark ? mixOk(pal.paper, pal.ground, 0.2) : metaInk(pal);
return {
- events,
- overflow: [...(stat.overflow ? ["stat"] : []), ...(label?.overflow ? ["label"] : []), ...(brand?.overflow ? ["brand"] : [])],
- signature: 0.75 * k + 0.7,
- camera: () => ({ zoom: 1, x: 0, y: 0 }),
- frame(t, P, Lp) {
- // The push: from a little farther out and turned, square on the panel at rest.
- const push = P("push");
- const cam = multiply(translate(0, (1 - push) * S * 0.05), about(design.w / 2, panel.y + panel.h * 0.4, 0.88 + 0.12 * push, -0.035 * (1 - push)));
- const pe = P("panel");
- const children: DisplayNode[] = [
- { type: "rect", x: panel.x, y: panel.y + S * 0.02, w: panel.w, h: panel.h, r: S * 0.04, fill: shadow },
- { type: "rect", x: panel.x, y: panel.y, w: panel.w, h: panel.h, r: S * 0.04, fill: pal.surface },
- ];
- // Window dots, top right.
- for (let i = 0; i < 3; i++) children.push({ type: "ellipse", cx: panel.x + panel.w - P0 - i * S * 0.03, cy: headTop + S * 0.017, rx: S * 0.008, ry: S * 0.008, fill: grid });
- const g = P("grid");
- if (g > 0) for (let i = 0; i < 4; i++) children.push({ type: "rect", x: panel.x + P0, y: chartBottom - (i / 3) * chartH * 0.92, w: inner, h: Math.max(1.5, S * 0.002), fill: grid, opacity: g });
- bars.forEach((b, i) => {
- const q = P(`bar.${i}`);
- if (q <= 0) return;
- const h = b.h * q;
- children.push({ type: "rect", x: b.x, y: chartBottom - h, w: barW, h, r: Math.min(barW * 0.22, h / 2), fill: i === BARS - 1 ? pal.highlight.fill : barColour });
- });
- const a = P("area");
- if (a > 0) children.push({ type: "path", d: area, fill: { kind: "linear", x0: 0, y0: chartTop, x1: 0, y1: chartBottom, stops: [{ at: 0, color: withAlpha(pal.mark, 0.32) }, { at: 1, color: withAlpha(pal.mark, 0) }] }, opacity: a });
- const l = P("line");
- if (l > 0) children.push({ type: "path", d: line.d, stroke: { paint: pal.mark, width: S * 0.0065, trim: l, length: line.length, cap: "round", join: "round" } });
- const dot = P("dot");
- if (Lp("dot") > 0) {
- const end = pts[BARS - 1];
- const r = S * 0.014 * Math.max(0, dot);
- children.push({ type: "ellipse", cx: end[0], cy: end[1], rx: r * 1.9, ry: r * 1.9, fill: withAlpha(pal.mark, 0.25) }, { type: "ellipse", cx: end[0], cy: end[1], rx: r, ry: r, fill: pal.mark });
- // The live point keeps a slow pulse while the piece holds (none on the last frame).
- const ph = pulse(t);
- if (ph > 0 && ph < 1) children.push({ type: "ellipse", cx: end[0], cy: end[1], rx: S * 0.014 * (1.9 + 3.2 * ph), ry: S * 0.014 * (1.9 + 3.2 * ph), stroke: { paint: pal.mark, width: Math.max(1.5, S * 0.003) }, opacity: 0.55 * (1 - ph) });
+ overflow: [...(stat?.overflow ? ["stat"] : []), ...(label?.overflow ? ["label"] : []), ...(sign?.overflow ? ["brand"] : []), ...(site?.overflow ? ["website"] : []), ...row.overflow],
+ signature: landed + 0.2,
+ camera: (t) => ({ x: 0, y: 24 * (1 - Math.min(1, t / c.last)) ** 2 }),
+ draw(t, kit) {
+ const field = litField(c, t, { from: "tl", stops, light: withLightness(pal.brand[0], 0.6), lightAlpha: c.dark ? 0.3 : 0.2 });
+ // A fine grid in a tone of the ground.
+ const cell = S * 0.09;
+ let gd = "";
+ for (let x = (design.w % cell) / 2; x <= design.w; x += cell) gd += `M${x.toFixed(1)} 0V${design.h}`;
+ for (let y = (design.h % cell) / 2; y <= design.h; y += cell) gd += `M0 ${y.toFixed(1)}H${design.w}`;
+ const atmosphere: DisplayNode[] = [group([{ type: "path", d: gd, stroke: { paint: toneOf(pal, 0.14), width: 1 } }], { opacity: 0.16, cache: { key: `grid|${design.w}x${design.h}|${pal.ground}`, bounds: { x: 0, y: 0, ...design } } })];
+ const lin = kit.L("panel");
+ const p = kit.P("panel");
+ const plate: DisplayNode = { type: "rect", ...panel, r: S * 0.035, fill: rgba(surface, 0.78), stroke: { paint: edge, width: Math.max(1, S * 0.0015) } };
+ const sheen: DisplayNode = { type: "rect", ...panel, r: S * 0.035, fill: { kind: "linear", x0: 0, y0: panel.y, x1: 0, y1: panel.y + panel.h * 0.5, stops: [{ at: 0, color: rgba("#ffffff", c.dark ? 0.08 : 0.4) }, { at: 1, color: rgba("#ffffff", 0) }] } };
+ // The glass's own hairline edge is its rim (no separate top line).
+ const inside: DisplayNode[] = [];
+ const gp = kit.P("grid");
+ if (gp > 0) {
+ let g = "";
+ for (let i = 0; i <= ticks; i++) {
+ const y = chart.y + (chart.h * i) / ticks;
+ g += `M${chart.x.toFixed(1)} ${y.toFixed(1)}H${(chart.x + chart.w * gp).toFixed(1)}`;
+ }
+ inside.push({ type: "path", d: g, stroke: { paint: rgba(pal.ink, 0.1), width: Math.max(1, S * 0.0012) } });
+ }
+ // The comparison: dashed, at 25 %.
+ const gh = kit.P("ghost");
+ if (gh > 0) {
+ let dd = "";
+ const n = 28;
+ // A dashed line drawn as short pieces along the second series' points.
+ const ends = shadowSeries.pts;
+ for (let i = 0; i < n; i += 2) {
+ const u0 = i / n;
+ const u1 = (i + 1) / n;
+ const at = (u: number) => {
+ const f = u * (ends.length - 1);
+ const j = Math.min(ends.length - 2, Math.floor(f));
+ const r = f - j;
+ return [ends[j][0] + (ends[j + 1][0] - ends[j][0]) * r, ends[j][1] + (ends[j + 1][1] - ends[j][1]) * r];
+ };
+ const [ax, ay] = at(u0);
+ const [bx, by] = at(u1);
+ dd += `M${ax.toFixed(1)} ${ay.toFixed(1)}L${bx.toFixed(1)} ${by.toFixed(1)}`;
+ }
+ inside.push({ type: "path", d: dd, stroke: { paint: rgba(pal.ink, 0.25 * gh), width: Math.max(1.5, S * 0.003), cap: "round" } });
}
- if (logoBox) {
- const b = P("brand");
- if (b > 0) children.push(b < 1 ? group([logoNode(c, logoBox, quiet)], { opacity: b }) : logoNode(c, logoBox, quiet));
- } else if (brandB) {
- const b = P("brand");
- if (b > 0) children.push({ ...lineRuns(brandB), ...(b < 1 && { opacity: b }) });
+ const ar = kit.P("area");
+ if (ar > 0) inside.push(group([{ type: "path", d: spark.area, fill: { kind: "linear", x0: chart.x, y0: 0, x1: chart.x + chart.w, y1: 0, stops: [{ at: 0, color: rgba(lineColor, 0.05) }, { at: 0.8, color: rgba(lineColor, 0.2) }, { at: 0.93, color: rgba(lineColor, 0.16) }, { at: 1, color: rgba(lineColor, 0) }] } }], { opacity: ar }));
+ const sp = kit.P("spark");
+ if (sp > 0) inside.push({ type: "path", d: spark.d, stroke: { paint: lineColor, width: Math.max(3, S * 0.007), trim: sp, length: spark.length, cap: "round", join: "round" } });
+ if (sp >= 1) {
+ const dl = kit.L("dot");
+ const ring = dl > 0 && dl < 1 ? [{ type: "ellipse" as const, cx: spark.end[0], cy: spark.end[1], rx: S * (0.015 + 0.05 * dl), ry: S * (0.015 + 0.05 * dl), stroke: { paint: rgba(lineColor, 0.6 * (1 - dl)), width: Math.max(1.5, S * 0.003) } }] : [];
+ inside.push(...ring, { type: "ellipse", cx: spark.end[0], cy: spark.end[1], rx: S * 0.03, ry: S * 0.03, fill: rgba(lineColor, 0.22) }, { type: "ellipse", cx: spark.end[0], cy: spark.end[1], rx: S * 0.013, ry: S * 0.013, fill: lineColor });
}
- if (Lp("count") > 0) children.push(counterNode(stat, panel.x + P0, statTop, numberInk, Lp("count")));
- if (labelB) {
- const q = P("label");
- if (q > 0) children.push(group([lineRuns(labelB)], { transform: translate(0, (1 - q) * S * 0.02), ...(q < 1 && { opacity: q }) }));
+ const ch = kit.L("change");
+ if (tagSet && ch > 0) {
+ const q = kit.P("change");
+ const ax = tagX + tagSize * 0.75;
+ const ay = tagY + tagH / 2;
+ const a = tagSize * 0.32;
+ const tagNodes: DisplayNode[] = [
+ { type: "rect", x: tagX, y: tagY, w: tagW, h: tagH, r: tagH / 2, fill: lineColor },
+ { type: "path", d: `M${(ax - a).toFixed(1)} ${(ay + a * 0.6).toFixed(1)}L${ax.toFixed(1)} ${(ay - a * 0.7).toFixed(1)}L${(ax + a).toFixed(1)} ${(ay + a * 0.6).toFixed(1)}Z`, fill: surface },
+ ...asDecor([{ type: "text", field: "label", runs: [{ text: pct, gap: "", font: tagSet.font, x: tagSet.lines[0].x, y: tagSet.lines[0].y, fill: surface }] }]),
+ ];
+ inside.push(group(tagNodes, { ...(q < 1 && { transform: about(tagX + tagW / 2, tagY + tagH, 0.85 + 0.15 * q) }), ...(ch < 0.5 && { opacity: ch / 0.5 }) }));
}
- const lin = Lp("panel");
- return { nodes: lin > 0 ? [group([group(children, { transform: translate(0, (1 - pe) * S * 0.08), ...(lin < 0.35 && { opacity: lin / 0.35 }) })], { transform: cam })] : [] };
+ const reveal = Math.min(1, lin * 1.25);
+ const subject: DisplayNode[] =
+ lin > 0
+ ? [
+ group([...twoShadow({ nodes: [plate], size: panel.h, ground: pal.ground, bounds: panel, key: `dz|${panel.w.toFixed(0)}x${panel.h.toFixed(0)}` }), plate, sheen, ...inside], {
+ transform: [1, 0, 0, 1, 0, (1 - p) * S * 0.04],
+ ...(reveal < 1 && { clip: { type: "rect", x: panel.x - S * 0.1, y: panel.y + panel.h * (1 - reveal) - S * 0.05, w: panel.w + S * 0.2, h: panel.h * reveal + S * 0.2 } }),
+ }),
+ ]
+ : [];
+ const hero: DisplayNode[] = [];
+ if (statPlan && stat) hero.push(...kit.type(statPlan, { fill: pal.ink, sweep: "#ffffff", sweepAlpha: 0.45 }));
+ if (labelPlan) hero.push(...kit.type(labelPlan, { fill: labelInk }));
+ const meta = [...signNodes(c, kit, sign, signPlan, "brand", safe.x, safe.y, pal.ink), ...(sitePlan ? kit.type(sitePlan, { fill: metaInk(pal), caret: lineColor }) : []), ...row.draw(kit, metaInk(pal), pal.ink)];
+ return [
+ { role: "ground", nodes: field },
+ { role: "atmosphere", nodes: atmosphere },
+ { role: "subject", nodes: subject, push: -0.025, z: 1 },
+ { role: "hero", nodes: hero },
+ { role: "meta", nodes: meta },
+ ];
},
};
},
diff --git a/src/lib/motion/scenes/marketing/stat-stack.ts b/src/lib/motion/scenes/marketing/stat-stack.ts
new file mode 100644
index 00000000..a274c3cd
--- /dev/null
+++ b/src/lib/motion/scenes/marketing/stat-stack.ts
@@ -0,0 +1,207 @@
+/**
+ * Stat Stack: three numbers as one poster. The first is the hero, its figures filling the width in a heavy condensed
+ * face; the other two sit side by side under a hairline at about half its size (on a wide frame, three equal columns).
+ * Every figure rolls up column by column (blank until its column starts, never a placeholder) to exactly what was
+ * typed; a trailing unit (%, ×) sits at 40 % of the figures' height, top-aligned to their cap height. Each label hangs
+ * under its figure, a small accent index sits over each, and a giant filled tonal copy of the first figures bleeds off
+ * the right edge behind it on a lit two-tone field. The brand, the address, a corner note and an index arrow sit on the
+ * corners; through the hold the type plane pushes in and a band of light crosses each number in turn.
+ */
+
+import { group, type DisplayNode } from "../../display";
+import { fieldStops, mixOk } from "../../color";
+import { highlighter, rule } from "../../fx/overlays";
+import { marked } from "./kit";
+import { fontOf } from "../../type/faces";
+import type { TypePlan } from "../../type/animate";
+import type { TypeSet } from "../../type/glyphs";
+import { bands, brandSign, capAt, capBand, footRow, litField, markColor, metaInk, posterScene, shadowed, signIn, signNodes, toneOf, withLeadGap, topSite } from "./poster";
+import { splitUnit } from "./big-number";
+
+interface Row {
+ i: number;
+ n: number;
+ figs: TypeSet;
+ unit: TypeSet | null;
+ label: TypeSet | null;
+ /** Its cap band (figures and unit). */
+ band: { x: number; y: number; w: number; h: number };
+}
+
+export default posterScene({
+ id: "marketing/stat-stack",
+ name: "Stat Stack",
+ pairing: "T2",
+ look: "dark",
+ build(c) {
+ const { S, safe, pal } = c;
+ const side = c.wide;
+ const signH = S * (c.cover ? 0.058 : 0.046);
+ const sign = brandSign(c, { maxW: S * 0.4, h: signH, x: safe.x, y: safe.y, min: S * (c.cover ? 0.05 : 0.03) });
+ const metaSize = S * (c.cover ? 0.024 : 0.02);
+ const site = topSite(c, sign, metaSize);
+ // Labels may star words for a highlighter (*an hour*); the stars are not shown.
+ const items = [1, 2, 3].map((n) => { const m = marked(c.field(`label${n}`)); return { n, stat: c.field(`stat${n}`), label: m.text, marks: m.marks }; }).filter((x) => x.stat);
+ const b = bands(c, { topRow: sign?.h ?? metaSize, gap: S * 0.07 });
+ const foot = metaSize * 1.1 + S * 0.05;
+ const bottom = b.bottom - foot;
+ const labelSize = S * (c.cover ? 0.032 : 0.03);
+ const idxSize = S * (c.cover ? 0.024 : 0.02);
+ const gutter = S * 0.06;
+
+ // Where each figure goes and how wide: hero full width then two halves (tall); three columns (wide).
+ const slots = items.map((_, i) => (side ? { x: safe.x + (i * (safe.w + gutter)) / 3, w: (safe.w - 2 * gutter) / 3 } : i === 0 ? { x: safe.x, w: safe.w * 0.74 } : { x: safe.x + ((i - 1) * (safe.w + gutter)) / 2, w: (safe.w - gutter) / 2 }));
+ const figOpts = (size: number, x: number, y: number) => ({ role: "figures" as const, x, y, width: safe.w * 2, maxLines: 1, max: size, min: size, tabular: true, preset: "odometer" as const, tracking: 0, leading: 0.9 });
+ // Each figure's width at 100 (figures plus its unit at 40 %), to size it to its slot.
+ const widthAt100 = (stat: string) => {
+ const [f, u] = splitUnit(stat);
+ const fs = c.set("probe", f, figOpts(100, 0, 0));
+ const us = u ? c.set("probe", u.trim(), { ...figOpts(35, 0, 0), tabular: false }) : null;
+ return { w: (fs?.ink.w ?? 100) + (us ? us.ink.w + 4 : 0), cap: fs ? fs.cap.bottom - fs.cap.top : 70 };
+ };
+ const probes = items.map((it) => widthAt100(it.stat));
+ // Sizes: the hero fills its slot (held to 42 % of the room's height); the others share one size, about half the hero's.
+ const labelRoom = labelSize * 3.6;
+ const heroRoom = side ? (bottom - b.top - labelRoom - idxSize * 2) : (bottom - b.top) * 0.7;
+ let sizes = items.map((_, i) => (100 * slots[i].w * 0.96) / probes[i].w);
+ if (side) {
+ const one = Math.min(...sizes, (100 * heroRoom) / Math.max(...probes.map((p) => p.cap)));
+ sizes = sizes.map(() => one);
+ } else {
+ sizes[0] = Math.min(sizes[0], (100 * heroRoom) / probes[0].cap, S * 0.75);
+ const rest = Math.min(...sizes.slice(1), sizes[0] * 0.42);
+ sizes = sizes.map((s, i) => (i ? rest : s));
+ }
+ // The hero row, then the pair under it (tall); one row of three (wide). Every row's index sits over its figures.
+ // Laid out once to measure, then shrunk until the block sits clear above the foot row, and centred in the room.
+ const layout = (scale: number, y0: number) => {
+ const rows: Row[] = [];
+ const tops: number[] = [];
+ // The hero gives up less than the pair under it when the block has to shrink (it stays the poster).
+ const sz = sizes.map((s, i) => s * (i === 0 && !side ? Math.sqrt(scale) : scale));
+ let y = y0 + idxSize * 2.1;
+ let bottomY = y0;
+ items.forEach((it, i) => {
+ const slot = slots[i];
+ if (!side && i === 1) y = bottomY + S * 0.09 + idxSize * 2.1;
+ const top = side ? y0 + idxSize * 2.1 : y;
+ tops.push(top);
+ const [f, u] = splitUnit(it.stat);
+ const figs = capAt(c, `stat${it.n}`, f, figOpts(sz[i], slot.x, top));
+ if (!figs) return;
+ const uSize = sz[i] * 0.35;
+ const u0 = u ? capAt(c, `stat${it.n}`, u.trimStart(), { ...figOpts(uSize, figs.ink.x + figs.ink.w + sz[i] * 0.03, top), tabular: false, preset: "stomp" }) : null;
+ const unit = u0 ? withLeadGap(u0, u.slice(0, u.length - u.trimStart().length)) : null;
+ const fb = capBand(figs);
+ const band = { x: fb.x, y: fb.y, w: (unit ? unit.ink.x + unit.ink.w : fb.x + fb.w) - fb.x, h: fb.h };
+ let label: TypeSet | null = null;
+ if (it.label) {
+ const lo = { role: "body" as const, weight: 500, x: slot.x, width: Math.min(slot.w, i === 0 && !side ? safe.w * 0.7 : slot.w), maxLines: 3, leading: 1.18, even: 0.6 };
+ // The hero's label tucks into the column beside its figures when they leave a third of the width free, its last
+ // line on the figures' baseline (the poster keeps its height for the hero).
+ const bx = band.x + band.w + S * 0.045;
+ const bw = safe.x + safe.w - bx;
+ const tuck = i === 0 && !side && bw >= safe.w * 0.3;
+ const lo2 = tuck ? { ...lo, x: bx, width: bw, maxLines: 4 } : lo;
+ const l0 = c.set(`label${it.n}`, it.label, { ...lo2, y: 0, max: labelSize, min: S * 0.026 });
+ if (l0) {
+ const lastBase = l0.lines[l0.lines.length - 1].baseline - (l0.lines[0].y + l0.cap.top);
+ label = capAt(c, `label${it.n}`, it.label, { ...lo2, y: tuck ? band.y + band.h - lastBase : band.y + band.h + S * 0.03, max: l0.size, min: l0.size });
+ }
+ if (tuck && label) {
+ rows.push({ i, n: it.n, figs, unit, label, band });
+ bottomY = Math.max(bottomY, band.y + band.h);
+ return;
+ }
+ }
+ rows.push({ i, n: it.n, figs, unit, label, band });
+ bottomY = Math.max(bottomY, label ? label.lines[label.lines.length - 1].baseline + label.size * 0.25 : band.y + band.h);
+ });
+ return { rows, tops, bottomY };
+ };
+ let scale = 1;
+ let lay = layout(scale, b.top);
+ for (let i = 0; i < 14 && lay.bottomY > bottom; i++) lay = layout((scale *= 0.94), b.top);
+ lay = layout(scale, b.top + Math.max(0, (bottom - lay.bottomY) * 0.45));
+ const { rows, tops } = lay;
+ const overflowed = rows.some((r) => r.band.x + r.band.w > slots[r.i].x + slots[r.i].w + 1);
+
+ const k = c.spread(3.4, 1.5);
+ const plans: { figs: TypePlan; unit: TypePlan | null; label: TypePlan | null; at: number }[] = [];
+ let done = 0.6;
+ rows.forEach((r, i) => {
+ const at = 0.03 + i * 0.18 * k;
+ c.ev(`idx.${i}`, "fade", at, 0.3, "glide");
+ const figs = c.move(r.figs, { in: "odometer", at, hero: i === 0, intensity: 1, loop: "light-sweep", loopAt: 2.4 + i * 0.15, loopEvery: 1.9 }, `stat${r.n}`);
+ const unit = r.unit ? c.move(r.unit, { in: "stomp", at: Math.max(at + 0.1, figs.settled - 0.3), intensity: 0.8 }, `stat${r.n}.unit`) : null;
+ const label = r.label ? c.move(r.label, { in: "cut-rise", at: figs.settled - 0.3 }) : null;
+ done = Math.max(done, label?.settled ?? figs.settled, unit?.settled ?? 0);
+ plans.push({ figs, unit, label, at });
+ });
+ if (!side && rows.length > 1) c.ev("rule", "draw", 0.4, 0.6, "draw");
+ const signPlan = signIn(c, sign, "brand", 0.2);
+ const sitePlan = site ? c.move(site, { in: "fade-rise", at: 0.35, rate: 26 }) : null;
+ const row = footRow(c, done + 0.1);
+
+ const idxFont = fontOf(c.pairing.meta.family, idxSize, c.pairing.meta.weight);
+ const stops = fieldStops(pal);
+ const ruleY = rows[1] ? tops[1] - idxSize * 2.1 - S * 0.045 : 0;
+ // The starred words of each label, for their highlighter.
+ const marks: { row: number; x: number; w: number; capTop: number; baseline: number; key: string }[] = [];
+ rows.forEach((r, ri) => {
+ const it = items[r.i];
+ const l = r.label;
+ if (!l || !it.marks.length) return;
+ let at = 0;
+ l.words.forEach((w, wi) => {
+ at += w.gap.length;
+ const a = at;
+ const e = at + w.text.length;
+ at = e;
+ if (!it.marks.some(([p, q]) => p < e && q > a)) return;
+ const line = l.lines[w.line];
+ marks.push({ row: ri, x: w.x, w: w.w, capTop: line.y + l.cap.top, baseline: line.baseline, key: `s${ri}.${wi}` });
+ });
+ });
+ marks.forEach((mk, j) => c.ev(`mark.${j}`, "draw", (plans[mk.row]?.label?.settled ?? 1) + 0.05 + 0.08 * j, 0.4, "snap"));
+ const labelInk = metaInk(pal);
+ const idxInk = toneOf(pal, 0.6);
+
+ return {
+ overflow: [...(overflowed ? [`stat${rows.find((r) => r.band.x + r.band.w > slots[r.i].x + slots[r.i].w + 1)!.n}`] : []), ...rows.flatMap((r) => [...(r.figs.overflow ? [`stat${r.n}`] : []), ...(r.label?.overflow ? [`label${r.n}`] : [])]), ...(sign?.overflow ? ["brand"] : []), ...(site?.overflow ? ["website"] : []), ...row.overflow],
+ signature: (plans[0]?.figs.settled ?? 1) + 0.2,
+ camera: (t) => ({ x: 0, y: 18 * (1 - Math.min(1, t / c.last)) ** 2 }),
+ draw(t, kit) {
+ const field = litField(c, t, { from: "tr", stops });
+ const ghosts: DisplayNode[] = [];
+ const hero: DisplayNode[] = [];
+ const overlay: DisplayNode[] = [];
+ const rp = kit.P("rule");
+ if (rp > 0 && ruleY) overlay.push(rule({ x: safe.x, y: ruleY, w: safe.w, color: toneOf(pal, 0.3), p: rp, width: Math.max(1, S * 0.0016) }));
+ rows.forEach((r, i) => {
+ const p = plans[i];
+ const ip = kit.P(`idx.${i}`);
+ if (ip > 0) overlay.push(group([{ type: "text", field: `stat${r.n}`, decor: true, runs: [{ text: `0${i + 1}`, gap: "", font: idxFont, x: slots[i].x, y: r.band.y - idxSize * 2.1, fill: idxInk }] }], { opacity: ip }));
+ const nodes = [...kit.type(p.figs, { fill: pal.ink, sweep: "#ffffff", sweepAlpha: 0.45 }), ...(p.unit ? kit.type(p.unit, { fill: pal.ink }) : [])];
+ const pad = r.figs.size * 0.25;
+ if (t >= Math.max(p.figs.settled, p.unit?.settled ?? 0)) hero.push(...shadowed(c, nodes, r.figs.size * 0.5, { x: r.band.x - pad, y: r.band.y - pad, w: r.band.w + 2 * pad, h: r.band.h + 2 * pad }, `ss|${r.figs.text}|${r.figs.size}`, 0.8));
+ hero.push(...nodes);
+ for (const [j, mk] of marks.entries()) {
+ if (mk.row !== i) continue;
+ const hl = highlighter({ capTop: mk.capTop, baseline: mk.baseline, x: mk.x, w: mk.w, color: mixOk(markColor(c, pal.ground, labelInk), pal.ground, 0.1), seed: c.seed, p: kit.P(`mark.${j}`), key: mk.key, cover: 0.8, skew: -3 });
+ if (hl) hero.push(hl);
+ }
+ if (p.label) hero.push(...kit.type(p.label, { fill: labelInk }));
+ });
+ const meta = [...signNodes(c, kit, sign, signPlan, "brand", safe.x, safe.y, pal.ink), ...(sitePlan ? kit.type(sitePlan, { fill: metaInk(pal), caret: pal.accent }) : []), ...row.draw(kit, metaInk(pal), pal.ink)];
+ return [
+ { role: "ground", nodes: field },
+ { role: "ghost", nodes: ghosts },
+ { role: "hero", nodes: hero },
+ { role: "overlay", nodes: overlay },
+ { role: "meta", nodes: meta },
+ ];
+ },
+ };
+ },
+});
diff --git a/src/lib/motion/scenes/marketing/testimonials.ts b/src/lib/motion/scenes/marketing/testimonials.ts
new file mode 100644
index 00000000..b1776a49
--- /dev/null
+++ b/src/lib/motion/scenes/marketing/testimonials.ts
@@ -0,0 +1,204 @@
+/**
+ * Kind Words: three customers' words, the first as the poster's hero. It is set large on a deep lit field in a quiet
+ * serif in the accent (or paper when the accent doesn't read), its opening mark hung in the margin, its stars popping
+ * in above it and the name typing on under it. A giant filled quote mark one tone off the field bleeds off the left
+ * edge behind it. The other two follow as paper cards, each as wide as its words, overlapping a little on purpose,
+ * with a contact and an ambient shadow, sliding a short way in with their words riding inside; their stars are
+ * filled in the accent on the quote's line. The brand, the address, a corner note and an index arrow sit on the
+ * corners. Through the hold the type plane pushes in.
+ */
+
+import { group, type DisplayNode } from "../../display";
+import { contrastOf, ensureContrast, fieldStops, fromLch, lchOf, mixOk } from "../../color";
+import { twoShadow } from "../../fx/depth";
+import { rotation } from "../../fx/overlays";
+import type { TypePlan } from "../../type/animate";
+import { moveSet, type TypeSet } from "../../type/glyphs";
+import { starPath } from "./kit";
+import { bands, brandSign, capAt, capBand, footRow, ghost, litField, metaInk, posterScene, signIn, signNodes, topSite } from "./poster";
+
+interface Card {
+ i: number;
+ box: { x: number; y: number; w: number; h: number };
+ quote: TypeSet;
+ name: TypeSet | null;
+ deg: number;
+ starY: number;
+ starX: number;
+ /** The first quote: on the field, no card. */
+ hero: boolean;
+ plate: string;
+ ink: string;
+}
+
+export default posterScene({
+ id: "marketing/testimonials",
+ name: "Kind Words",
+ pairing: "T9",
+ look: "dark",
+ build(c) {
+ const { S, safe, pal, design } = c;
+ const side = c.wide;
+ const signH = S * (c.cover ? 0.058 : 0.046);
+ const sign = brandSign(c, { maxW: S * 0.42, h: signH, x: safe.x, y: safe.y, min: S * (c.cover ? 0.05 : 0.03) });
+ const metaSize = S * (c.cover ? 0.024 : 0.02);
+ const site = topSite(c, sign, metaSize);
+ const b = bands(c, { topRow: sign?.h ?? metaSize, gap: S * 0.06 });
+ const foot = metaSize * 1.1 + S * 0.05;
+ const top = b.top;
+ const bottom = b.bottom - foot;
+ const items = [1, 2, 3].map((n) => ({ q: c.field(`quote${n}`), n: c.field(`name${n}`), key: n })).filter((x) => x.q);
+ const rest = Math.max(0, items.length - 1);
+ const starR = S * (c.cover ? 0.017 : 0.014);
+ const nameSize = S * (c.cover ? 0.028 : 0.024);
+ const starsW = 5 * starR * 2.4;
+ const cardText = S * (c.cover ? 0.031 : 0.03);
+ // The cards keep room for two lines of words; the hero takes the rest (the left half of a wide frame).
+ const cardNeed = cardText * 2.4 + cardText * 1.5 + starR * 2 + S * 0.02;
+ const overlap = -S * 0.025;
+ const heroH = rest ? Math.max((bottom - top) * 0.44, bottom - top - rest * cardNeed + (rest - 1) * overlap - S * 0.06) : bottom - top;
+ const heroBox = side ? { x: safe.x, y: top, w: safe.w * 0.52, h: bottom - top } : { x: safe.x, y: top, w: safe.w, h: heroH };
+ // One material for every card: warm ivory paper with a faint tint of the brand.
+ const plateOf = () => mixOk(mixOk(pal.paper, "#f3ece0", 0.7), pal.brand[0], 0.05);
+ // The hero's ink: the accent when it reads at 4.5:1 on the field's lighter stop, else paper.
+ const stops = { dark: fromLch(0.12, Math.max(0.05, lchOf(pal.brand[0]).C * 0.7), lchOf(pal.brand[0]).h), light: fromLch(0.3, Math.max(0.05, lchOf(pal.brand[0]).C * 0.8), (lchOf(pal.brand[0]).h + 340) % 360) };
+ const heroInk = c.dark && contrastOf(pal.accent, stops.light) >= 4.5 && contrastOf(pal.accent, pal.ground) >= 4.6 ? pal.accent : pal.ink;
+ const cards: Card[] = [];
+ let heroBottom = top;
+ let cardBottom = -Infinity;
+ items.forEach((it, i) => {
+ const hero = i === 0;
+ if (hero) {
+ const inner = { x: heroBox.x, w: heroBox.w };
+ const name0 = it.n ? c.set(`name${it.key}`, it.n, { role: "meta", x: inner.x, y: 0, width: inner.w, maxLines: 1, max: nameSize * 1.1, min: S * 0.02 }) : null;
+ const nameH = name0 ? capBand(name0).h : 0;
+ const starsH = starR * 2 + S * 0.035;
+ const qTop = heroBox.y + starsH;
+ const qRoom = heroBox.h - starsH - nameH - S * 0.06;
+ const qo = (max: number) => ({ role: "hero" as const, x: inner.x, y: qTop, width: inner.w, maxLines: 5, max, min: S * 0.03, leading: 1.08, preset: "cut-rise" as const, even: 0.4 });
+ let quote = capAt(c, `quote${it.key}`, it.q, qo(Math.min(S * (side ? 0.09 : 0.125), qRoom / 1.2)));
+ for (let j = 0; quote && j < 16 && capBand(quote).h > qRoom; j++) quote = capAt(c, `quote${it.key}`, it.q, qo(quote.size * 0.93));
+ if (!quote) return;
+ const hang = Math.max(0, inner.x - quote.ink.x);
+ if (hang > 0.5) quote = capAt(c, `quote${it.key}`, it.q, { ...qo(quote.size), x: inner.x + hang, width: inner.w - hang, min: Math.min(quote.size, S * 0.03) }) ?? quote;
+ const qBottom = quote.lines[quote.lines.length - 1].baseline;
+ const name = name0 ? capAt(c, `name${it.key}`, it.n, { role: "meta", x: inner.x, y: qBottom + S * 0.045, width: inner.w, maxLines: 1, max: name0.size, min: Math.min(name0.size, S * 0.02) }) : null;
+ heroBottom = name ? name.lines[0].baseline + name.size * 0.3 : qBottom + quote.size * 0.3;
+ cards.push({ i, box: heroBox, quote, name, deg: 0, starY: heroBox.y + starR, starX: inner.x, hero, plate: pal.ground, ink: heroInk });
+ return;
+ }
+ const plate = plateOf();
+ const ink = ensureContrast(mixOk(pal.brand[0], "#101014", 0.35), plate, 7);
+ const pad = cardText * 0.9;
+ // Cards start at least 4 % of the short side below the hero's last line (its name).
+ const zoneTop = side ? top : heroBottom + S * 0.045;
+ const zoneH = bottom - zoneTop;
+ const h = side ? (zoneH + (rest - 1) * overlap) / rest : Math.min(cardNeed * 1.25, (zoneH + (rest - 1) * overlap) / rest);
+ const maxW = side ? safe.w * 0.44 : safe.w * 0.78;
+ const x0 = side ? safe.x + safe.w * 0.56 : safe.x;
+ // The card's words in the quote's serif, on two lines when they fit a little smaller (a balanced rag), else three.
+ const qOpts = { role: "hero" as const, x: 0, y: 0, width: maxW - 2 * pad, leading: 1.18, preset: "fade-rise" as const };
+ const two = c.set(`quote${it.key}`, it.q, { ...qOpts, maxLines: 2, max: cardText, min: cardText * 0.82 });
+ const quote0 = two && !two.overflow ? two : c.set(`quote${it.key}`, it.q, { ...qOpts, maxLines: 3, max: cardText, min: S * 0.026 });
+ if (!quote0) return;
+ const textW = Math.max(...quote0.lines.map((l) => l.ink.w), starsW + S * 0.2);
+ const w = Math.min(maxW, textW + 2 * pad);
+ const x = side ? x0 : (i - 1) % 2 ? safe.x + safe.w - w : x0;
+ const y = Math.max(cardBottom + S * 0.03, zoneTop + (i - 1) * (h - overlap) + (side ? 0 : Math.max(0, zoneH - (rest * h - (rest - 1) * overlap)) * 0.5));
+ const quote = capAt(c, `quote${it.key}`, it.q, { ...qOpts, x: x + pad, y: y + pad, width: w - 2 * pad + 1, maxLines: quote0.lines.length, max: quote0.size, min: quote0.size });
+ if (!quote) return;
+ const qBottom = quote.lines[quote.lines.length - 1].baseline;
+ const starY = qBottom + cardText * 0.9 + starR;
+ const name0 = it.n ? c.set(`name${it.key}`, it.n, { role: "meta", x: x + pad + starsW + S * 0.015, y: 0, width: w - 2 * pad - starsW - S * 0.015, maxLines: 1, max: nameSize, min: S * 0.02 }) : null;
+ const name = name0 ? capAt(c, `name${it.key}`, it.n, { role: "meta", x: x + pad + starsW + S * 0.015, y: starY - capBand(name0).h / 2, width: w - 2 * pad - starsW - S * 0.015, maxLines: 1, max: name0.size, min: name0.size }) : null;
+ const boxH = Math.max(h, starY + starR + pad * 0.8 - y);
+ cardBottom = y + boxH;
+ cards.push({ i, box: { x, y, w, h: boxH }, quote, name, deg: [-3, 2.5][(i - 1) % 2], starY, starX: x + pad, hero: false, plate, ink });
+ });
+ // The cards keep clear of the foot row: lifted together (never into the hero) when the last runs low.
+ const lastCard = cards[cards.length - 1];
+ const lift = lastCard && !lastCard.hero ? Math.min(lastCard.box.y + lastCard.box.h - (bottom - S * 0.03), (cards[1]?.box.y ?? 0) - (heroBottom + S * 0.03)) : 0;
+ if (lift > 0) {
+ for (const cd of cards) {
+ if (cd.hero) continue;
+ cd.box = { ...cd.box, y: cd.box.y - lift };
+ cd.starY -= lift;
+ cd.quote = moveSet(cd.quote, 0, -lift);
+ if (cd.name) cd.name = moveSet(cd.name, 0, -lift);
+ }
+ }
+
+ const k = c.spread(3.4, 1.5);
+ const quotePlans: TypePlan[] = [];
+ const namePlans: (TypePlan | null)[] = [];
+ let at = 0.03;
+ cards.forEach((cd, i) => {
+ c.ev(`card.${i}`, "enter", at, 0.55, "settle");
+ for (let s = 0; s < 5; s++) c.ev(`star.${i}.${s}`, "pop", at + (cd.hero ? 0.05 : 0.3) + s * 0.08, 0.4, "pop", { group: `stars.${i}`, unit: "elements" });
+ // A card's words arrive with it (never an empty box).
+ const q = c.move(cd.quote, cd.hero ? { in: "cut-rise", at: at + 0.12 } : { in: "fade-rise", at, intensity: 0 });
+ quotePlans.push(q);
+ namePlans.push(cd.name ? c.move(cd.name, { in: "fade-rise", at: q.settled - 0.1, rate: 30 }) : null);
+ at = cd.hero ? q.settled - 0.15 : at + 0.32 * k;
+ });
+ const signPlan = signIn(c, sign, "brand", 0.25);
+ const sitePlan = site ? c.move(site, { in: "fade-rise", at: 0.4, rate: 26 }) : null;
+ const row = footRow(c, at + 0.2);
+ const starFill = ensureContrast(pal.accent, stops.light, 3);
+ const markGround = mixOk(stops.dark, stops.light, 0.75);
+ const heroSet = cards[0]?.hero ? cards[0].quote : null;
+ // The mark only where the hero leaves the right side free (never under its words).
+ const free = heroSet ? safe.x + safe.w - Math.max(...heroSet.lines.map((l) => l.ink.x + l.ink.w)) - S * 0.04 : 0;
+ const ghostSize = free >= S * 0.16 ? Math.min(design.h * 0.4, free / 0.5) : 0;
+
+ return {
+ overflow: [...cards.flatMap((cd) => [...(cd.quote.overflow ? [cd.quote.field] : []), ...(cd.name?.overflow ? [cd.name.field] : [])]), ...(sign?.overflow ? ["brand"] : []), ...(site?.overflow ? ["website"] : []), ...row.overflow],
+ signature: at + 0.2,
+ camera: (t) => ({ x: 0, y: 24 * (1 - Math.min(1, t / c.last)) ** 2 }),
+ draw(t, kit) {
+ // Night: deep navy to a dusk blue, a warm window light from the top right.
+ const field = c.dark ? litField(c, t, { from: "tr", stops, light: mixOk(pal.brand[1], "#ffd9a0", 0.5), lightAlpha: 0.22 }) : litField(c, t, { from: "tr", stops: fieldStops(pal) });
+ // A giant quote mark, one tone off the field, bleeding off the left edge behind the hero.
+ // A giant quote mark, one faint tone off the field, whole, at the right behind the hero's end and the cards.
+ const ghosts: DisplayNode[] = heroSet && ghostSize > 0 ? [ghost(c, { field: heroSet.field, lines: ["”"], size: ghostSize, x: safe.x + safe.w + S * 0.02, align: "right", y: heroSet.lines[0].y - ghostSize * 0.1, t, ground: markGround, family: c.pairing.hero.family })] : [];
+ const hero: DisplayNode[] = [];
+ const subject: DisplayNode[] = [];
+ cards.forEach((cd, i) => {
+ const lin = kit.L(`card.${i}`);
+ if (lin <= 0) return;
+ const p = kit.P(`card.${i}`);
+ const bx = cd.box;
+ const inside: DisplayNode[] = [];
+ for (let s = 0; s < 5; s++) {
+ const q = kit.P(`star.${i}.${s}`);
+ if (kit.L(`star.${i}.${s}`) <= 0) continue;
+ const x = cd.starX + starR + s * starR * 2.4;
+ const y = cd.starY;
+ inside.push(group([{ type: "path", d: starPath(x, y, starR, starR * 0.45, 5), fill: cd.hero ? starFill : ensureContrast(pal.accent, cd.plate, 2.2) }], { transform: [q, 0, 0, q, x - q * x, y - q * y] }));
+ }
+ inside.push(...kit.type(quotePlans[i], { fill: cd.ink }));
+ const np = namePlans[i];
+ if (np) inside.push(...kit.type(np, { fill: cd.hero ? metaInk(pal) : metaInk({ ...pal, ink: cd.ink, ground: cd.plate }) }));
+ if (cd.hero) {
+ hero.push(...inside);
+ return;
+ }
+ // A short slide (never a long smear), the words inside it.
+ const dx = (1 - p) * S * 0.14 * (i % 2 ? -1 : 1);
+ const rect: DisplayNode = { type: "rect", ...bx, r: S * 0.014, fill: cd.plate, stroke: { paint: mixOk(starFill, cd.plate, 0.45), width: Math.max(1, S * 0.001) } };
+ // It swings level as it lands (never tilted at rest).
+ const rot = rotation(cd.deg * (1 - p), bx.x + bx.w / 2, bx.y + bx.h / 2);
+ subject.push(group([...twoShadow({ nodes: [rect], size: bx.h, ground: stops.dark, bounds: bx, key: `kw|${bx.w.toFixed(0)}x${bx.h.toFixed(0)}` }), rect, ...inside], { transform: [rot[0], rot[1], rot[2], rot[3], rot[4] + dx, rot[5]], ...(lin < 0.15 && { opacity: lin / 0.15 }) }));
+ });
+ const meta = [...signNodes(c, kit, sign, signPlan, "brand", safe.x, safe.y, pal.ink), ...(sitePlan ? kit.type(sitePlan, { fill: metaInk(pal), caret: pal.accent }) : []), ...row.draw(kit, metaInk(pal), pal.ink)];
+ return [
+ { role: "ground", nodes: field },
+ { role: "ghost", nodes: ghosts },
+ { role: "hero", nodes: hero },
+ { role: "overlay", nodes: subject },
+ { role: "meta", nodes: meta },
+ ];
+ },
+ };
+ },
+});
diff --git a/src/lib/motion/showcase.ts b/src/lib/motion/showcase.ts
index 72891013..30fc700b 100644
--- a/src/lib/motion/showcase.ts
+++ b/src/lib/motion/showcase.ts
@@ -12,20 +12,28 @@ export interface ShowcaseBrand {
name: string;
colors: string[];
fonts: { heading: string; body: string };
- /** Its lockup (symbol and wordmark as outlines, in one colour), drawn by Fuobe: /previews/kinetic/marks/…svg. */
- logo: string;
+ /** Its lockup (symbol and wordmark as outlines, in one colour), drawn by Fuobe: /previews/kinetic/marks/…svg. None: its name is set in type. */
+ logo?: string;
}
-export const SHOWCASE_BRANDS = {
- ardent: { name: "Maison Ardent", colors: ["#2f3b2c", "#c9a46a"], fonts: { heading: "Playfair Display", body: "Inter" }, logo: "/previews/kinetic/marks/ardent.svg?v=9d6992d9" },
+const BRANDS = {
+ ardent: { name: "Maison Ardent", colors: ["#4a1424", "#e9b8aa"], fonts: { heading: "Playfair Display", body: "Inter" }, logo: "/previews/kinetic/marks/ardent.svg?v=9d6992d9" },
lumen: { name: "Lumen Labs", colors: ["#3d5afe", "#9fe7ff"], fonts: { heading: "Space Grotesk", body: "Inter" }, logo: "/previews/kinetic/marks/lumen.svg?v=5383c502" },
- ledgerly: { name: "Ledgerly", colors: ["#0f5c5a", "#f4b860"], fonts: { heading: "Space Grotesk", body: "Inter" }, logo: "/previews/kinetic/marks/ledgerly.svg?v=04360c5d" },
+ ledgerly: { name: "Ledgerly", colors: ["#1f3fd1", "#ffb547"], fonts: { heading: "Space Grotesk", body: "Inter" }, logo: "/previews/kinetic/marks/ledgerly.svg?v=04360c5d" },
vesper: { name: "Vesper", colors: ["#c8102e", "#f4b43c"], fonts: { heading: "Fraunces", body: "Manrope" }, logo: "/previews/kinetic/marks/vesper.svg?v=7c2c68c7" },
- sora: { name: "Sora Skin", colors: ["#b5532f", "#e9b872"], fonts: { heading: "Fraunces", body: "Manrope" }, logo: "/previews/kinetic/marks/sora.svg?v=0b4eecd2" },
+ sora: { name: "Sora Skin", colors: ["#6b1430", "#f6cdd2"], fonts: { heading: "Fraunces", body: "Manrope" }, logo: "/previews/kinetic/marks/sora.svg?v=0b4eecd2" },
aurele: { name: "Aurèle", colors: ["#0e3b2f", "#cfae6e"], fonts: { heading: "Cormorant Garamond", body: "Manrope" }, logo: "/previews/kinetic/marks/aurele.svg?v=55ea21a5" },
+ kova: { name: "KOVA", colors: ["#ff5a1f", "#16120f"], fonts: { heading: "Archivo Black", body: "Inter" } },
+ noor: { name: "Atelier Noor", colors: ["#17120d", "#d8b26e"], fonts: { heading: "Bodoni Moda", body: "Inter" } },
+ halden: { name: "Halden", colors: ["#16110f", "#e5432c"], fonts: { heading: "DM Serif Display", body: "Inter" } },
+ halcyon: { name: "Halcyon Hotels", colors: ["#123049", "#e2bd78"], fonts: { heading: "Cormorant Garamond", body: "Manrope" } },
+ lune: { name: "Bar Lune", colors: ["#1c1236", "#ffb36b"], fonts: { heading: "Fraunces", body: "Outfit" } },
+ orbit: { name: "Orbit", colors: ["#1b2a63", "#ff7a59"], fonts: { heading: "Space Grotesk", body: "Inter" } },
} satisfies Record<string, ShowcaseBrand>;
-export type ShowcaseBrandId = keyof typeof SHOWCASE_BRANDS;
+export const SHOWCASE_BRANDS: Record<keyof typeof BRANDS, ShowcaseBrand> = BRANDS;
+
+export type ShowcaseBrandId = keyof typeof BRANDS;
/**
* Fuobe's own sample products, cut out (with their versions): objects made for the showcase brands, in their
@@ -52,11 +60,22 @@ export const SHOWCASE_PRODUCT_THUMBS: Record<keyof typeof SHOWCASE_PRODUCTS, str
headphones: "/previews/kinetic/products/thumbs/lumen-headphones.webp?v=0d3422a9",
};
+/** Fuobe's own sample photographs, for templates that fill a panel or the frame with one (with their versions). */
+export const SHOWCASE_PHOTOS = {
+ portrait: "/previews/kinetic/photos/portrait-soft.webp?v=d5a8ad5a",
+ dunes: "/previews/kinetic/photos/red-dunes.webp?v=55df7331",
+ gown: "/previews/kinetic/photos/gold-gown.webp?v=27ae6c3f",
+ night: "/previews/kinetic/photos/night-lights.webp?v=4234c952",
+} as const;
+
export interface Showcase {
brand: ShowcaseBrandId;
+ /** The brand's colours for this piece, when it shows the brand in another of its palettes (its own by default). */
+ colors?: string[];
fields: Record<string, string>;
controls: Record<string, string>;
product?: keyof typeof SHOWCASE_PRODUCTS;
+ photo?: keyof typeof SHOWCASE_PHOTOS;
size: SizePreset;
/** The scene, when a choice picks it (the end card's style). */
scene?: string;
@@ -69,16 +88,24 @@ export interface Showcase {
/** Each code-drawn template's showcase, by template id. */
export const SHOWCASES: Record<string, Showcase> = {
- "ms-kinetic-headline": { brand: "lumen", size: "9:16", fields: { headline: "Invoices that *chase* themselves.", cta: "Start free", website: "lumenlabs.io" }, controls: { pace: "punchy", look: "dark", align: "centre" }, poster: "words.exit" },
- "m2-line-reveal": { brand: "ardent", size: "9:16", product: "perfume", fields: { headline: "Quietly exceptional.", cta: "Discover the scent" }, controls: { pace: "calm", look: "light", line: "fine" } },
- "ms-logo-sting": { brand: "lumen", size: "4:5", fields: { tagline: "Software that ships itself" }, controls: { pace: "punchy", look: "dark" } },
- "ms-feature-cards": { brand: "ledgerly", size: "4:5", fields: { headline: "Month-end, minus the panic", point1: "Invoices that chase themselves", point2: "Payroll in two taps", point3: "Books that close on Friday" }, controls: { pace: "calm", look: "light" } },
- "ms-dashboard-zoom": { brand: "ledgerly", size: "4:5", fields: { stat: "$1,284,000", label: "Revenue this quarter, up 38%" }, controls: { pace: "calm", look: "dark" } },
- "m2-retro-starburst": { brand: "vesper", size: "9:16", product: "heel", fields: { headline: "Made to be noticed.", badge: "New!" }, controls: { pace: "punchy", look: "brand" } },
- "m2-offer-badge": { brand: "sora", size: "9:16", product: "serum", fields: { offer: "20% off", headline: "The gifting edit", cta: "Shop the edit" }, controls: { pace: "punchy", look: "light" } },
- "ms-big-number": { brand: "ledgerly", size: "4:5", fields: { stat: "3×", caption: "faster month-end close" }, controls: { pace: "punchy", look: "brand" } },
- "ms-five-star-quote": { brand: "sora", size: "4:5", fields: { quote: "“The only serum I’ve ever bought three times.”", name: "Amara K., verified buyer" }, controls: { pace: "calm", look: "light" } },
+ "ms-kinetic-headline": { brand: "lumen", size: "9:16", fields: { headline: "SHIP IT *TONIGHT.*", cta: "Start free", website: "lumenlabs.io", note: "Release 4.0" }, controls: { pace: "punchy", look: "dark", align: "left" } },
+ "m2-line-reveal": { brand: "ardent", size: "9:16", product: "perfume", fields: { headline: "Quietly exceptional.", cta: "Discover the scent", website: "maison-ardent.com", note: "Est. 1987" }, controls: { pace: "calm", look: "light", line: "fine" } },
+ "ms-logo-sting": { brand: "lumen", size: "4:5", fields: { tagline: "Software that ships itself", website: "lumenlabs.io", note: "Est. 2019" }, controls: { pace: "punchy", look: "dark" } },
+ "ms-feature-cards": { brand: "ledgerly", colors: ["#4a1020", "#f2c4c0"], size: "4:5", fields: { headline: "Month-end, minus the panic", point1: "Invoices that chase themselves", point2: "Payroll in two taps", point3: "Books that close on Friday", website: "ledgerly.app", note: "Built for finance teams" }, controls: { pace: "calm", look: "brand" } },
+ "ms-dashboard-zoom": { brand: "ledgerly", size: "4:5", fields: { stat: "$1,284,000", label: "Revenue this quarter, up 38%", website: "ledgerly.app", note: "Q3 2026" }, controls: { pace: "calm", look: "dark" } },
+ "m2-retro-starburst": { brand: "vesper", size: "9:16", product: "heel", fields: { headline: "Made to be noticed.", badge: "New!", website: "vesper-shoes.com", note: "SS26" }, controls: { pace: "punchy", look: "light" } },
+ "m2-offer-badge": { brand: "sora", size: "9:16", product: "serum", fields: { offer: "20% off", headline: "THE GIFTING EDIT", cta: "Shop the edit", website: "soraskin.co", note: "Until 24 Dec" }, controls: { pace: "punchy", look: "brand" } },
+ "ms-big-number": { brand: "ledgerly", size: "4:5", fields: { stat: "3×", caption: "*faster* month-end close, every month", website: "ledgerly.app", note: "2026 report" }, controls: { pace: "punchy", look: "light" } },
+ "ms-five-star-quote": { brand: "sora", size: "4:5", photo: "portrait", fields: { quote: "“The only serum I’ve ever bought three times.”", name: "Amara K., verified buyer", website: "soraskin.co", note: "Verified reviews" }, controls: { pace: "calm", look: "light" } },
"ms-end-card": { brand: "aurele", size: "9:16", scene: "end-card/draw-on", fields: { product: "Le Sérum Nuit", cta: "Discover the ritual", website: "aurele-paris.com" }, controls: { style: "draw-on", mark: "logo" } },
+ "m2-midnight-drop": { brand: "kova", size: "9:16", fields: { headline: "DROP 07", count: "03:12:45", when: "Friday · 9 PM", cta: "Set a reminder", website: "kova.store", note: "Season 07" }, controls: { pace: "punchy", look: "dark" } },
+ "m2-nocturne": { brand: "ardent", size: "9:16", product: "perfume", fields: { headline: "Nocturne", line: "Eau de parfum, for the hours after dark", cta: "Discover", website: "maison-ardent.com", note: "Est. 1987" }, controls: { pace: "calm", look: "dark" } },
+ "m2-season-finale": { brand: "halden", size: "4:5", photo: "dunes", fields: { headline: "FINAL SALE", offer: "Up to 50% off", cta: "Shop the sale", website: "halden-studio.com", note: "SS26 Collection" }, controls: { pace: "punchy", look: "light" } },
+ "m2-prism-stage": { brand: "aurele", colors: ["#2a1d4a", "#cfd3e0"], size: "4:5", product: "nightSerum", fields: { headline: "Eau de Nuit", line: "Amber, iris and a trace of smoke", cta: "Discover", website: "aurele-paris.com", note: "Est. 1924" }, controls: { pace: "calm", look: "dark" } },
+ "mm-marquee": { brand: "lune", size: "9:16", photo: "night", fields: { headline: "Opening Night", when: "Friday 14 March · 8 PM", place: "12 Rue des Martyrs, Paris", cta: "Reserve a table", website: "barlune.fr", note: "Doors at 7:30" }, controls: { pace: "calm", look: "dark" } },
+ "mm-runway-titles": { brand: "noor", size: "4:5", photo: "gown", fields: { headline: "THE GOLD HOUR", accent: "Spring", line: "Collection 07 · Marrakech", website: "ateliernoor.com", note: "SS26" }, controls: { pace: "calm", look: "dark" } },
+ "ms-stat-stack": { brand: "orbit", size: "4:5", fields: { stat1: "98%", label1: "of tickets answered in *an hour*", stat2: "4.9", label2: "average rating from 12,000 teams", stat3: "3×", label3: "faster than last year", website: "orbit.help", note: "2026 report" }, controls: { pace: "punchy", look: "dark" } },
+ "ms-kind-words": { brand: "halcyon", size: "4:5", fields: { quote1: "“The calmest three days I’ve had all year.”", name1: "Léa M., Lisbon", quote2: "“Breakfast on the terrace was worth the trip alone.”", name2: "James O., London", quote3: "“We’ve booked again for September.”", name3: "Priya S., Mumbai", website: "halcyonhotels.com", note: "Guest reviews" }, controls: { pace: "calm", look: "dark" } },
};
/**
@@ -99,8 +126,8 @@ export function showcaseRecipe(id: string, scene: string, duration = 5, o: { cov
fps: 30,
duration,
fields: s.brand === "aurele" ? { brand: b.name, ...s.fields } : { ...s.fields },
- brand: { name: b.name, colors: [...b.colors], fonts: { ...b.fonts }, ...(logo && { logo }) },
- ...(s.product && { media: { product: SHOWCASE_PRODUCTS[s.product] } }),
+ brand: { name: b.name, colors: [...(s.colors ?? b.colors)], fonts: { ...b.fonts }, ...(logo && { logo }) },
+ ...((s.product || s.photo) && { media: { product: s.product ? SHOWCASE_PRODUCTS[s.product] : SHOWCASE_PHOTOS[s.photo!] } }),
controls: { template: id, ...s.controls, ...(o.cover && { cover: "tile" }) },
export: DEFAULT_EXPORT,
};
diff --git a/src/lib/motion/template.ts b/src/lib/motion/template.ts
index 8548145f..b42ab9c1 100644
--- a/src/lib/motion/template.ts
+++ b/src/lib/motion/template.ts
@@ -7,7 +7,7 @@
import { FORMATS, KINETIC_SIZES, type MarketingTemplate } from "@/lib/catalog/marketing";
import { unmarked } from "./marks";
import { DEFAULT_EXPORT, type Recipe } from "./recipe";
-import { SHOWCASE_BRANDS, SHOWCASE_PRODUCTS, SHOWCASES } from "./showcase";
+import { SHOWCASE_BRANDS, SHOWCASE_PHOTOS, SHOWCASE_PRODUCTS, SHOWCASES } from "./showcase";
import type { SizePreset } from "./sizes";
export interface TemplateBrand {
@@ -54,8 +54,9 @@ export function templateScene(t: MarketingTemplate, controls: Record<string, str
/** The showcase brand a template opens with. */
export function showcaseBrand(t: MarketingTemplate): TemplateBrand {
- const b = SHOWCASE_BRANDS[SHOWCASES[t.id]?.brand ?? "lumen"];
- return { name: b.name, colors: [...b.colors], fonts: { ...b.fonts }, logo: b.logo };
+ const s = SHOWCASES[t.id];
+ const b = SHOWCASE_BRANDS[s?.brand ?? "lumen"];
+ return { name: b.name, colors: [...(s?.colors ?? b.colors)], fonts: { ...b.fonts }, logo: b.logo };
}
/** The state a template opens in: its showcase words and choices, and the person's own brand when they set one. */
@@ -73,7 +74,7 @@ export function initialState(t: MarketingTemplate, brand?: TemplateBrand | null)
size: s?.size && sizes.includes(s.size) ? s.size : sizes[0],
duration: lengths.default,
brand: brand ?? showcaseBrand(t),
- product: t.picture === "product" ? (s?.product ? SHOWCASE_PRODUCTS[s.product] : SHOWCASE_PRODUCTS.perfume) : null,
+ product: t.picture === "product" ? (s?.product ? SHOWCASE_PRODUCTS[s.product] : SHOWCASE_PRODUCTS.perfume) : t.picture === "photo" ? SHOWCASE_PHOTOS[s?.photo ?? "portrait"] : null,
};
}
@@ -96,7 +97,7 @@ export function templateRecipe(t: MarketingTemplate, s: TemplateState): Recipe {
const logo = s.brand.logo && !(endCard && s.controls.mark === "name") ? s.brand.logo : undefined;
const controls: Record<string, string> = { template: t.id };
for (const g of t.easy ?? []) if (!g.scene && s.controls[g.id]) controls[g.id] = s.controls[g.id];
- const product = t.picture === "product" && s.product ? s.product : undefined;
+ const product = t.picture && s.product ? s.product : undefined;
return {
v: 1,
scene,
diff --git a/src/lib/motion/tween.ts b/src/lib/motion/tween.ts
index a73159a1..3d3247cf 100644
--- a/src/lib/motion/tween.ts
+++ b/src/lib/motion/tween.ts
@@ -36,11 +36,15 @@ export function stagger(i: number, n: number, each: number, total = Infinity): n
return i * Math.min(each, total / (n - 1));
}
-/** What a timing rule calls a moving thing (tests/motion-timing.test.ts checks each kind's limits). */
-export type EventKind = "enter" | "pop" | "fade" | "draw" | "move" | "camera" | "exit";
+/**
+ * What a timing rule calls a moving thing (tests/motion-timing.test.ts checks each kind's limits). `hero` is the
+ * entrance of type taller than a quarter of the frame (it may take up to 1 s); `slam` is the short accelerating hit of
+ * a stomp (0.12–0.3 s).
+ */
+export type EventKind = "enter" | "hero" | "slam" | "pop" | "fade" | "draw" | "move" | "camera" | "exit";
-/** How a group of events is spaced: words (40–80 ms), elements (80–140 ms) or letters (20–50 ms). */
-export type StaggerUnit = "letters" | "words" | "elements";
+/** How a group of events is spaced: letters (20–50 ms), words (40–80 ms), lines (80–200 ms) or elements (80–140 ms). */
+export type StaggerUnit = "letters" | "words" | "lines" | "elements";
export interface MotionEvent {
/** Stable name ("headline.line.1", "cta.pill"). */
@@ -94,6 +98,8 @@ export function linearProgress(tl: Timeline, id: string, t: number): number {
/** Limits per kind, in seconds: an entrance 350–700 ms, nothing that moves under 200 ms. */
export const DURATION_LIMITS: Record<EventKind, [number, number]> = {
enter: [0.35, 0.7],
+ hero: [0.35, 1],
+ slam: [0.12, 0.3],
pop: [0.35, 0.7],
fade: [0.2, 1.5],
draw: [0.2, 1.5],
@@ -105,6 +111,7 @@ export const DURATION_LIMITS: Record<EventKind, [number, number]> = {
export const STAGGER_LIMITS: Record<StaggerUnit, [number, number]> = {
letters: [0.02, 0.05],
words: [0.04, 0.08],
+ lines: [0.08, 0.2],
elements: [0.08, 0.14],
};
diff --git a/src/lib/motion/type/animate.ts b/src/lib/motion/type/animate.ts
new file mode 100644
index 00000000..e82e6ba0
--- /dev/null
+++ b/src/lib/motion/type/animate.ts
@@ -0,0 +1,781 @@
+/**
+ * Moving type (pure): a type set (glyphs.ts) and a motion (an entrance preset, an optional exit and loop) give the
+ * timeline events and, at any time, the display nodes that draw it.
+ *
+ * - At rest every unit is at its layout place and the field is one text node whose pieces spell the typed words.
+ * - While moving, each unit is its own group (its transform, its clip, its mask), and decorative copies (a stomp's
+ * ring, a neon glow, an echo, a colour split) are text nodes marked `decor`.
+ * - Units follow one another with eased gaps (wide, then tightening), within the timing rules for their unit.
+ * - Everything is a function of the time asked for: no state, no clock, no Math.random.
+ */
+
+import { group, IDENTITY, mixHex, multiply, withAlpha, type Box, type DisplayNode, type GroupNode, type Matrix, type Paint, type TextRun } from "../display";
+import type { CurveName } from "../ease";
+import { rng } from "../random";
+import { clamp } from "../time";
+import { DURATION_LIMITS, STAGGER_LIMITS, type EventKind, type MotionEvent, type StaggerUnit } from "../tween";
+import { fontOf, weightFor } from "./faces";
+import type { TypeSet } from "./glyphs";
+import { F, LOOP_REST, loopAt, PRESETS, REST, scrambleLock, type LoopId, type LoopPose, type Pivot, type Pose, type Preset, type PresetId, type PresetOptions, type UnitInfo, type UnitKind } from "./presets";
+
+export interface TextMotion {
+ /** The entrance. */
+ in: PresetId;
+ /** When it starts (seconds). */
+ at: number;
+ /** The exit (the entrance's own by default) and when it starts; none when absent. */
+ out?: PresetId;
+ exitAt?: number;
+ /** A loop after the entrance: from `loopAt` (default 0.15 s after it settles). */
+ loop?: LoopId;
+ loopAt?: number;
+ loopEvery?: number;
+ loopPeriod?: number;
+ /** No sweep may still be crossing after this (seconds; the clip's last frame by default in a poster). */
+ loopUntil?: number;
+ /** 0.7–1.4: faster or slower than designed. */
+ speed?: number;
+ /** 0–1: how far things travel. */
+ intensity?: number;
+ seed?: number;
+ /** Type over a quarter of the frame's height (a weightier entrance). */
+ hero?: boolean;
+ /** Copies trailing a moving unit (3–5). */
+ echo?: number;
+ /** Type-on: letters a second (default 20). Beat-cut: seconds a beat (default 0.5). */
+ rate?: number;
+ beat?: number;
+ /** A stomp's white flash on impact (accent words only). */
+ flash?: boolean;
+ /** A dark ground (colour splits and glows read only there). */
+ dark?: boolean;
+}
+
+export interface TypeStyle {
+ fill: Paint;
+ /** An outline (hollow type: fill "transparent"). */
+ stroke?: { paint: Paint; width: number };
+ /** Bar-swipe's bar. */
+ bar?: string;
+ /** Neon's glow colour. */
+ glow?: string;
+ /** Split-flap tiles. */
+ tile?: string;
+ /** Paper chips under words (cut-paper). */
+ chip?: string;
+ /** Type-on's caret. */
+ caret?: string;
+ /** A light sweep's colour and strength. */
+ sweep?: string;
+ sweepAlpha?: number;
+}
+
+interface Piece {
+ text: string;
+ gap: string;
+ x: number;
+ y: number;
+ w: number;
+ line: number;
+ /** Its letter's place in its line, spaces counted (tracking moves letters apart by it); -1 for a whole line or word. */
+ ord: number;
+ /** Its letter in the set's glyphs (-1 for a whole line or word). */
+ glyph: number;
+}
+
+export interface PlannedUnit {
+ info: UnitInfo;
+ start: number;
+ exitStart: number | null;
+ pieces: Piece[];
+}
+
+export interface TypePlan {
+ id: string;
+ set: TypeSet;
+ motion: TextMotion;
+ preset: Preset;
+ exit: Preset;
+ options: PresetOptions;
+ units: PlannedUnit[];
+ events: MotionEvent[];
+ /** Every unit has landed (the entrance's end). */
+ settled: number;
+ /** The exit's end (null: no exit). */
+ gone: number | null;
+ loopStart: number;
+ frame: { w: number; h: number };
+ speed: number;
+}
+
+const unitStagger: Record<UnitKind, StaggerUnit> = { glyph: "letters", word: "words", line: "lines", block: "elements" };
+
+const limit = (v: number, [lo, hi]: readonly [number, number]) => Math.min(hi, Math.max(lo, v));
+const round6 = (v: number) => Math.round(v * 1e6) / 1e6;
+
+/** Start offsets for `n` units `each` apart, gaps eased from wide to tight, in the given order, kept inside the unit's limits. */
+export function staggerStarts(n: number, each: number, order: Preset["order"], seed: number, unit: StaggerUnit): number[] {
+ if (n <= 1 || each <= 0) return Array(n).fill(0);
+ const [lo, hi] = STAGGER_LIMITS[unit];
+ const rank: number[] = Array.from({ length: n }, (_, i) => i);
+ if (order === "reverse") rank.reverse();
+ else if (order === "centre") rank.sort((a, b) => Math.abs(a - (n - 1) / 2) - Math.abs(b - (n - 1) / 2) || a - b);
+ else if (order === "seeded") rank.sort((a, b) => rng(seed, "order", a) - rng(seed, "order", b));
+ const out = Array(n).fill(0);
+ let at = 0;
+ rank.forEach((unitIndex, r) => {
+ if (r > 0) at += limit(each * (1.25 - (0.45 * (r - 1)) / Math.max(1, n - 2)), [lo + 2e-6, hi - 2e-6]);
+ out[unitIndex] = round6(at);
+ });
+ return out;
+}
+
+/** The units a preset moves, with their pieces at rest. */
+interface RawUnit {
+ kind: UnitKind;
+ line: number;
+ text: string;
+ pieces: Piece[];
+}
+
+function unitsOf(set: TypeSet, kind: UnitKind, perLetter: boolean): RawUnit[] {
+ const glyphPieces = (from: number, to: number, line: number): Piece[] => {
+ const l = set.lines[line];
+ const first = l.glyphs ? l.glyphs[0] : 0;
+ return set.glyphs.slice(from, to).map((g, k) => ({ text: g.text, gap: g.gap, x: g.x, y: g.y, w: g.w, line, ord: from + k - first + countSpacesBefore(set, line, from + k), glyph: from + k }));
+ };
+ const wordPieces = (wi: number): Piece[] => {
+ const w = set.words[wi];
+ if (perLetter && w.glyphs) return glyphPieces(w.glyphs[0], w.glyphs[1], w.line);
+ return [{ text: w.text, gap: w.gap, x: w.x, y: w.y, w: w.w, line: w.line, ord: -1, glyph: -1 }];
+ };
+ const linePieces = (li: number): Piece[] => {
+ const l = set.lines[li];
+ if (perLetter && l.glyphs) return glyphPieces(l.glyphs[0], l.glyphs[1], li);
+ if (perLetter) return Array.from({ length: l.words[1] - l.words[0] }, (_, k) => wordPieces(l.words[0] + k)).flat();
+ // A tracked line, or one whose word spaces were opened up, is drawn in pieces so it lands exactly on its layout.
+ if (set.tracking !== 0 && l.glyphs) return glyphPieces(l.glyphs[0], l.glyphs[1], li);
+ if (set.tracking !== 0 || set.spaceExtra > 0) return Array.from({ length: l.words[1] - l.words[0] }, (_, k) => wordPieces(l.words[0] + k)).flat();
+ return [{ text: l.text, gap: set.words[l.words[0]]?.gap ?? l.gap, x: l.x, y: l.y, w: l.w, line: li, ord: -1, glyph: -1 }];
+ };
+ switch (kind) {
+ case "glyph":
+ return set.lines.flatMap((l, li): RawUnit[] => {
+ if (l.glyphs) return set.glyphs.slice(l.glyphs[0], l.glyphs[1]).map((g, k) => ({ kind: "glyph" as const, line: li, text: g.text, pieces: glyphPieces(l.glyphs![0] + k, l.glyphs![0] + k + 1, li) }));
+ return Array.from({ length: l.words[1] - l.words[0] }, (_, k) => ({ kind: "word" as const, line: li, text: set.words[l.words[0] + k].text, pieces: wordPieces(l.words[0] + k) }));
+ });
+ case "word":
+ return set.words.map((w, wi) => ({ kind: "word" as const, line: w.line, text: w.text, pieces: wordPieces(wi) }));
+ case "line":
+ return set.lines.map((l, li) => ({ kind: "line" as const, line: li, text: l.text, pieces: linePieces(li) }));
+ case "block":
+ return [{ kind: "block" as const, line: 0, text: set.text, pieces: set.lines.flatMap((_, li) => linePieces(li)) }];
+ }
+}
+
+/** Spaces in a line before a letter (tracking also follows a space). */
+function countSpacesBefore(set: TypeSet, line: number, glyph: number): number {
+ const l = set.lines[line];
+ if (!l.glyphs) return 0;
+ let n = 0;
+ for (let k = l.glyphs[0] + 1; k <= glyph; k++) n += [...set.glyphs[k].gap].length;
+ return n;
+}
+
+const boxOfPieces = (pieces: Piece[]): { x: number; w: number } => {
+ const x0 = Math.min(...pieces.map((p) => p.x));
+ const x1 = Math.max(...pieces.map((p) => p.x + p.w));
+ return { x: x0, w: x1 - x0 };
+};
+
+/** The clip a line's units rise inside: its ink, with room for accents above, descenders below and overhangs. */
+export function lineClip(set: TypeSet, line: number): Box {
+ const l = set.lines[line];
+ const em = set.size;
+ const top = Math.min(l.ink.y, l.y + set.cap.top) - 0.12 * em;
+ const bottom = Math.max(l.ink.y + l.ink.h, l.baseline) + 0.04 * em;
+ return { x: l.x - 0.3 * em, y: top, w: l.w + 0.6 * em, h: bottom - top };
+}
+
+/** Plan a field's motion: units, their starts, the events, and when it settles and leaves. */
+export function planType(id: string, set: TypeSet, motion: TextMotion, frame: { w: number; h: number }): TypePlan {
+ const preset = PRESETS[motion.in];
+ const exit = PRESETS[motion.out ?? motion.in];
+ const speed = Math.min(1.4, Math.max(0.7, motion.speed ?? 1));
+ const options: PresetOptions = { seed: motion.seed ?? 7, intensity: clamp(motion.intensity ?? 1), hero: !!motion.hero, rate: motion.rate ?? 20, beat: motion.beat ?? 0.5 };
+ // Tracking that moves needs letters to move apart, so the unit is drawn letter by letter.
+ // (A whole line drawn at once has no letter spacing, so tracked type is drawn letter by letter too.)
+ const perLetter = preset.unit === "glyph" || !!preset.widest?.tracking || set.tracking !== 0;
+ const raw = unitsOf(set, preset.unit, perLetter);
+ const em = set.size;
+ const lh = set.lineHeight;
+ const capH = set.cap.bottom - set.cap.top;
+ const infos: UnitInfo[] = raw.map((u, index) => {
+ const b = boxOfPieces(u.pieces);
+ const line = set.lines[u.line];
+ const lines = u.kind === "block" ? set.lines : [line];
+ const y = u.kind === "block" ? set.box.y : line.y;
+ const h = u.kind === "block" ? set.box.h : lh;
+ const inkTop = Math.min(...lines.map((l) => l.ink.y));
+ const inkBottom = Math.max(...lines.map((l) => l.ink.y + l.ink.h));
+ const clip = lineClip(set, u.line);
+ return {
+ kind: u.kind,
+ index,
+ count: raw.length,
+ line: u.line,
+ lines: set.lines.length,
+ text: u.text,
+ x: b.x,
+ y,
+ w: b.w,
+ h,
+ ink: { x: b.x, y: inkTop, w: b.w, h: inkBottom - inkTop },
+ baseline: u.kind === "block" ? set.lines[set.lines.length - 1].baseline : line.baseline,
+ em,
+ lh,
+ cap: capH,
+ block: set.box,
+ frame,
+ clear: { down: clip.y + clip.h - inkTop + 0.02 * em, up: inkBottom - clip.y + 0.02 * em },
+ ...(/\p{Nd}/u.test(u.text) && { lead: !raw.slice(0, index).some((r) => r.line === u.line && /\p{Nd}/u.test(r.text)) }),
+ };
+ });
+
+ // Starts: by line for presets that let each line follow the one before, else across all units.
+ const each = preset.each / speed;
+ const dur = (options.hero && preset.heroDur ? preset.heroDur : preset.dur) / speed;
+ const unitName = preset.stagger ?? unitStagger[preset.unit];
+ const starts: number[] = Array(infos.length).fill(0);
+ if (!preset.together) {
+ if (preset.lineOverlap !== undefined && set.lines.length > 1) {
+ let lineStart = 0;
+ for (let li = 0; li < set.lines.length; li++) {
+ const members = infos.filter((u) => u.line === li);
+ const local = staggerStarts(members.length, each, preset.order, options.seed, unitName);
+ members.forEach((u, k) => (starts[u.index] = round6(lineStart + local[k])));
+ const span = Math.max(0, ...local) + dur;
+ lineStart += span * preset.lineOverlap;
+ }
+ } else staggerStarts(infos.length, each, preset.order, options.seed, unitName).forEach((s, i) => (starts[i] = s));
+ }
+ const enterSpan = (i: number): number => {
+ if (preset.id === "beat-cut") return infos[i].count * options.beat / speed + (6 * F) / speed;
+ if (preset.id === "type-on") return infos.length / options.rate / speed;
+ if (preset.id === "scramble") return scrambleLock(infos[infos.length - 1]) / speed;
+ if (preset.id === "stomp") return (12 * F) / speed;
+ if (preset.id === "split-flap") return (0.05 * 8) / speed;
+ return dur;
+ };
+ const settled = round6(motion.at + Math.max(0, ...infos.map((_, i) => starts[i] + enterSpan(i))));
+
+ // Exit: first unit first, in about two thirds of the entrance's time.
+ const exitDur = exit.exitDur / speed;
+ let exitStarts: number[] | null = null;
+ if (motion.exitAt !== undefined) {
+ const n = infos.length;
+ const exitEach = exit.together ? 0 : (exit.each * 0.68) / speed;
+ exitStarts = exit.together || exitEach <= 0 ? Array(n).fill(0) : staggerStarts(n, exitEach, "ease", options.seed, unitName);
+ }
+ const gone = exitStarts && motion.exitAt !== undefined ? round6(motion.exitAt + Math.max(...exitStarts) + exitDur) : null;
+
+ const units: PlannedUnit[] = infos.map((info, i) => ({ info, start: round6(motion.at + starts[i]), exitStart: exitStarts && motion.exitAt !== undefined ? round6(motion.exitAt + exitStarts[i]) : null, pieces: raw[i].pieces }));
+
+ // Events, for the timeline (and the timing rules).
+ const events: MotionEvent[] = [];
+ const kindOf = (k: EventKind, d: number): EventKind => (k === "enter" && d > DURATION_LIMITS.enter[1] + 1e-9 ? "hero" : k);
+ const curveOf = preset.curve as CurveName;
+ if (preset.together || infos.length === 1) {
+ const span = Math.max(...infos.map((_, i) => enterSpan(i)));
+ const kind = kindOf(preset.kind, span);
+ events.push({ id, kind, start: round6(motion.at), dur: round6(limit(span, DURATION_LIMITS[kind])), curve: curveOf });
+ } else {
+ const order = units.map((u, i) => ({ u, i })).sort((a, b) => a.u.start - b.u.start || a.i - b.i);
+ for (const { u, i } of order) {
+ const kind = kindOf(preset.kind, dur);
+ const grp = preset.lineOverlap !== undefined && set.lines.length > 1 ? `${id}.l${u.info.line}` : id;
+ events.push({ id: `${id}.${i}`, kind, start: u.start, dur: round6(limit(dur, DURATION_LIMITS[kind])), curve: curveOf, group: grp, unit: unitName });
+ }
+ }
+ if (preset.id === "stomp") for (const [i, u] of units.entries()) events.push({ id: `${id}.${i}.ring`, kind: "fade", start: round6(u.start + (5 * F) / speed), dur: round6((7 * F) / speed), curve: "linear" });
+ if (exitStarts && motion.exitAt !== undefined) {
+ if (exit.together || infos.length === 1) events.push({ id: `${id}.exit`, kind: "exit", start: round6(motion.exitAt), dur: round6(limit(exitDur, DURATION_LIMITS.exit)), curve: "exit" });
+ else {
+ const order = units.map((u, i) => ({ u, i })).sort((a, b) => a.u.exitStart! - b.u.exitStart! || a.i - b.i);
+ for (const { u, i } of order) events.push({ id: `${id}.exit.${i}`, kind: "exit", start: u.exitStart!, dur: round6(limit(exitDur, DURATION_LIMITS.exit)), curve: "exit", group: `${id}.exit`, unit: unitName });
+ }
+ }
+ return { id, set, motion, preset, exit, options, units, events, settled, gone, loopStart: motion.loopAt ?? round6(settled + 0.15), frame, speed };
+}
+
+const isRest = (p: Pose): boolean =>
+ p.dx === 0 && p.dy === 0 && p.sx === 1 && p.sy === 1 && p.rot === 0 && p.skewX === 0 && p.opacity === 1 && p.blur === 0 && p.shade === 0 && p.tracking === undefined && p.weight === undefined && !p.shown && !p.reveal && !p.bar && !p.ghost && p.glow === undefined && p.fold === undefined && !p.flap && p.roll === undefined && !p.split;
+
+/** A unit's pose at `t` (absolute): before, during and after its entrance, then its exit. */
+export function poseAt(plan: TypePlan, i: number, t: number): Pose {
+ const u = plan.units[i];
+ if (u.exitStart !== null && t >= u.exitStart) {
+ const d = plan.exit.exitDur / plan.speed;
+ const e = d > 0 ? (t - u.exitStart) / d : 1;
+ if (e >= 1) return { ...REST, opacity: 0 };
+ return plan.exit.exit(clamp(e), u.info, plan.options);
+ }
+ return plan.preset.enter((t - u.start) * plan.speed, u.info, plan.options);
+}
+
+/** The point a unit turns and scales about. */
+function pivotOf(p: Pivot, u: UnitInfo, set: TypeSet): [number, number] {
+ switch (p) {
+ case "centre":
+ return [u.x + u.w / 2, u.ink.y + u.ink.h / 2];
+ case "baseline-left":
+ return [u.x, u.baseline];
+ case "baseline-centre":
+ return [u.x + u.w / 2, u.baseline];
+ case "bottom-left":
+ return [u.x, u.ink.y + u.ink.h];
+ case "midline":
+ return [u.x + u.w / 2, u.y + (set.cap.top + set.cap.bottom) / 2];
+ }
+}
+
+/** translate(dx, dy) · about the pivot: rotate, shear, scale. */
+export function poseMatrix(p: Pick<Pose, "dx" | "dy" | "sx" | "sy" | "rot" | "skewX">, px: number, py: number): Matrix | undefined {
+ if (p.dx === 0 && p.dy === 0 && p.sx === 1 && p.sy === 1 && p.rot === 0 && p.skewX === 0) return undefined;
+ const c = Math.cos(p.rot);
+ const s = Math.sin(p.rot);
+ const R: Matrix = [c, s, -s, c, 0, 0];
+ const K: Matrix = [1, 0, p.skewX, 1, 0, 0];
+ const S: Matrix = [p.sx, 0, 0, p.sy, 0, 0];
+ const M = multiply(multiply(R, K), S);
+ return multiply([1, 0, 0, 1, p.dx + px, p.dy + py], multiply(M, [1, 0, 0, 1, -px, -py]));
+}
+
+/** A paint taken toward black. */
+function shaded(p: Paint, k: number): Paint {
+ if (k <= 0) return p;
+ if (typeof p === "string") return /^#[0-9a-f]{3,6}$/i.test(p) ? mixHex(p, "#000000", k) : p;
+ return { ...p, stops: p.stops.map((s) => ({ ...s, color: /^#[0-9a-f]{3,6}$/i.test(s.color) ? mixHex(s.color, "#000000", k) : s.color })) };
+}
+
+/** The pieces' places for this pose's tracking and weight (letters move apart, centred lines stay centred). */
+function placed(plan: TypePlan, pieces: Piece[], p: Pose): { piece: Piece; x: number; font: string }[] {
+ const set = plan.set;
+ const tracking = p.tracking !== undefined ? set.tracking + p.tracking : set.tracking;
+ const weight = p.weight !== undefined ? weightFor(set.family, Math.round(p.weight), set.style) : set.weight;
+ const font = weight === set.weight ? set.font : fontOf(set.family, set.size, weight, set.style);
+ const dT = (tracking - set.tracking) * set.size;
+ if (dT === 0 && font === set.font) return pieces.map((piece) => ({ piece, x: piece.x, font }));
+ return pieces.map((piece) => {
+ if (piece.ord < 0) return { piece, x: piece.x, font };
+ const line = set.lines[piece.line];
+ const n = line.glyphs ? countSpacesBefore(set, piece.line, line.glyphs[1] - 1) + (line.glyphs[1] - line.glyphs[0]) : 1;
+ const grow = dT * Math.max(0, n - 1);
+ const shift = set.align === "centre" ? -grow / 2 : set.align === "right" ? -grow : 0;
+ let x = piece.x + dT * piece.ord + shift;
+ if (font !== set.font) {
+ // A heavier or lighter letter is wider or narrower: the letters before it in the line push it along.
+ const g0 = line.glyphs ? line.glyphs[0] : piece.glyph;
+ let pushed = 0;
+ for (let k = g0; k < piece.glyph; k++) pushed += set.measure(set.glyphs[k].text, font) - set.glyphs[k].w;
+ x += pushed;
+ }
+ return { piece, x, font };
+ });
+}
+
+function runsOf(plan: TypePlan, pieces: Piece[], p: Pose, style: TypeStyle, fill: Paint = style.fill): TextRun[] {
+ return placed(plan, pieces, p).map(({ piece, x, font }) => {
+ const run: TextRun = { text: piece.text, gap: piece.gap, font, x, y: piece.y, fill: shaded(fill, p.shade) };
+ if (style.stroke) run.stroke = { paint: shaded(style.stroke.paint, p.shade), width: style.stroke.width };
+ if (plan.set.dir === "rtl") run.dir = "rtl";
+ if (p.shown && p.shown !== piece.text) {
+ run.shown = p.shown;
+ run.x = x + (piece.w - plan.set.measure(p.shown, font)) / 2;
+ }
+ return run;
+ });
+}
+
+const textNode = (field: string, runs: TextRun[], decor = false): DisplayNode => ({ type: "text", field, runs, ...(decor && { decor: true }) });
+
+/** A soft horizontal wipe as a group mask. */
+function revealMask(r: NonNullable<Pose["reveal"]>, box: Box): GroupNode["mask"] | null {
+ const span = box.w;
+ if (r.to - r.feather >= 1 && r.from <= 0) return null;
+ const stops: { at: number; color: string }[] = [];
+ const add = (at: number, a: number) => stops.push({ at: clamp(at), color: `rgba(0,0,0,${a})` });
+ add(r.from - r.feather, 0);
+ add(r.from, 1);
+ add(r.to - r.feather, 1);
+ add(r.to, 0);
+ stops.sort((a, b) => a.at - b.at);
+ return { kind: "linear", x0: box.x, y0: 0, x1: box.x + span, y1: 0, stops, bounds: box };
+}
+
+export interface TypeFrame {
+ nodes: DisplayNode[];
+ /** A nudge for the scene's camera (a stomp's impact), design units. */
+ camera: { x: number; y: number };
+ /** A white flash over the frame (0–0.06). */
+ flash: number;
+ /** Nothing in this field moves at this time. */
+ still: boolean;
+}
+
+/** The field at `t`. */
+export function drawType(plan: TypePlan, style: TypeStyle, t: number): TypeFrame {
+ const { set, preset } = plan;
+ const field = set.field;
+ const poses = plan.units.map((_, i) => poseAt(plan, i, t));
+ const loop: LoopPose = plan.motion.loop && t >= plan.loopStart && (plan.gone === null || t < (plan.motion.exitAt ?? Infinity)) ? loopAt(plan.motion.loop, t - plan.loopStart, { seed: plan.options.seed, period: plan.motion.loopPeriod, every: plan.motion.loopEvery, frameW: plan.frame.w, ...(plan.motion.loopUntil !== undefined && { until: plan.motion.loopUntil - plan.loopStart }) }) : LOOP_REST;
+ const loopStill = loop.s === 1 && loop.rot === 0 && loop.dx === 0 && loop.dy === 0 && loop.sweep === null;
+ const allRest = poses.every(isRest);
+ let camera = { x: 0, y: 0 };
+ let flash = 0;
+
+ let nodes: DisplayNode[];
+ if (allRest) {
+ nodes = [...staticExtras(plan, style), textNode(field, plan.units.flatMap((u) => runsOf(plan, u.pieces, REST, style)))];
+ } else {
+ nodes = [];
+ for (const [i, u] of plan.units.entries()) {
+ const p = poses[i];
+ if (preset.id === "stomp" && (u.exitStart === null || t < u.exitStart)) {
+ const local = (t - u.start) * plan.speed;
+ const A = 5 * F;
+ if (local >= A && local < A + 6 * F) {
+ const amp = 8 * Math.exp((-5 * (local - A)) / (6 * F)) * plan.options.intensity;
+ const ang = rng(plan.options.seed, "nudge", i) * Math.PI * 2;
+ camera = { x: camera.x + amp * Math.cos(ang), y: camera.y + amp * Math.sin(ang) };
+ if (plan.motion.flash && local < A + 2 * F) flash = 0.06;
+ }
+ }
+ if (p.opacity <= 0.001 && !p.bar) continue;
+ nodes.push(...unitNodes(plan, i, p, style, t));
+ }
+ if (preset.id === "scramble") nodes = sliced(plan, nodes, t);
+ }
+ if (!loopStill) nodes = looped(plan, nodes, loop, style);
+ return { nodes, camera, flash, still: allRest && loopStill };
+}
+
+/** Tiles and chips that stay at rest (split-flap's tiles, cut-paper's chips). */
+function staticExtras(plan: TypePlan, style: TypeStyle): DisplayNode[] {
+ if (plan.preset.id === "split-flap" && style.tile) return plan.units.filter((u) => flips(u.info.text)).map((u) => tileNode(plan, u.info, style.tile!));
+ if (plan.preset.id === "cut-paper" && style.chip) return plan.units.map((u) => chipNodes(plan, u.info, style.chip!)).flat();
+ return [];
+}
+
+function unitNodes(plan: TypePlan, i: number, p: Pose, style: TypeStyle, t: number): DisplayNode[] {
+ const { set, preset } = plan;
+ const u = plan.units[i];
+ const info = u.info;
+ const field = set.field;
+ const [px, py] = pivotOf(preset.pivot, info, set);
+ const m = poseMatrix(p, px, py);
+ const out: DisplayNode[] = [];
+ const em = set.size;
+
+ // Echo: the unit a few frames back, fading, collapsing into it at rest.
+ if (plan.motion.echo && !isRest(p)) {
+ const alphas = [0.5, 0.3, 0.15, 0.08, 0.04].slice(0, Math.min(5, Math.max(1, plan.motion.echo)));
+ alphas.forEach((a, k) => {
+ const q = poseAt(plan, i, t - (k + 1) * 2.5 * F);
+ if (q.dx === p.dx && q.dy === p.dy && q.sx === p.sx && q.sy === p.sy && q.rot === p.rot) return;
+ out.push(group([textNode(field, runsOf(plan, u.pieces, { ...q, shown: undefined }, style), true)], { transform: poseMatrix(q, px, py), opacity: a * q.opacity }));
+ });
+ }
+
+ let body: DisplayNode[] = [];
+ if (p.flap) body = flapNodes(plan, u, p, style);
+ else if (p.roll !== undefined) body = rollNodes(plan, u, p, style);
+ else if (p.fold !== undefined) body = foldNodes(plan, u, p, style);
+ else body = [textNode(field, runsOf(plan, u.pieces, p, style))];
+
+ // A cut-paper chip moves with its word.
+ if (preset.id === "cut-paper" && style.chip) body = [...chipNodes(plan, info, style.chip), ...body];
+ if (preset.id === "split-flap" && style.tile && !p.flap && flips(info.text)) body = [tileNode(plan, info, style.tile), ...body];
+
+ // Glow (neon): cached blurred copies behind, in the glow colour.
+ if (p.glow !== undefined && p.glow > 0 && style.glow) {
+ const levels: [number, number][] = [
+ [0.05, 0.9],
+ [0.3, 0.6],
+ [0.8, 0.4],
+ ];
+ const glows = levels.map(([b, a]) => {
+ const blur = b * em;
+ const pad = blur * 2.5;
+ const bounds = { x: info.x - pad, y: info.ink.y - pad, w: info.w + 2 * pad, h: info.ink.h + 2 * pad };
+ return group([textNode(field, runsOf(plan, u.pieces, REST, style, style.glow!), true)], { soften: blur, blend: "lighter", opacity: a * p.glow!, cache: { key: `glow|${set.font}|${info.text}|${style.glow}|${b}`, bounds } });
+ });
+ body = [...glows, ...body];
+ }
+
+ // Colour split while a scramble runs (dark grounds only).
+ if (p.split && plan.motion.dark) {
+ const half = p.split / 2;
+ body = [
+ group([textNode(field, runsOf(plan, u.pieces, p, style, "#ff3355"), true)], { transform: [1, 0, 0, 1, -half, 0], blend: "screen", opacity: 0.7 }),
+ group([textNode(field, runsOf(plan, u.pieces, p, style, "#33ddff"), true)], { transform: [1, 0, 0, 1, half, 0], blend: "screen", opacity: 0.7 }),
+ ...body,
+ ];
+ }
+
+ // Blur-in: cross-faded cached blur levels (never a live blur per frame).
+ let content: DisplayNode[] = body;
+ if (p.blur > 0.01) {
+ const levels = [0, 2, 4, 8, 16];
+ const b = Math.min(16, p.blur);
+ let k = 0;
+ while (k < levels.length - 2 && levels[k + 1] < b) k++;
+ const lo = levels[k];
+ const hi = levels[k + 1];
+ const mixHi = (b - lo) / (hi - lo);
+ const pad = 2.5 * hi + 0.2 * em;
+ const bounds = { x: info.x - pad, y: info.ink.y - pad, w: info.w + 2 * pad, h: info.ink.h + 2 * pad };
+ const layer = (level: number, a: number): DisplayNode => group(body, { opacity: a, ...(level > 0 && { soften: level, cache: { key: `blur|${set.font}|${info.text}|${JSON.stringify(style.fill)}|${level}`, bounds } }) });
+ content = [layer(lo, 1 - mixHi), layer(hi, mixHi)];
+ }
+
+ // Stomp's ring: a copy growing away from the impact.
+ if (p.ghost && p.ghost.a > 0) {
+ const g = poseMatrix({ dx: 0, dy: 0, sx: p.ghost.s, sy: p.ghost.s, rot: 0, skewX: 0 }, px, py);
+ out.push(group([textNode(field, runsOf(plan, u.pieces, REST, style), true)], { transform: g, opacity: p.ghost.a }));
+ }
+
+ const g: GroupNode = group(content, { ...(m && { transform: m }), ...(p.opacity < 1 && { opacity: p.opacity }) });
+ if (p.reveal) {
+ const pad = 0.3 * em;
+ const box = { x: info.x - pad, y: info.ink.y - 0.3 * em, w: info.w + 2 * pad, h: info.ink.h + 0.6 * em };
+ const mask = revealMask({ ...p.reveal, from: p.reveal.from, to: p.reveal.to }, box);
+ if (mask) g.mask = mask;
+ else if (p.reveal.to <= p.reveal.from) return out;
+ }
+ let node: DisplayNode = g;
+ if (p.clip) node = group([g], { clip: { type: "rect", ...lineClip(set, info.line) } });
+ out.push(node);
+
+ // Bar-swipe's bar, over the line.
+ if (p.bar && p.bar.to > p.bar.from && style.bar) {
+ const l = set.lines[info.line];
+ const capH = set.cap.bottom - set.cap.top;
+ const padX = 0.06 * em;
+ const x0 = info.x - padX + p.bar.from * (info.w + 2 * padX);
+ const x1 = info.x - padX + p.bar.to * (info.w + 2 * padX);
+ out.push({ type: "rect", x: x0, y: l.y + set.cap.top - 0.025 * capH, w: x1 - x0, h: 1.05 * capH, fill: style.bar });
+ }
+
+ // Type-on's caret: solid while typing, then two blinks, then gone.
+ if (plan.preset.id === "type-on" && i === lastShown(plan, t)) {
+ const end = plan.units[0].start + plan.units.length / plan.options.rate / plan.speed;
+ const after = t - end;
+ const on = after < 0 || (after < 1.06 && Math.floor(after / 0.265) % 2 === 1);
+ if (on) {
+ const capH = set.cap.bottom - set.cap.top;
+ out.push({ type: "rect", x: info.x + info.w + 0.04 * em, y: info.y + set.cap.top - 0.05 * capH, w: Math.max(2, 0.06 * em), h: capH * 1.15, fill: style.caret ?? (typeof style.fill === "string" ? style.fill : "#ffffff") });
+ }
+ }
+ return out;
+}
+
+/** The last letter typed so far. */
+function lastShown(plan: TypePlan, t: number): number {
+ let last = -1;
+ for (let i = 0; i < plan.units.length; i++) if (poseAt(plan, i, t).opacity > 0) last = i;
+ return last;
+}
+
+/** A split-flap tile behind a letter. */
+/** Whether a split-flap slot flips (letters and figures); separators such as ":" stand free, with no tile. */
+const flips = (text: string): boolean => /^[\p{L}\p{Nd}]$/u.test(text);
+
+/** The widest flipping letter of a plan (every tile is that wide, so a narrow "1" gets the same tile as an "8"). */
+const tileWidths = new WeakMap<TypePlan, number>();
+function widestTile(plan: TypePlan): number {
+ let w = tileWidths.get(plan);
+ if (w === undefined) {
+ w = Math.max(0, ...plan.units.filter((x) => flips(x.info.text)).map((x) => x.info.w));
+ tileWidths.set(plan, w);
+ }
+ return w;
+}
+
+/** A flap tile's box round a letter (8 % of the letter's size in padding a side), one width for the whole row. */
+function tileBox(plan: TypePlan, u: Pick<UnitInfo, "x" | "y" | "w">): Box {
+ const { set } = plan;
+ const em = set.size;
+ const capH = set.cap.bottom - set.cap.top;
+ const w = Math.max(u.w, widestTile(plan));
+ return { x: u.x + u.w / 2 - w / 2 - 0.08 * em, y: u.y + set.cap.top - 0.2 * capH, w: w + 0.16 * em, h: capH * 1.4 };
+}
+
+/** A flap tile: its top half a step lighter than its bottom, a hinge line across the middle. */
+function tileShape(b: Box, r: number, fill: string, em: number): DisplayNode[] {
+ const mid = b.y + b.h / 2;
+ const hinge = Math.max(1, em * 0.02);
+ const light = /^#[0-9a-f]{6}$/i.test(fill) ? mixHex(fill, "#ffffff", 0.06) : fill;
+ const dark = /^#[0-9a-f]{6}$/i.test(fill) ? mixHex(fill, "#000000", 0.12) : fill;
+ return [
+ group([{ type: "rect", ...b, r, fill: light }], { clip: { type: "rect", x: b.x - 1, y: b.y - 1, w: b.w + 2, h: mid - b.y + 1 } }),
+ group([{ type: "rect", ...b, r, fill: dark }], { clip: { type: "rect", x: b.x - 1, y: mid, w: b.w + 2, h: b.y + b.h - mid + 1 } }),
+ { type: "rect", x: b.x, y: mid - hinge / 2, w: b.w, h: hinge, fill: withAlpha("#000000", 0.45) },
+ ];
+}
+
+function tileNode(plan: TypePlan, u: UnitInfo, fill: string): DisplayNode {
+ return group(tileShape(tileBox(plan, u), 0.04 * plan.set.size, fill, plan.set.size));
+}
+
+/** A tile mid-flip: halves of the leaving and arriving letters, the moving flap squeezed about the middle. */
+function flapNodes(plan: TypePlan, u: PlannedUnit, p: Pose, style: TypeStyle): DisplayNode[] {
+ const { set } = plan;
+ const info = u.info;
+ const f = p.flap!;
+ const em = set.size;
+ const capH = set.cap.bottom - set.cap.top;
+ const tb = tileBox(plan, info);
+ const top = tb.y;
+ const mid = tb.y + tb.h / 2;
+ const bottom = tb.y + tb.h;
+ const x = tb.x;
+ const w = tb.w;
+ void capH;
+ const letter = (c: string) => [textNode(set.field, runsOf(plan, u.pieces, { ...REST, shown: c }, style))];
+ const half = (c: string, upper: boolean, sy = 1): DisplayNode => {
+ const clip = upper ? { type: "rect" as const, x, y: top, w, h: mid - top } : { type: "rect" as const, x, y: mid, w, h: bottom - mid };
+ const inner: DisplayNode[] = [...(style.tile && flips(info.text) ? tileShape(tb, 0.04 * em, style.tile, em) : []), ...letter(c)];
+ const m: Matrix | undefined = sy === 1 ? undefined : [1, 0, 0, sy, 0, mid - sy * mid];
+ return group([group(inner, { clip })], m ? { transform: m } : {});
+ };
+ const out: DisplayNode[] = [half(f.to, true), half(f.from, false)];
+ if (f.phase < 0.5) out.push(half(f.from, true, Math.max(0.001, Math.cos(f.phase * Math.PI))));
+ else out.push(half(f.to, false, Math.max(0.001, -Math.cos(f.phase * Math.PI))));
+ return out;
+}
+
+/** A rolling figure: the two figures either side of its place on the strip, in a window that fades at its ends. */
+function rollNodes(plan: TypePlan, u: PlannedUnit, p: Pose, style: TypeStyle): DisplayNode[] {
+ const { set } = plan;
+ const info = u.info;
+ const v = p.roll!;
+ const base = Math.floor(v);
+ const frac = v - base;
+ const lh = set.lineHeight;
+ const capH = set.cap.bottom - set.cap.top;
+ // The window: the cap band and 10 % either side, fading over its outer 18 % (a neighbour never shows more than a sliver).
+ const win = { x: info.x - 0.1 * set.size, y: info.y + set.cap.top - 0.1 * capH, w: info.w + 0.2 * set.size, h: capH * 1.2 };
+ const from = p.rollFrom ?? -Infinity;
+ const digit = (d: number, dy: number): DisplayNode[] => (d < from ? [] : [group([textNode(set.field, runsOf(plan, u.pieces, { ...REST, shown: String(((d % 10) + 10) % 10) }, style))], { transform: [1, 0, 0, 1, 0, dy] })]);
+ const mask: GroupNode["mask"] = { kind: "linear", x0: 0, y0: win.y, x1: 0, y1: win.y + win.h, stops: [{ at: 0, color: "rgba(0,0,0,0)" }, { at: 0.18, color: "rgba(0,0,0,1)" }, { at: 0.82, color: "rgba(0,0,0,1)" }, { at: 1, color: "rgba(0,0,0,0)" }], bounds: win };
+ const shown = [...digit(base, -frac * lh), ...digit(base + 1, (1 - frac) * lh)];
+ return shown.length ? [group(shown, { clip: { type: "rect", ...win }, mask })] : [];
+}
+
+/** A line whose top half hinges down from flat. */
+function foldNodes(plan: TypePlan, u: PlannedUnit, p: Pose, style: TypeStyle): DisplayNode[] {
+ const { set } = plan;
+ const info = u.info;
+ const em = set.size;
+ const mid = info.y + (set.cap.top + set.cap.bottom) / 2;
+ const x = info.x - 0.3 * em;
+ const w = info.w + 0.6 * em;
+ const top = info.ink.y - 0.2 * em;
+ const bottom = info.ink.y + info.ink.h + 0.2 * em;
+ const runs = (shade: number) => [textNode(set.field, runsOf(plan, u.pieces, { ...REST, shade }, style))];
+ const sy = Math.max(0.001, Math.cos(p.fold!));
+ const out: DisplayNode[] = [
+ group(runs(0), { clip: { type: "rect", x, y: mid, w, h: bottom - mid } }),
+ group([group(runs(p.shade), { clip: { type: "rect", x, y: top, w, h: mid - top } })], { transform: [1, 0, 0, sy, 0, mid - sy * mid] }),
+ ];
+ const s = Math.sin(p.fold!);
+ if (s > 0.01) out.push({ type: "rect", x, y: mid, w, h: 0.12 * em, fill: { kind: "linear", x0: 0, y0: mid, x1: 0, y1: mid + 0.12 * em, stops: [{ at: 0, color: `rgba(0,0,0,${0.25 * s})` }, { at: 1, color: "rgba(0,0,0,0)" }] } });
+ return out;
+}
+
+/** A torn paper chip under a word, with its shadow and a strip of tape (seeded, the same every frame). */
+function chipNodes(plan: TypePlan, u: UnitInfo, paper: string): DisplayNode[] {
+ const { set } = plan;
+ const em = set.size;
+ const seed = plan.options.seed;
+ const x0 = u.x - 0.22 * em;
+ const x1 = u.x + u.w + 0.22 * em;
+ const y0 = u.ink.y - 0.16 * em;
+ const y1 = u.ink.y + u.ink.h + 0.16 * em;
+ const j = (k: string) => (rng(seed, "chip", u.index, k) * 2 - 1) * 0.06 * em;
+ const pts: [number, number][] = [
+ [x0 + j("a"), y0 + j("b")],
+ [(x0 + x1) / 2 + j("c"), y0 + j("d")],
+ [x1 + j("e"), y0 + j("f")],
+ [x1 + j("g"), (y0 + y1) / 2 + j("h")],
+ [x1 + j("i"), y1 + j("j")],
+ [(x0 + x1) / 2 + j("k"), y1 + j("l")],
+ [x0 + j("m"), y1 + j("n")],
+ [x0 + j("o"), (y0 + y1) / 2 + j("p")],
+ ];
+ const d = `M${pts.map(([x, y]) => `${x.toFixed(1)} ${y.toFixed(1)}`).join("L")}Z`;
+ const pad = 0.2 * em;
+ const tapeW = 0.9 * em;
+ const tapeH = 0.26 * em;
+ const tx = (x0 + x1) / 2;
+ const ang = (rng(seed, "tape", u.index) * 2 - 1) * 12 * (Math.PI / 180);
+ const c = Math.cos(ang);
+ const s = Math.sin(ang);
+ return [
+ group([{ type: "path", d, fill: "rgba(0,0,0,0.22)" }], { transform: [1, 0, 0, 1, 0, 0.06 * em], soften: 0.08 * em, cache: { key: `chip-shadow|${d}`, bounds: { x: x0 - pad, y: y0 - pad, w: x1 - x0 + 2 * pad, h: y1 - y0 + 2 * pad } } }),
+ { type: "path", d, fill: paper, stroke: { paint: "rgba(255,255,255,0.6)", width: 1 } },
+ group([{ type: "rect", x: -tapeW / 2, y: -tapeH / 2, w: tapeW, h: tapeH, fill: "rgba(255,255,255,0.7)" }], { transform: [c, s, -s, c, tx, y0] }),
+ ];
+}
+
+/** A scramble's glitch: in two-frame bursts the block is cut into bands shifted sideways. */
+function sliced(plan: TypePlan, nodes: DisplayNode[], t: number): DisplayNode[] {
+ const local = (t - plan.motion.at) * plan.speed;
+ const end = scrambleLock(plan.units[plan.units.length - 1].info);
+ if (local < 0 || local >= end) return nodes;
+ const step = Math.floor(local / (2 * F) + 1e-6);
+ const seed = plan.options.seed;
+ if (rng(seed, "slice-on", step) > 0.4) return nodes;
+ const box = plan.set.ink;
+ const n = 3 + Math.floor(rng(seed, "slices", step) * 3);
+ const pad = plan.set.size * 0.4;
+ const out: DisplayNode[] = [];
+ for (let k = 0; k < n; k++) {
+ const y0 = box.y + (box.h * k) / n;
+ const dx = (rng(seed, "slice-dx", step, k) * 2 - 1) * (0.02 + 0.04 * rng(seed, "slice-amp", step, k)) * plan.frame.w * plan.options.intensity;
+ out.push(group(nodes, { clip: { type: "rect", x: box.x - pad - Math.abs(dx), y: k === 0 ? box.y - pad : y0, w: box.w + 2 * pad + 2 * Math.abs(dx), h: k === n - 1 || k === 0 ? box.h / n + pad : box.h / n }, transform: [1, 0, 0, 1, dx, 0] }));
+ }
+ return out;
+}
+
+/** A loop applied to the whole field: a breath, a pulse, a wiggle, or a light band crossing the letters. */
+function looped(plan: TypePlan, nodes: DisplayNode[], loop: LoopPose, style: TypeStyle): DisplayNode[] {
+ const box = plan.set.ink;
+ const cx = box.x + box.w / 2;
+ const cy = box.y + box.h / 2;
+ const m = poseMatrix({ dx: loop.dx, dy: loop.dy, sx: loop.s, sy: loop.s, rot: loop.rot, skewX: 0 }, cx, cy);
+ let out: DisplayNode[] = m ? [group(nodes, { transform: m })] : nodes;
+ if (loop.sweep !== null) {
+ const pad = plan.set.size * 0.3;
+ const bandW = Math.max(0.18 * box.w, plan.set.size * 0.4);
+ const x = box.x - bandW + loop.sweep * (box.w + 2 * bandW);
+ const colour = style.sweep ?? "#ffffff";
+ // A band that reads at 7.5 fps and on a phone: never fainter than 0.4.
+ const a = Math.max(0.4, style.sweepAlpha ?? 0.45);
+ const band: DisplayNode = {
+ type: "rect",
+ x: x - bandW / 2,
+ y: box.y - pad,
+ w: bandW,
+ h: box.h + 2 * pad,
+ fill: { kind: "linear", x0: x - bandW / 2, y0: 0, x1: x + bandW / 2, y1: 0, stops: [{ at: 0, color: withAlpha(colour, 0) }, { at: 0.5, color: withAlpha(colour, a) }, { at: 1, color: withAlpha(colour, 0) }] },
+ };
+ const tilt: Matrix = poseMatrix({ dx: 0, dy: 0, sx: 1, sy: 1, rot: 0, skewX: Math.tan((20 * Math.PI) / 180) }, x, cy) ?? IDENTITY;
+ out = [group([...out, group([band], { blend: "source-atop", transform: tilt })], { isolate: { x: box.x - pad - bandW, y: box.y - pad, w: box.w + 2 * pad + 2 * bandW, h: box.h + 2 * pad } })];
+ }
+ return out;
+}
+
+/** The fields' widest moment for a preset (for setType's `widest`). */
+export const widestFor = (id: PresetId): { tracking?: number; scale?: number; weight?: number } | undefined => PRESETS[id].widest;
diff --git a/src/lib/motion/type/faces.generated.ts b/src/lib/motion/type/faces.generated.ts
new file mode 100644
index 00000000..6763159d
--- /dev/null
+++ b/src/lib/motion/type/faces.generated.ts
@@ -0,0 +1,41 @@
+// Generated by scripts/kinetic/build-fonts.py from scripts/kinetic/fonts.json. Do not edit by hand.
+
+import type { KineticFace } from "./faces";
+
+export const KINETIC_UNICODE_RANGE = "U+0020-007E,U+00A0-00FF,U+0100-017F,U+0192,U+0218-021B,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+20A0-20C0,U+2100-2122,U+2190-2199,U+2212,U+2215,U+2605-2606,U+2713,U+FEFF,U+FFFD";
+
+export const KINETIC_FACES: readonly KineticFace[] = [
+ { id: "anton", family: "Kinetic Anton", style: "normal", weight: [400, 400], file: "/fonts/kinetic/anton.woff2", v: "47140a67", bytes: 17424, licence: "/fonts/kinetic/licences/anton-OFL.txt" },
+ { id: "league-gothic", family: "Kinetic League Gothic", style: "normal", weight: [400, 400], file: "/fonts/kinetic/league-gothic.woff2", v: "26c0c6b2", bytes: 11052, licence: "/fonts/kinetic/licences/leaguegothic-OFL.txt" },
+ { id: "league-gothic-condensed", family: "Kinetic League Gothic Condensed", style: "normal", weight: [400, 400], file: "/fonts/kinetic/league-gothic-condensed.woff2", v: "49b83521", bytes: 11180, licence: "/fonts/kinetic/licences/leaguegothic-OFL.txt" },
+ { id: "instrument-serif", family: "Kinetic Instrument Serif", style: "normal", weight: [400, 400], file: "/fonts/kinetic/instrument-serif.woff2", v: "6471f195", bytes: 17472, licence: "/fonts/kinetic/licences/instrumentserif-OFL.txt" },
+ { id: "instrument-serif-italic", family: "Kinetic Instrument Serif", style: "italic", weight: [400, 400], file: "/fonts/kinetic/instrument-serif-italic.woff2", v: "f8c113be", bytes: 18040, licence: "/fonts/kinetic/licences/instrumentserif-OFL.txt" },
+ { id: "geist-mono", family: "Kinetic Geist Mono", style: "normal", weight: [400, 600], file: "/fonts/kinetic/geist-mono.woff2", v: "c076c6d5", bytes: 27788, licence: "/fonts/kinetic/licences/geistmono-OFL.txt" },
+ { id: "big-shoulders", family: "Kinetic Big Shoulders Display", style: "normal", weight: [600, 900], file: "/fonts/kinetic/big-shoulders.woff2", v: "e832024f", bytes: 40116, licence: "/fonts/kinetic/licences/bigshouldersdisplay-OFL.txt" },
+ { id: "archivo-expanded", family: "Kinetic Archivo Expanded", style: "normal", weight: [600, 900], file: "/fonts/kinetic/archivo-expanded.woff2", v: "b2b98788", bytes: 33004, licence: "/fonts/kinetic/licences/archivo-OFL.txt" },
+ { id: "archivo-condensed", family: "Kinetic Archivo Condensed", style: "normal", weight: [700, 900], file: "/fonts/kinetic/archivo-condensed.woff2", v: "9885470a", bytes: 33092, licence: "/fonts/kinetic/licences/archivo-OFL.txt" },
+ { id: "instrument-sans", family: "Kinetic Instrument Sans", style: "normal", weight: [400, 700], file: "/fonts/kinetic/instrument-sans.woff2", v: "289cecfd", bytes: 42232, licence: "/fonts/kinetic/licences/instrumentsans-OFL.txt" },
+ { id: "unbounded", family: "Kinetic Unbounded", style: "normal", weight: [500, 900], file: "/fonts/kinetic/unbounded.woff2", v: "4cb3192b", bytes: 67628, licence: "/fonts/kinetic/licences/unbounded-OFL.txt" },
+ { id: "boldonse", family: "Kinetic Boldonse", style: "normal", weight: [400, 400], file: "/fonts/kinetic/boldonse.woff2", v: "a354915c", bytes: 19024, licence: "/fonts/kinetic/licences/boldonse-OFL.txt" },
+ { id: "inter-tight", family: "Kinetic Inter Tight", style: "normal", weight: [300, 600], file: "/fonts/kinetic/inter-tight.woff2", v: "bbcb7ff7", bytes: 62668, licence: "/fonts/kinetic/licences/intertight-OFL.txt" },
+ { id: "bodoni-moda", family: "Kinetic Bodoni Moda Display", style: "normal", weight: [400, 700], file: "/fonts/kinetic/bodoni-moda.woff2", v: "2c4b7f85", bytes: 34016, licence: "/fonts/kinetic/licences/bodonimoda-OFL.txt" },
+ { id: "bodoni-moda-italic", family: "Kinetic Bodoni Moda Display", style: "italic", weight: [400, 700], file: "/fonts/kinetic/bodoni-moda-italic.woff2", v: "f7750916", bytes: 39708, licence: "/fonts/kinetic/licences/bodonimoda-OFL.txt" },
+ { id: "italiana", family: "Kinetic Italiana", style: "normal", weight: [400, 400], file: "/fonts/kinetic/italiana.woff2", v: "a04fe580", bytes: 10128, licence: "/fonts/kinetic/licences/italiana-OFL.txt" },
+ { id: "fraunces-soft", family: "Kinetic Fraunces Soft", style: "normal", weight: [300, 600], file: "/fonts/kinetic/fraunces-soft.woff2", v: "d0ad2d68", bytes: 45624, licence: "/fonts/kinetic/licences/fraunces-OFL.txt" },
+ { id: "fraunces-soft-italic", family: "Kinetic Fraunces Soft", style: "italic", weight: [300, 600], file: "/fonts/kinetic/fraunces-soft-italic.woff2", v: "1665d037", bytes: 55200, licence: "/fonts/kinetic/licences/fraunces-OFL.txt" },
+ { id: "fraunces-display", family: "Kinetic Fraunces Display", style: "normal", weight: [700, 900], file: "/fonts/kinetic/fraunces-display.woff2", v: "1192b7ca", bytes: 36932, licence: "/fonts/kinetic/licences/fraunces-OFL.txt" },
+ { id: "manrope", family: "Kinetic Manrope", style: "normal", weight: [400, 700], file: "/fonts/kinetic/manrope.woff2", v: "15da53e1", bytes: 30176, licence: "/fonts/kinetic/licences/manrope-OFL.txt" },
+ { id: "young-serif", family: "Kinetic Young Serif", style: "normal", weight: [400, 400], file: "/fonts/kinetic/young-serif.woff2", v: "23bd95f8", bytes: 21356, licence: "/fonts/kinetic/licences/youngserif-OFL.txt" },
+ { id: "bricolage", family: "Kinetic Bricolage Display", style: "normal", weight: [600, 800], file: "/fonts/kinetic/bricolage.woff2", v: "92d087fb", bytes: 50160, licence: "/fonts/kinetic/licences/bricolagegrotesque-OFL.txt" },
+ { id: "outfit", family: "Kinetic Outfit", style: "normal", weight: [400, 600], file: "/fonts/kinetic/outfit.woff2", v: "292365cf", bytes: 35864, licence: "/fonts/kinetic/licences/outfit-OFL.txt" },
+ { id: "geist", family: "Kinetic Geist", style: "normal", weight: [400, 600], file: "/fonts/kinetic/geist.woff2", v: "2bf19523", bytes: 27208, licence: "/fonts/kinetic/licences/geist-OFL.txt" },
+ { id: "mona-sans", family: "Kinetic Mona Sans", style: "normal", weight: [600, 900], file: "/fonts/kinetic/mona-sans.woff2", v: "78cd262e", bytes: 54084, licence: "/fonts/kinetic/licences/monasans-OFL.txt" },
+ { id: "mona-sans-expanded", family: "Kinetic Mona Sans Expanded", style: "normal", weight: [600, 900], file: "/fonts/kinetic/mona-sans-expanded.woff2", v: "78e0ade4", bytes: 55304, licence: "/fonts/kinetic/licences/monasans-OFL.txt" },
+ { id: "dela-gothic", family: "Kinetic Dela Gothic One", style: "normal", weight: [400, 400], file: "/fonts/kinetic/dela-gothic.woff2", v: "7824e5db", bytes: 18780, licence: "/fonts/kinetic/licences/delagothicone-OFL.txt" },
+ { id: "bagel-fat", family: "Kinetic Bagel Fat One", style: "normal", weight: [400, 400], file: "/fonts/kinetic/bagel-fat.woff2", v: "740bc1da", bytes: 17448, licence: "/fonts/kinetic/licences/bagelfatone-OFL.txt" },
+ { id: "caveat", family: "Kinetic Caveat", style: "normal", weight: [500, 700], file: "/fonts/kinetic/caveat.woff2", v: "be2b3756", bytes: 86296, licence: "/fonts/kinetic/licences/caveat-OFL.txt" },
+ { id: "ballet", family: "Kinetic Ballet", style: "normal", weight: [400, 400], file: "/fonts/kinetic/ballet.woff2", v: "fb60fdcc", bytes: 25300, licence: "/fonts/kinetic/licences/ballet-OFL.txt" },
+ { id: "space-mono", family: "Kinetic Space Mono", style: "normal", weight: [400, 400], file: "/fonts/kinetic/space-mono.woff2", v: "e9402b97", bytes: 14468, licence: "/fonts/kinetic/licences/spacemono-OFL.txt" },
+ { id: "space-mono-bold", family: "Kinetic Space Mono", style: "normal", weight: [700, 700], file: "/fonts/kinetic/space-mono-bold.woff2", v: "1e703f43", bytes: 14508, licence: "/fonts/kinetic/licences/spacemono-OFL.txt" },
+ { id: "gloock", family: "Kinetic Gloock", style: "normal", weight: [400, 400], file: "/fonts/kinetic/gloock.woff2", v: "70867bc6", bytes: 20620, licence: "/fonts/kinetic/licences/gloock-OFL.txt" },
+];
diff --git a/src/lib/motion/type/faces.ts b/src/lib/motion/type/faces.ts
new file mode 100644
index 00000000..54d3a18c
--- /dev/null
+++ b/src/lib/motion/type/faces.ts
@@ -0,0 +1,75 @@
+/**
+ * Kinetic Motion's own type faces (pure): display and text faces under the SIL Open Font License, cut to the
+ * instances the type pairings use (an optical size, a width, a softness) and subset to Latin, served from
+ * /fonts/kinetic/ next to their licences. Built by scripts/kinetic/build-fonts.py from scripts/kinetic/fonts.json.
+ *
+ * A page loads only the faces its template uses (src/components/motion/kinetic-fonts.ts). Canvas text names a face
+ * by its family, weight and style. Every family is named "Kinetic …" ("Kinetic Fraunces Soft"), so a brand kit that
+ * picks the same font from the web-font service keeps that service's weights and scripts.
+ */
+
+import { fallbackFor } from "@/components/ads/layout";
+import { KINETIC_FACES, KINETIC_UNICODE_RANGE } from "./faces.generated";
+
+export { KINETIC_FACES, KINETIC_UNICODE_RANGE };
+
+export interface KineticFace {
+ id: string;
+ family: string;
+ style: "normal" | "italic";
+ /** The weights the file covers (a variable face: a range). */
+ weight: [number, number];
+ /** Path under the site's root. */
+ file: string;
+ /** Content hash, for caching. */
+ v: string;
+ bytes: number;
+ /** The licence text that ships with it. */
+ licence: string;
+}
+
+export type FontStyle = "normal" | "italic";
+
+/** Every family Kinetic hosts itself. */
+export const KINETIC_FAMILIES: ReadonlySet<string> = new Set(KINETIC_FACES.map((f) => f.family));
+
+/** Whether Kinetic hosts this family (so no web-font service is asked for it). */
+export const isKineticFamily = (family: string | undefined): boolean => !!family && KINETIC_FAMILIES.has(family.trim());
+
+/** A face's address with its version. */
+export const faceUrl = (f: KineticFace): string => `${f.file}?v=${f.v}`;
+
+/** The files that draw these families (every weight and style each has), and nothing else. */
+export function facesOf(families: Iterable<string | { family: string; style?: FontStyle } | null | undefined>): KineticFace[] {
+ const want = new Map<string, Set<FontStyle> | null>();
+ for (const f of families) {
+ if (!f) continue;
+ const family = (typeof f === "string" ? f : f.family).trim();
+ if (!KINETIC_FAMILIES.has(family)) continue;
+ const style = typeof f === "string" ? undefined : f.style;
+ if (!style) want.set(family, null);
+ else if (want.get(family) !== null) want.set(family, new Set([...(want.get(family) ?? []), style]));
+ }
+ return KINETIC_FACES.filter((f) => want.has(f.family) && (want.get(f.family) === null || want.get(f.family)!.has(f.style)));
+}
+
+/** The nearest weight a family has (a static face draws at its one weight; asking for another would fake it). */
+export function weightFor(family: string, weight: number, style: FontStyle = "normal"): number {
+ const faces = KINETIC_FACES.filter((f) => f.family === family && f.style === style);
+ if (!faces.length) return weight;
+ let best = weight;
+ let gap = Infinity;
+ for (const f of faces) {
+ const w = Math.min(f.weight[1], Math.max(f.weight[0], weight));
+ if (Math.abs(w - weight) < gap) {
+ gap = Math.abs(w - weight);
+ best = w;
+ }
+ }
+ return best;
+}
+
+/** A CSS font for canvas text: style, weight, size (whole pixels, as the layout measures) and the family's fallback. */
+export function fontOf(family: string, size: number, weight = 400, style: FontStyle = "normal"): string {
+ return `${style === "italic" ? "italic " : ""}${weight} ${Math.round(size)}px "${family.replace(/"/g, "")}", ${fallbackFor(family)}`;
+}
diff --git a/src/lib/motion/type/glyphs.ts b/src/lib/motion/type/glyphs.ts
new file mode 100644
index 00000000..5ee8c189
--- /dev/null
+++ b/src/lib/motion/type/glyphs.ts
@@ -0,0 +1,368 @@
+/**
+ * Type set for motion (pure): a field's typed words laid out at a display size, with every line, word and letter
+ * placed, so an animation can move them one by one and land exactly on the layout at rest.
+ *
+ * - Exact text: the words are the typed words (layout.ts): never re-cased, cut, split or squeezed. Joining each
+ * piece's `gap` and `text` in order gives back the typed text.
+ * - Fit at the widest moment: an animation that widens the words (tracking that closes in, a scale, a heavier weight)
+ * says so in `widest`, and the size is chosen so even that moment fits the box. If nothing fits, `overflow` is set
+ * and the page asks for shorter words.
+ * - Letters are placed from the measured line up to them (`measure(line.slice(0, end)) - own width`), so the font's
+ * kerning survives when they move apart; tracking adds the same space after each letter.
+ * - Scripts whose letters join or reorder (Arabic, Hebrew, Devanagari, Thai…) and lines a font may join with a
+ * ligature move by word or line only, never letter by letter, and get no tracking.
+ * - Measured from the ink: the cap height and the ink box come from the browser's glyph bounds where it gives them
+ * (`measure.box`), so clips, bars and alignment hug the letters rather than the font size.
+ */
+
+import { graphemes, layoutText, type Measure } from "../layout";
+import type { Box } from "../display";
+import { fontOf, type FontStyle } from "./faces";
+
+/** Where a text's ink lies, from the point it is drawn at (textBaseline "top"): top and bottom down from y, left and right across from x. */
+export interface InkBox {
+ top: number;
+ bottom: number;
+ left: number;
+ right: number;
+}
+
+/** A measure that can also report ink bounds (the browser's actualBoundingBox*, with textBaseline "top"). */
+export type BoxMeasure = Measure & { box?: (text: string, font: string) => InkBox };
+
+const pxOf = (font: string): number => Number(/(\d+(?:\.\d+)?)px/.exec(font)?.[1] ?? 16);
+
+/** A text's ink box: the browser's own where it can tell, else an estimate from the size (caps 0.1–0.82 em, descenders to 1 em). */
+export function inkOf(measure: BoxMeasure, text: string, font: string): InkBox {
+ if (measure.box) return measure.box(text, font);
+ const size = pxOf(font);
+ return { top: size * 0.1, bottom: size * (/[gjpqyQ,;]/.test(text) ? 1 : 0.82), left: 0, right: measure(text, font) };
+}
+
+/** Joining or reordering scripts: by word or line only. */
+const COMPLEX = /[\p{Script=Hebrew}\p{Script=Arabic}\p{Script=Syriac}\p{Script=Thaana}\p{Script=Nko}\p{Script=Devanagari}\p{Script=Bengali}\p{Script=Gurmukhi}\p{Script=Gujarati}\p{Script=Oriya}\p{Script=Tamil}\p{Script=Telugu}\p{Script=Kannada}\p{Script=Malayalam}\p{Script=Sinhala}\p{Script=Thai}\p{Script=Lao}\p{Script=Tibetan}\p{Script=Myanmar}\p{Script=Khmer}\p{Script=Mongolian}]/u;
+/** Pairs a font may join into one glyph: such a line moves by word. */
+const LIGATURE = /f[fijlbhkt]/;
+const DIGIT = /^\p{Nd}$/u;
+const OPENING = /^[“‘"'«„‚(\[]$/u;
+
+export interface TypeSpec {
+ /** The field it sets ("headline"). */
+ field: string;
+ text: string;
+ family: string;
+ weight: number;
+ style?: FontStyle;
+ /** Largest and smallest size; tried from the largest down by `step` (6 %). */
+ max: number;
+ min: number;
+ step?: number;
+ /** The box: its left edge, its width; the first line's cap top (or em top) at `y`. */
+ x: number;
+ y: number;
+ width: number;
+ maxLines: number;
+ /** Line pitch as a share of the size. */
+ leading: number;
+ /** Letter spacing at rest, in em. */
+ tracking?: number;
+ /** The widest moment of the animation: letter spacing it adds (em, on top of `tracking`), its scale, its heaviest weight. */
+ widest?: { tracking?: number; scale?: number; weight?: number };
+ align?: "left" | "centre" | "right";
+ /** `y` is the cap top of the first line (default), else the top of its em box. */
+ capTop?: boolean;
+ /** Left-aligned lines start at their first letter's ink, not its side bearing; an opening quote hangs outside (default on). */
+ optical?: boolean;
+ /** Figures in fixed-width cells (prices, counts, stats): numbers never jitter while they change. */
+ tabular?: boolean;
+ /** Even lines (see layoutText): the shortest line's share of the longest worth trying smaller sizes for. */
+ even?: number;
+ /** The narrowest a word space may look (em, space plus tracking); default by size and style (see wordSpaceFor). */
+ wordSpace?: number;
+}
+
+/** Below this size (design units) a run is copy, not a hero: never tracked tighter than 0. */
+export const COPY_SIZE = 100;
+
+/**
+ * The letter spacing a text is really set at: never tighter than −1 %; words with lower-case letters never tracked
+ * open (tracking is for capitals) and, below hero size, never tighter than 0.
+ */
+export function trackingFor(text: string, tracking: number, max: number): number {
+ let t = Math.max(-0.01, tracking);
+ if (/\p{Ll}/u.test(text)) {
+ t = Math.min(0.01, t);
+ if (max < COPY_SIZE) t = Math.max(0, t);
+ }
+ return t;
+}
+
+/** The narrowest word space (em) for a size and style: copy and italics need more room than display caps. */
+export const wordSpaceFor = (max: number, style: FontStyle): number => (max < COPY_SIZE ? 0.24 : 0.2) + (style === "italic" ? 0.04 : 0);
+
+/** Minimum gap between one line's ink and the next line's ink, as a share of the cap height. */
+export const LINE_GAP = 0.05;
+
+export interface SetGlyph {
+ text: string;
+ gap: string;
+ x: number;
+ y: number;
+ /** Its own advance. */
+ w: number;
+ line: number;
+ word: number;
+}
+
+export interface SetWord {
+ text: string;
+ gap: string;
+ x: number;
+ y: number;
+ w: number;
+ line: number;
+ /** Its letters in `glyphs` (from, to), or null when its line moves by word. */
+ glyphs: [number, number] | null;
+}
+
+export interface SetLine {
+ text: string;
+ gap: string;
+ x: number;
+ y: number;
+ w: number;
+ /** The baseline (the bottom of a capital). */
+ baseline: number;
+ /** Its ink. */
+ ink: Box;
+ words: [number, number];
+ glyphs: [number, number] | null;
+}
+
+export interface TypeSet {
+ field: string;
+ /** The typed text, trimmed. */
+ text: string;
+ overflow: boolean;
+ family: string;
+ weight: number;
+ style: FontStyle;
+ size: number;
+ font: string;
+ lineHeight: number;
+ /** Letter spacing at rest (em); 0 for scripts that join. */
+ tracking: number;
+ /** Room added to each word space so it never looks closed (px at this size; 0 for most faces). */
+ spaceExtra: number;
+ align: "left" | "centre" | "right";
+ dir: "ltr" | "rtl";
+ /** The cap height's top and bottom below a line's y. */
+ cap: { top: number; bottom: number };
+ lines: SetLine[];
+ words: SetWord[];
+ glyphs: SetGlyph[];
+ /** Whether every line can move letter by letter. */
+ splittable: boolean;
+ tabular: boolean;
+ /** The layout box (x, y of the first line's em top, the widest line, every line's pitch). */
+ box: Box;
+ /** All the ink. */
+ ink: Box;
+ /** Kept for the moments an animation re-measures (a weight wave, a cycling letter). */
+ measure: BoxMeasure;
+}
+
+const union = (boxes: Box[]): Box => {
+ if (!boxes.length) return { x: 0, y: 0, w: 0, h: 0 };
+ const x0 = Math.min(...boxes.map((b) => b.x));
+ const y0 = Math.min(...boxes.map((b) => b.y));
+ const x1 = Math.max(...boxes.map((b) => b.x + b.w));
+ const y1 = Math.max(...boxes.map((b) => b.y + b.h));
+ return { x: x0, y: y0, w: x1 - x0, h: y1 - y0 };
+};
+
+/** The widest figure's advance in a font (the cell a tabular figure sits in). */
+export const figureCell = (measure: Measure, font: string): number => Math.max(...[..."0123456789"].map((d) => measure(d, font)));
+
+/** A text's advance with figures in cells (each other letter at its own advance; kerning between figures dropped). */
+function tabularWidth(measure: Measure, text: string, font: string): number {
+ if (!/\p{Nd}/u.test(text)) return measure(text, font);
+ const cell = figureCell(measure, font);
+ let w = 0;
+ let run = "";
+ for (const g of graphemes(text)) {
+ if (DIGIT.test(g.text)) {
+ if (run) w += measure(run, font);
+ run = "";
+ w += cell;
+ } else run += g.text;
+ }
+ return w + (run ? measure(run, font) : 0);
+}
+
+/** Lay out a field for motion (see the file's comment). */
+export function setType(spec: TypeSpec, measure: BoxMeasure): TypeSet {
+ const style: FontStyle = spec.style ?? "normal";
+ const styled = (font: string) => (style === "italic" && !font.startsWith("italic") ? `italic ${font}` : font);
+ const text = spec.text.trim();
+ const complex = COMPLEX.test(text);
+ const tracking = complex ? 0 : trackingFor(text, spec.tracking ?? 0, spec.max);
+ const minSpace = complex ? 0 : (spec.wordSpace ?? wordSpaceFor(spec.max, style));
+ const spaceRoom = (font: string, track: number) => Math.max(0, minSpace * pxOf(font) - (measure(" ", font) + track * pxOf(font)));
+ const spacesIn = (t: string) => (t.match(/ /g) ?? []).length;
+ const widest = spec.widest ?? {};
+ const wideTrack = complex ? 0 : tracking + Math.max(0, widest.tracking ?? 0);
+ const scale = Math.max(1, widest.scale ?? 1);
+ const tabular = !!spec.tabular;
+ const advance = (t: string, font: string) => (tabular ? tabularWidth(measure, t, font) : measure(t, font));
+ // The width a line takes at the animation's widest moment.
+ const fit: Measure = (t, font) => {
+ const real = styled(font);
+ let w = advance(t, real);
+ if (widest.weight && widest.weight !== spec.weight) w = Math.max(w, advance(t, real.replace(/^(italic )?\d+ /, `$1${widest.weight} `)));
+ const n = graphemes(t).length;
+ return (w + wideTrack * pxOf(font) * Math.max(0, n - 1) + spaceRoom(real, tracking) * spacesIn(t)) * scale;
+ };
+ const layout = layoutText({ text, family: spec.family, weight: spec.weight, width: spec.width, maxLines: spec.maxLines, max: spec.max, min: spec.min, step: spec.step, lineHeight: spec.leading, even: spec.even }, fit);
+ const size = layout.size;
+ const font = fontOf(spec.family, size, spec.weight, style);
+ const capProbe = inkOf(measure, "H", font);
+ // Lines never touch: the pitch grows until each line's ink clears the next line's by LINE_GAP of the cap height.
+ let lh = size * spec.leading;
+ for (let i = 0; i + 1 < layout.lines.length; i++) {
+ const below = inkOf(measure, layout.lines[i].text, font).bottom;
+ const above = Math.min(capProbe.top, inkOf(measure, layout.lines[i + 1].text, font).top);
+ lh = Math.max(lh, below - above + LINE_GAP * (capProbe.bottom - capProbe.top));
+ }
+ const align = spec.align ?? "left";
+ const cap = { top: capProbe.top, bottom: capProbe.bottom };
+ const top = spec.capTop === false ? spec.y : spec.y - cap.top;
+ const T = tracking * size;
+ const E = layout.dir === "ltr" ? spaceRoom(font, tracking) : 0;
+ const cell = tabular ? figureCell(measure, font) : 0;
+
+ const lines: SetLine[] = [];
+ const words: SetWord[] = [];
+ const glyphs: SetGlyph[] = [];
+ let splittable = !complex;
+
+ layout.lines.forEach((ln, li) => {
+ const lineText = ln.text;
+ const gs = graphemes(lineText);
+ const ordAt = new Map<number, number>();
+ gs.forEach((g, k) => ordAt.set(g.index, k));
+ ordAt.set(lineText.length, gs.length);
+ // Each letter's left edge and advance at rest.
+ const lefts: number[] = [];
+ const widths: number[] = [];
+ if (tabular) {
+ let x = 0;
+ gs.forEach((g, k) => {
+ const own = measure(g.text, font);
+ const adv = DIGIT.test(g.text) ? cell : own;
+ lefts.push(x + (adv - own) / 2);
+ widths.push(own);
+ x += adv + (k < gs.length - 1 ? T : 0) + (g.text === " " ? E : 0);
+ });
+ } else {
+ let spaces = 0;
+ gs.forEach((g, k) => {
+ const own = measure(g.text, font);
+ lefts.push(measure(lineText.slice(0, g.index + g.text.length), font) - own + T * k + E * spaces);
+ widths.push(own);
+ if (g.text === " ") spaces++;
+ });
+ }
+ const natural = tabular ? tabularWidth(measure, lineText, font) : measure(lineText, font);
+ const width = natural + T * Math.max(0, gs.length - 1) + E * spacesIn(lineText);
+ const lineInk = inkOf(measure, lineText, font);
+ // Optical margin: a left-aligned line starts at its first letter's ink; an opening quote hangs outside.
+ let shift = 0;
+ if (align === "left" && spec.optical !== false && layout.dir === "ltr" && gs.length) {
+ const first = gs[0].text;
+ shift = OPENING.test(first) ? -(lefts[1] ?? widths[0]) : -Math.max(-size * 0.08, Math.min(size * 0.08, inkOf(measure, first, font).left));
+ }
+ const x = (align === "left" ? spec.x : align === "right" ? spec.x + spec.width - width : spec.x + (spec.width - width) / 2) + shift;
+ const y = top + li * lh;
+ const split = !complex && layout.dir === "ltr" && !LIGATURE.test(lineText);
+ if (!split) splittable = false;
+ const w0 = words.length;
+ const g0 = glyphs.length;
+ let wordIndex = w0;
+ let off = 0;
+ for (const word of ln.words) {
+ // The word's place in the line: the line starts with the first word; each next one after its gap.
+ const from = words.length === w0 ? 0 : off + word.gap.length;
+ const to = from + word.text.length;
+ off = to;
+ const ordFrom = ordAt.get(from) ?? 0;
+ const ordTo = ordAt.get(to) ?? gs.length;
+ const left = layout.dir === "rtl" ? width - (measure(lineText.slice(0, to), font) + T * ordTo) : lefts[ordFrom] ?? 0;
+ const right = layout.dir === "rtl" ? width - (measure(lineText.slice(0, from), font) + T * ordFrom) : (lefts[ordTo - 1] ?? 0) + (widths[ordTo - 1] ?? 0);
+ const wordGlyphs: [number, number] | null = split ? [glyphs.length, glyphs.length] : null;
+ if (split) {
+ let gap = word.gap;
+ for (let k = ordFrom; k < ordTo; k++) {
+ glyphs.push({ text: gs[k].text, gap, x: x + lefts[k], y, w: widths[k], line: li, word: wordIndex });
+ gap = "";
+ }
+ wordGlyphs![1] = glyphs.length;
+ }
+ words.push({ text: word.text, gap: word.gap, x: x + left, y, w: right - left, line: li, glyphs: wordGlyphs });
+ wordIndex++;
+ }
+ lines.push({
+ text: lineText,
+ gap: ln.gap,
+ x,
+ y,
+ w: width,
+ baseline: y + cap.bottom,
+ ink: { x: x + lineInk.left, y: y + lineInk.top, w: lineInk.right - lineInk.left + T * Math.max(0, gs.length - 1) + E * spacesIn(lineText), h: lineInk.bottom - lineInk.top },
+ words: [w0, words.length],
+ glyphs: split ? [g0, glyphs.length] : null,
+ });
+ });
+
+ const box: Box = lines.length ? { x: Math.min(...lines.map((l) => l.x)), y: top, w: Math.max(...lines.map((l) => l.w)), h: lines.length * lh } : { x: spec.x, y: top, w: 0, h: 0 };
+ return {
+ field: spec.field,
+ text,
+ overflow: layout.overflow,
+ family: spec.family,
+ weight: spec.weight,
+ style,
+ size,
+ font,
+ lineHeight: lh,
+ tracking,
+ spaceExtra: E,
+ align,
+ dir: layout.dir,
+ cap,
+ lines,
+ words,
+ glyphs,
+ splittable: splittable && lines.length > 0,
+ tabular,
+ box,
+ ink: union(lines.map((l) => l.ink)),
+ measure,
+ };
+}
+
+/** A set's lines, words and letters joined back (gap + text): the typed text. */
+export const setSpelling = (set: TypeSet): string => set.words.map((w) => w.gap + w.text).join("");
+
+/** Shift a whole set (a layout made at one place, drawn at another). */
+export function moveSet(set: TypeSet, dx: number, dy: number): TypeSet {
+ const box = (b: Box): Box => ({ ...b, x: b.x + dx, y: b.y + dy });
+ return {
+ ...set,
+ lines: set.lines.map((l) => ({ ...l, x: l.x + dx, y: l.y + dy, baseline: l.baseline + dy, ink: box(l.ink) })),
+ words: set.words.map((w) => ({ ...w, x: w.x + dx, y: w.y + dy })),
+ glyphs: set.glyphs.map((g) => ({ ...g, x: g.x + dx, y: g.y + dy })),
+ box: box(set.box),
+ ink: box(set.ink),
+ };
+}
diff --git a/src/lib/motion/type/pairings.ts b/src/lib/motion/type/pairings.ts
new file mode 100644
index 00000000..3e4a0f94
--- /dev/null
+++ b/src/lib/motion/type/pairings.ts
@@ -0,0 +1,169 @@
+/**
+ * Type pairings (pure): nine voices for Kinetic templates, each a hero face, an accent face, a face for small
+ * details (corner facts, labels) and a body face, with the leading and tracking each is set at. A template picks one;
+ * the brand kit decides the colours. Every face is hosted by Kinetic itself (faces.ts) under the SIL Open Font License.
+ *
+ * Tracking is in em (0.06 = 6 % of the size). It is the look of the face at rest, never a way to make words fit: a
+ * layout that doesn't fit asks for shorter words instead. Case is never changed by code: `heroCase` says what the
+ * showcase copy is written in, and the person's own words are set exactly as typed.
+ */
+
+import type { FontStyle } from "./faces";
+
+export interface RoleFace {
+ family: string;
+ weight: number;
+ style?: FontStyle;
+ /** Line pitch as a share of the size. */
+ leading: number;
+ /** Letter spacing in em at rest. */
+ tracking: number;
+}
+
+export type PairingId = "T1" | "T2" | "T3" | "T4" | "T5" | "T6" | "T7" | "T8" | "T9";
+
+export interface Pairing {
+ id: PairingId;
+ name: string;
+ /** What it suits. */
+ moods: readonly string[];
+ hero: RoleFace;
+ /** One word of contrast (an italic, a script, a wide cut), or none. */
+ accent: RoleFace | null;
+ /** Tiny tracked details: corners, labels, indices. */
+ meta: RoleFace;
+ body: RoleFace;
+ /** Prices, counts and stats (set in fixed-width cells by the layout). */
+ figures: RoleFace;
+ /** How the showcase copy for this voice is written (advice for writers; code never re-cases typed words). */
+ heroCase: "caps" | "title" | "any";
+ /** Tracking for a hero typed in capitals, where it differs (wide luxury caps). */
+ heroCapsTracking?: number;
+}
+
+const face = (family: string, weight: number, leading: number, tracking = 0, style?: FontStyle): RoleFace => ({ family, weight, leading, tracking, ...(style && { style }) });
+
+export const PAIRINGS: Record<PairingId, Pairing> = {
+ T1: {
+ id: "T1",
+ name: "Editorial Bold",
+ moods: ["fashion", "launch", "portfolio", "pitch"],
+ hero: face("Kinetic Anton", 400, 0.9, 0.005),
+ accent: face("Kinetic Instrument Serif", 400, 1, 0, "italic"),
+ meta: face("Kinetic Geist Mono", 500, 1.2, 0.06),
+ body: face("Kinetic Geist", 400, 1.3),
+ figures: face("Kinetic Anton", 400, 0.92),
+ heroCase: "caps",
+ },
+ T2: {
+ id: "T2",
+ name: "Poster Condensed",
+ moods: ["sale", "sport", "event", "offer"],
+ hero: face("Kinetic Big Shoulders Display", 900, 0.86),
+ accent: face("Kinetic Archivo Condensed", 900, 0.9),
+ meta: face("Kinetic Instrument Sans", 600, 1.2, 0.12),
+ body: face("Kinetic Instrument Sans", 400, 1.3),
+ figures: face("Kinetic Archivo Condensed", 900, 0.9),
+ heroCase: "caps",
+ },
+ T3: {
+ id: "T3",
+ name: "Extended Statement",
+ moods: ["tech", "agency", "saas", "launch"],
+ hero: face("Kinetic Archivo Expanded", 800, 0.9, -0.01),
+ accent: face("Kinetic Instrument Serif", 400, 1, 0, "italic"),
+ meta: face("Kinetic Geist Mono", 500, 1.2, 0.06),
+ body: face("Kinetic Inter Tight", 400, 1.3),
+ figures: face("Kinetic Archivo Expanded", 800, 0.9, -0.01),
+ heroCase: "any",
+ },
+ T4: {
+ id: "T4",
+ name: "Luxury Serif",
+ moods: ["luxury", "fragrance", "jewellery", "hospitality"],
+ hero: face("Kinetic Bodoni Moda Display", 600, 1, -0.005),
+ accent: face("Kinetic Bodoni Moda Display", 600, 1, 0, "italic"),
+ meta: face("Kinetic Inter Tight", 400, 1.2, 0.14),
+ body: face("Kinetic Inter Tight", 300, 1.35),
+ figures: face("Kinetic Bodoni Moda Display", 600, 1),
+ heroCase: "title",
+ heroCapsTracking: 0.25,
+ },
+ T5: {
+ id: "T5",
+ name: "Soft Beauty",
+ moods: ["beauty", "skincare", "wellness"],
+ hero: face("Kinetic Fraunces Soft", 400, 1, -0.01),
+ accent: face("Kinetic Fraunces Soft", 400, 1, 0, "italic"),
+ meta: face("Kinetic Manrope", 600, 1.2, 0.1),
+ body: face("Kinetic Manrope", 400, 1.35),
+ figures: face("Kinetic Fraunces Soft", 500, 1),
+ heroCase: "title",
+ },
+ T6: {
+ id: "T6",
+ name: "Warm Table",
+ moods: ["food", "drink", "cafe", "retail"],
+ hero: face("Kinetic Fraunces Display", 900, 0.95, -0.01),
+ accent: face("Kinetic Bricolage Display", 800, 0.95),
+ meta: face("Kinetic Outfit", 500, 1.2, 0.1),
+ body: face("Kinetic Outfit", 400, 1.35),
+ figures: face("Kinetic Fraunces Display", 900, 0.95),
+ heroCase: "title",
+ },
+ T7: {
+ id: "T7",
+ name: "Product Grotesk",
+ moods: ["software", "finance", "dashboard", "data"],
+ hero: face("Kinetic Bricolage Display", 800, 0.92, -0.01),
+ accent: face("Kinetic Geist Mono", 500, 1.1),
+ meta: face("Kinetic Geist Mono", 500, 1.2, 0.06),
+ body: face("Kinetic Geist", 400, 1.35),
+ figures: face("Kinetic Geist Mono", 500, 1),
+ heroCase: "any",
+ },
+ T8: {
+ id: "T8",
+ name: "Collage Play",
+ moods: ["playful", "kids", "cafe", "creator"],
+ hero: face("Kinetic Dela Gothic One", 400, 0.9),
+ accent: face("Kinetic Caveat", 600, 1),
+ meta: face("Kinetic Space Mono", 400, 1.2, 0.06),
+ body: face("Kinetic Space Mono", 400, 1.35),
+ figures: face("Kinetic Dela Gothic One", 400, 0.95),
+ heroCase: "any",
+ },
+ T9: {
+ id: "T9",
+ name: "Quiet Minimal",
+ moods: ["minimal", "end card", "invitation", "report"],
+ hero: face("Kinetic Gloock", 400, 1, 0),
+ accent: face("Kinetic Instrument Serif", 400, 1, 0, "italic"),
+ meta: face("Kinetic Instrument Sans", 500, 1.2, 0.14),
+ body: face("Kinetic Instrument Sans", 400, 1.35),
+ figures: face("Kinetic Gloock", 400, 1),
+ heroCase: "title",
+ },
+};
+
+export const PAIRING_IDS = Object.keys(PAIRINGS) as PairingId[];
+
+/** Every face (family and style) a pairing draws with, for loading only those. */
+export function pairingFaces(id: PairingId): { family: string; style: FontStyle }[] {
+ const p = PAIRINGS[id];
+ const seen = new Map<string, { family: string; style: FontStyle }>();
+ for (const r of [p.hero, p.accent, p.meta, p.body, p.figures]) if (r) seen.set(`${r.family}|${r.style ?? "normal"}`, { family: r.family, style: r.style ?? "normal" });
+ return [...seen.values()];
+}
+
+/** The pairing for a mood word ("beauty", "sale"…), or T1. */
+export function pairingFor(mood: string): Pairing {
+ const m = mood.trim().toLowerCase();
+ return Object.values(PAIRINGS).find((p) => p.moods.includes(m)) ?? PAIRINGS.T1;
+}
+
+/** Whether typed words are all capitals (so a pairing's caps tracking applies). Nothing is re-cased. */
+export const isAllCaps = (text: string): boolean => /\p{Lu}/u.test(text) && !/\p{Ll}/u.test(text);
+
+/** The tracking a hero is set at for these typed words. */
+export const heroTracking = (p: Pairing, text: string): number => (p.heroCapsTracking !== undefined && isAllCaps(text) ? p.heroCapsTracking : p.hero.tracking);
diff --git a/src/lib/motion/type/presets.ts b/src/lib/motion/type/presets.ts
new file mode 100644
index 00000000..900f4b37
--- /dev/null
+++ b/src/lib/motion/type/presets.ts
@@ -0,0 +1,1106 @@
+/**
+ * Text animations (pure): entrances, exits and loops for type, each a plain function of time. A preset says how one
+ * unit (the block, a line, a word or a letter) is posed `t` seconds after it starts, how units follow one another,
+ * which unit it moves, and how wide the words get at its widest moment (so the layout can fit that moment).
+ *
+ * Every entrance ends exactly at rest (no offset, no scale, full opacity, nothing swapped), so the frame the cover is
+ * taken from is the plain layout. Exits are the entrance played away (mirrored or reversed) in about two thirds of its
+ * time, on the "exit" curve, never overshooting. Units never change what is typed: a scramble cycles the letter drawn
+ * in a slot for a moment, but the slot's typed letter stays its text, and at rest every slot shows its own letter.
+ *
+ * Times are seconds; distances are in design units, `em` (the size), `lh` (the line pitch) or shares of the frame.
+ */
+
+import { back, CURVES, cubic, elastic, quart, type Ease } from "../ease";
+import type { EventKind, StaggerUnit } from "../tween";
+import { rng } from "../random";
+import { clamp } from "../time";
+import type { Box } from "../display";
+
+/** One frame at 30 fps: the presets' timings are written in these. */
+export const F = 1 / 30;
+const DEG = Math.PI / 180;
+
+export type UnitKind = "block" | "line" | "word" | "glyph";
+
+/** What a preset knows about the unit it poses (its place at rest, and its neighbours). */
+export interface UnitInfo {
+ kind: UnitKind;
+ /** Its place among the units it is staggered with, and how many there are. */
+ index: number;
+ count: number;
+ line: number;
+ lines: number;
+ /** Its text (a letter, a word, a line, the block). */
+ text: string;
+ /** Its box at rest: left, top of the em box, advance and line pitch. */
+ x: number;
+ y: number;
+ w: number;
+ h: number;
+ ink: Box;
+ baseline: number;
+ /** The size (em), the line pitch, and the cap height. */
+ em: number;
+ lh: number;
+ cap: number;
+ /** The block's own box (for moves that gather units into it). */
+ block: Box;
+ /** The frame (moves that start off screen). */
+ frame: { w: number; h: number };
+ /** How far down (and up) it must move to be wholly outside its line's clip. */
+ clear: { down: number; up: number };
+ /** A figure with no figure before it on its line (a number's leading column). */
+ lead?: boolean;
+}
+
+export interface PresetOptions {
+ seed: number;
+ /** 0–1: how far things travel and how much they overshoot (1 = as designed). */
+ intensity: number;
+ /** A hero over a quarter of the frame's height: slower, weightier entrances. */
+ hero: boolean;
+ /** Type-on: letters a second. */
+ rate: number;
+ /** Beat-cut: seconds a beat. */
+ beat: number;
+}
+
+/** A unit's pose: offsets, scale, rotation and the extras some presets draw (all at rest when absent). */
+export interface Pose {
+ dx: number;
+ dy: number;
+ sx: number;
+ sy: number;
+ /** Radians. */
+ rot: number;
+ /** Shear along x (tan of the angle). */
+ skewX: number;
+ opacity: number;
+ /** Blur in design units. */
+ blur: number;
+ /** Toward black (0–1). */
+ shade: number;
+ /** Letter spacing (em) for the whole block, when it moves. */
+ tracking?: number;
+ /** Font weight, when it moves (variable faces). */
+ weight?: number;
+ /** A letter drawn in place of the typed one for this frame (scramble). */
+ shown?: string;
+ /** Draw inside the line's clip (a hard edge the unit rises from). */
+ clip?: boolean;
+ /** A soft wipe: the unit shows from its left edge up to `to` (share of its width), with a feathered edge. */
+ reveal?: { from: number; to: number; feather: number };
+ /** A solid bar across the line (bar-swipe), its left and right edges as shares of the line's width. */
+ bar?: { from: number; to: number };
+ /** A copy growing away from an impact. */
+ ghost?: { s: number; a: number };
+ /** Neon tube lit (0–1). */
+ glow?: number;
+ /** The top half hinged away (radians, fold). */
+ fold?: number;
+ /** A split-flap tile mid-flip: the letter leaving, the letter arriving, how far through (0–1). */
+ flap?: { from: string; to: string; phase: number };
+ /** A rolling figure: its position on the 0–9 strip (fractions between two figures). */
+ roll?: number;
+ /** The lowest figure the strip shows (places below it are blank, so nothing shows before the figure rolls in). */
+ rollFrom?: number;
+ /** Red/cyan split along x (design units) while a scramble runs. */
+ split?: number;
+}
+
+export const REST: Readonly<Pose> = Object.freeze({ dx: 0, dy: 0, sx: 1, sy: 1, rot: 0, skewX: 0, opacity: 1, blur: 0, shade: 0 });
+const HIDDEN: Readonly<Pose> = Object.freeze({ ...REST, opacity: 0 });
+const pose = (p: Partial<Pose>): Pose => ({ ...REST, ...p });
+
+export type Pivot = "centre" | "baseline-left" | "baseline-centre" | "bottom-left" | "midline";
+
+/** How the units' starts are spaced: gaps wide then tightening (`ease`), from the middle out, in a seeded order, or from the right. */
+export type Order = "ease" | "centre" | "seeded" | "reverse";
+
+export type PresetId =
+ | "cut-rise"
+ | "cut-rise-glyph"
+ | "word-lift"
+ | "fade-rise"
+ | "word-drop"
+ | "curtain"
+ | "bar-swipe"
+ | "focus-in"
+ | "track-in"
+ | "snap-tight"
+ | "slow-drift"
+ | "stomp"
+ | "beat-cut"
+ | "punch"
+ | "pop-in"
+ | "burst"
+ | "inflate"
+ | "merge"
+ | "plates"
+ | "slide-in"
+ | "flip-up"
+ | "fold"
+ | "tumble"
+ | "type-on"
+ | "scramble"
+ | "neon-strike"
+ | "split-flap"
+ | "odometer"
+ | "cut-paper"
+ | "weight-wave"
+ | "ink-draw";
+
+export type Tone = "luxury" | "editorial" | "sales" | "tech" | "beauty" | "playful" | "sport";
+
+export interface Preset {
+ id: PresetId;
+ name: string;
+ unit: UnitKind;
+ /** What the timing rules call its moves. */
+ kind: EventKind;
+ /** The curve its main event is on (for the timeline). */
+ curve: import("../ease").CurveName;
+ /** Seconds one unit takes (a hero's when it differs). */
+ dur: number;
+ heroDur?: number;
+ /** Seconds between units' starts. */
+ each: number;
+ order: Order;
+ /** How the stagger is named for the timing rules (by the unit by default). */
+ stagger?: StaggerUnit;
+ pivot: Pivot;
+ /** The widest moment (for fitting): letter spacing in em, a scale, a weight. */
+ widest?: { tracking?: number; scale?: number; weight?: number };
+ /** Units start together; the preset spaces them itself (one event for the block). */
+ together?: boolean;
+ /** For glyph presets laid out by line: a line starts when the one before is this far through (0–1). */
+ lineOverlap?: number;
+ /** The tones it suits, and the ones it never goes with. */
+ tones: readonly Tone[];
+ never?: readonly Tone[];
+ /** Once per template, on the hero word only. */
+ signature?: boolean;
+ /** The unit's pose `t` seconds after its start (t < 0: before it). */
+ enter(t: number, u: UnitInfo, o: PresetOptions): Pose;
+ /** The exit's length, and the pose `e` (0–1, linear) through it. */
+ exitDur: number;
+ exit(e: number, u: UnitInfo, o: PresetOptions): Pose;
+}
+
+const enter = CURVES.enter;
+const exitC = CURVES.exit;
+const snap = CURVES.snap;
+const move = CURVES.move;
+const decel = CURVES.decel;
+const draw = CURVES.draw;
+const roll = CURVES.roll;
+const expoIn = CURVES.slam;
+const back14 = back(1.4).out;
+const back12 = back(1.2).out;
+const back11 = back(1.1).out;
+const elastic14 = elastic(1, 0.4).out;
+
+/** Progress 0–1 through [0, d] (clamped). */
+const at = (t: number, d: number): number => clamp(d > 0 ? t / d : 1);
+/** A seeded ±1. */
+const sign = (o: PresetOptions, ...k: (string | number)[]) => (rng(o.seed, ...k) < 0.5 ? -1 : 1);
+
+// ---------------------------------------------------------------------------
+// Exits
+
+/** A plain exit: a short lift as it fades. */
+const fadeExit = (e: number, u: UnitInfo): Pose => {
+ const k = exitC(e);
+ return pose({ dy: -0.1 * u.em * k, opacity: 1 - k });
+};
+
+/** Units the exit removes are gone. */
+export const GONE: Readonly<Pose> = HIDDEN;
+
+// ---------------------------------------------------------------------------
+// Scramble and flap letters
+
+const UPPER = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+const LOWER = "abcdefghijklmnopqrstuvwxyz";
+const DIGITS = "0123456789";
+const SIGNS = "#%&*+=<>/?$@";
+
+/** The letters a slot cycles through: the same kind as its own letter (capitals for a capital, figures for a figure). */
+export function cycleSet(letter: string): string {
+ if (/^\p{Lu}$/u.test(letter)) return UPPER;
+ if (/^\p{Ll}$/u.test(letter)) return LOWER;
+ if (/^\p{Nd}$/u.test(letter)) return DIGITS;
+ return SIGNS;
+}
+
+/** A seeded letter of the slot's kind, different from its own. */
+function otherLetter(letter: string, o: PresetOptions, ...k: (string | number)[]): string {
+ const set = cycleSet(letter);
+ let c = set[Math.floor(rng(o.seed, ...k) * set.length)];
+ if (c === letter) c = set[(set.indexOf(c) + 1) % set.length];
+ return c;
+}
+
+// ---------------------------------------------------------------------------
+// The presets
+
+const P: Preset[] = [
+ {
+ id: "cut-rise",
+ name: "Cut rise",
+ unit: "line",
+ kind: "enter",
+ curve: "enter",
+ dur: 0.7,
+ heroDur: 0.85,
+ each: 0.12,
+ order: "ease",
+ pivot: "baseline-left",
+ tones: ["luxury", "editorial", "beauty", "tech", "sales"],
+ enter(t, u, o) {
+ const d = o.hero ? 0.85 : 0.7;
+ const from = Math.max(1.1 * u.lh, u.clear.down);
+ if (t < 0) return pose({ dy: from, rot: 4 * DEG * o.intensity, clip: true });
+ if (t >= d) return REST;
+ const k = enter(t / d);
+ return pose({ dy: (1 - k) * from, rot: (1 - k) * 4 * DEG * o.intensity, clip: true });
+ },
+ exitDur: 0.48,
+ exit: (e, u) => pose({ dy: -Math.max(1.1 * u.lh, u.clear.up) * exitC(e), clip: true }),
+ },
+ {
+ id: "cut-rise-glyph",
+ name: "Cut rise by letter",
+ unit: "glyph",
+ kind: "enter",
+ curve: "enter",
+ dur: 0.65,
+ each: 0.028,
+ order: "ease",
+ lineOverlap: 0.6,
+ pivot: "baseline-left",
+ tones: ["editorial", "tech"],
+ enter(t, u, o) {
+ const from = Math.max(1.05 * u.lh, u.clear.down);
+ if (t < 0) return pose({ dy: from, rot: 5 * DEG * o.intensity, clip: true });
+ if (t >= 0.65) return REST;
+ const k = enter(t / 0.65);
+ return pose({ dy: (1 - k) * from, rot: (1 - k) * 5 * DEG * o.intensity, clip: true });
+ },
+ exitDur: 0.44,
+ exit: (e, u) => pose({ dy: -Math.max(1.05 * u.lh, u.clear.up) * exitC(e), clip: true }),
+ },
+ {
+ id: "word-lift",
+ name: "Word lift",
+ unit: "word",
+ kind: "enter",
+ curve: "decel",
+ dur: 0.45,
+ each: 0.075,
+ order: "ease",
+ pivot: "baseline-left",
+ tones: ["luxury", "editorial", "sales", "tech", "beauty", "playful", "sport"],
+ enter(t, u, o) {
+ if (t < 0) return pose({ dy: 0.6 * u.em * o.intensity, opacity: 0 });
+ if (t >= 0.45) return REST;
+ return pose({ dy: (1 - decel(t / 0.45)) * 0.6 * u.em * o.intensity, opacity: at(t, 0.45 * 0.6) });
+ },
+ exitDur: 0.3,
+ exit: (e, u) => pose({ dy: -0.4 * u.em * exitC(e), opacity: 1 - exitC(e) }),
+ },
+ {
+ // Small facts (an address, a note, a date): the whole line fades in while rising a few pixels, in about a fifth
+ // of a second. Never typed letter by letter (that reads as fussy on metadata).
+ id: "fade-rise",
+ name: "Fade rise",
+ unit: "block",
+ kind: "fade",
+ curve: "decel",
+ dur: 0.22,
+ each: 0,
+ order: "ease",
+ pivot: "baseline-left",
+ tones: ["luxury", "editorial", "sales", "tech", "beauty", "playful", "sport"],
+ enter(t, u, o) {
+ if (t < 0) return pose({ dy: 0.3 * u.em * o.intensity, opacity: 0 });
+ if (t >= 0.22) return REST;
+ const k = decel(t / 0.22);
+ return pose({ dy: (1 - k) * 0.3 * u.em * o.intensity, opacity: k });
+ },
+ exitDur: 0.2,
+ exit: fadeExit,
+ },
+ {
+ id: "word-drop",
+ name: "Word drop",
+ unit: "word",
+ kind: "enter",
+ curve: "decel",
+ dur: 0.45,
+ each: 0.075,
+ order: "ease",
+ pivot: "baseline-left",
+ tones: ["editorial", "sales", "tech", "beauty", "playful"],
+ enter(t, u, o) {
+ if (t < 0) return pose({ dy: -0.6 * u.em * o.intensity, opacity: 0 });
+ if (t >= 0.45) return REST;
+ return pose({ dy: -(1 - decel(t / 0.45)) * 0.6 * u.em * o.intensity, opacity: at(t, 0.45 * 0.6) });
+ },
+ exitDur: 0.3,
+ exit: (e, u) => pose({ dy: 0.4 * u.em * exitC(e), opacity: 1 - exitC(e) }),
+ },
+ {
+ id: "curtain",
+ name: "Curtain",
+ unit: "line",
+ kind: "enter",
+ curve: "move",
+ dur: 0.6,
+ each: 0.1,
+ order: "ease",
+ pivot: "baseline-left",
+ tones: ["luxury", "beauty", "editorial"],
+ enter(t, u, o) {
+ if (t < 0) return pose({ dx: -0.1 * u.em * o.intensity, reveal: { from: 0, to: 0, feather: 0.1 } });
+ if (t >= 0.6) return REST;
+ // The soft edge runs past the end, so the last letter is fully in when the wipe ends.
+ return pose({ dx: -(1 - enter(t / 0.6)) * 0.1 * u.em * o.intensity, reveal: { from: 0, to: move(t / 0.6) * 1.1, feather: 0.1 } });
+ },
+ exitDur: 0.42,
+ exit: (e) => pose({ reveal: { from: exitC(e) * 1.1 - 0.1, to: 1.2, feather: 0.1 } }),
+ },
+ {
+ id: "bar-swipe",
+ name: "Bar swipe",
+ unit: "line",
+ kind: "enter",
+ curve: "snap",
+ dur: 7 * F + 2 * F + 0.24,
+ each: 0.1,
+ order: "ease",
+ pivot: "baseline-left",
+ tones: ["sales", "tech", "sport"],
+ never: ["luxury"],
+ enter(t) {
+ const grow = 7 * F;
+ const hold = 2 * F;
+ if (t < 0) return pose({ opacity: 0 });
+ if (t < grow) return pose({ opacity: 0, bar: { from: 0, to: snap(t / grow) } });
+ if (t < grow + hold) return pose({ bar: { from: 0, to: 1 } });
+ if (t < grow + hold + 0.24) return pose({ bar: { from: snap((t - grow - hold) / 0.24), to: 1 } });
+ return REST;
+ },
+ exitDur: 0.36,
+ exit(e) {
+ // The bar covers the line from the left, the words go, the bar leaves to the right.
+ const s = e * 0.36;
+ if (s < 5 * F) return pose({ bar: { from: 0, to: snap(s / (5 * F)) } });
+ if (s < 7 * F) return pose({ opacity: 0, bar: { from: 0, to: 1 } });
+ return pose({ opacity: 0, bar: { from: snap((s - 7 * F) / (0.36 - 7 * F)), to: 1 } });
+ },
+ },
+ {
+ id: "focus-in",
+ name: "Focus in",
+ unit: "word",
+ kind: "enter",
+ curve: "enter",
+ dur: 0.7,
+ each: 0.07,
+ order: "ease",
+ pivot: "centre",
+ tones: ["beauty", "luxury"],
+ never: ["sales"],
+ enter(t, u, o) {
+ if (t < 0) return pose({ blur: 16 * o.intensity, opacity: 0, sx: 1.06, sy: 1.06 });
+ if (t >= 0.7) return REST;
+ const k = cubic.out(t / 0.7);
+ const s = 1.06 - 0.06 * k;
+ return pose({ blur: 16 * (1 - k) * o.intensity, opacity: k, sx: s, sy: s });
+ },
+ exitDur: 0.48,
+ exit(e, u, o) {
+ const k = exitC(e);
+ const s = 1 + 0.06 * k;
+ return pose({ blur: 16 * k * o.intensity, opacity: 1 - k, sx: s, sy: s });
+ },
+ },
+ {
+ id: "track-in",
+ name: "Track in",
+ unit: "block",
+ kind: "move",
+ curve: "decel",
+ dur: 3,
+ each: 0,
+ order: "ease",
+ pivot: "centre",
+ widest: { tracking: 0.4 },
+ tones: ["luxury", "beauty", "editorial"],
+ enter(t, u, o) {
+ const d = 3;
+ if (t < 0) return pose({ opacity: 0, blur: 6, tracking: 0.4 });
+ if (t >= d) return REST;
+ return pose({ opacity: at(t, 0.2 * d), blur: 6 * (1 - at(t, 0.4 * d)) * o.intensity, tracking: 0.4 - 0.4 * decel(t / d) });
+ },
+ exitDur: 0.6,
+ exit: (e) => pose({ opacity: 1 - exitC(e), tracking: 0.15 * exitC(e) }),
+ },
+ {
+ id: "snap-tight",
+ name: "Snap tight",
+ unit: "block",
+ kind: "enter",
+ curve: "enter",
+ dur: 0.5,
+ each: 0,
+ order: "ease",
+ pivot: "centre",
+ widest: { tracking: 0.17 },
+ tones: ["sport", "tech", "sales"],
+ enter(t) {
+ if (t < 0) return pose({ opacity: 0, tracking: 0.17 });
+ if (t >= 0.5) return REST;
+ return pose({ opacity: at(t, 0.12), tracking: 0.17 * (1 - enter(t / 0.5)) });
+ },
+ exitDur: 0.34,
+ exit: (e) => pose({ opacity: 1 - exitC(e), tracking: 0.12 * exitC(e) }),
+ },
+ {
+ id: "slow-drift",
+ name: "Slow drift",
+ unit: "block",
+ kind: "move",
+ curve: "decel",
+ dur: 1.1,
+ each: 0,
+ order: "ease",
+ pivot: "centre",
+ tones: ["luxury", "beauty", "editorial"],
+ never: ["sport"],
+ enter(t, u, o) {
+ if (t < 0) return pose({ dx: -0.25 * u.em * o.intensity, opacity: 0 });
+ if (t >= 1.1) return REST;
+ const k = decel(t / 1.1);
+ return pose({ dx: -(1 - k) * 0.25 * u.em * o.intensity, opacity: k });
+ },
+ exitDur: 0.7,
+ exit: (e, u) => pose({ dx: 0.25 * u.em * exitC(e), opacity: 1 - exitC(e) }),
+ },
+ {
+ id: "stomp",
+ name: "Stomp",
+ unit: "word",
+ kind: "slam",
+ curve: "slam",
+ dur: 5 * F,
+ each: 0.12,
+ order: "ease",
+ stagger: "elements",
+ pivot: "centre",
+ widest: { scale: 1 },
+ signature: true,
+ tones: ["sales", "sport", "playful"],
+ never: ["luxury", "beauty"],
+ enter(t, u, o) {
+ // Timed in frames (with a hair of tolerance, so frame 12 is frame 12 whatever the float error).
+ const f = t / F + 1e-6;
+ const A = 5;
+ if (f < 1e-6) return HIDDEN;
+ if (f < A) {
+ const s = 1.8 - 0.8 * expoIn(t / (A * F));
+ return pose({ sx: 1 + (s - 1) * o.intensity, sy: 1 + (s - 1) * o.intensity, opacity: at(t, 2 * F) });
+ }
+ const g = Math.min(1, (t - A * F) / (7 * F));
+ const ghost = f < 12 ? { s: 1 + 0.15 * g, a: 0.35 * (1 - g) } : undefined;
+ if (f < A + 1) return pose({ sx: 1 + 0.03 * o.intensity, sy: 1 - 0.04 * o.intensity, ghost });
+ if (f < A + 2) {
+ const k = snap(Math.max(0, (t - (A + 1) * F) / F));
+ return pose({ sx: 1 + 0.03 * o.intensity * (1 - k), sy: 1 - 0.04 * o.intensity * (1 - k), ghost });
+ }
+ return ghost ? pose({ ghost }) : REST;
+ },
+ exitDur: 0.2,
+ exit(e) {
+ const k = exitC(e);
+ return pose({ sx: 1 - 0.08 * k, sy: 1 - 0.08 * k, opacity: 1 - k });
+ },
+ },
+ {
+ id: "beat-cut",
+ name: "Beat cut",
+ unit: "word",
+ kind: "move",
+ curve: "snap",
+ dur: 0.5,
+ each: 0.5,
+ order: "ease",
+ stagger: "elements",
+ pivot: "centre",
+ together: true,
+ tones: ["sport", "sales"],
+ never: ["luxury"],
+ enter(t, u, o) {
+ // Each word owns a beat, alone and as big as the block; then the whole line lands together.
+ const beat = o.beat;
+ const mine = u.index * beat;
+ const all = u.count * beat;
+ if (t < mine) return HIDDEN;
+ if (t < mine + beat && t < all) {
+ const s0 = Math.min(2.5, Math.max(1, (u.block.w * 0.92) / Math.max(1, u.w)));
+ const k = snap(at(t - mine, 4 * F));
+ const s = s0 * (1.15 - 0.15 * k);
+ return pose({ dx: u.block.x + u.block.w / 2 - (u.x + u.w / 2), dy: u.block.y + u.block.h / 2 - (u.y + u.h / 2), sx: s, sy: s });
+ }
+ if (t < all) return HIDDEN;
+ if (t < all + 6 * F) {
+ const s = 1.06 - 0.06 * snap((t - all) / (6 * F));
+ return pose({ sx: s, sy: s });
+ }
+ return REST;
+ },
+ exitDur: 0.2,
+ exit: (e) => pose({ opacity: e < 0.5 ? 1 : 0 }),
+ },
+ {
+ id: "punch",
+ name: "Punch",
+ unit: "word",
+ kind: "enter",
+ curve: "snap",
+ dur: 0.36,
+ each: 0.08,
+ order: "ease",
+ pivot: "baseline-centre",
+ tones: ["sport", "sales", "playful"],
+ never: ["luxury"],
+ enter(t, u, o) {
+ if (t < 0) return HIDDEN;
+ if (t >= 0.36) return REST;
+ const i = o.intensity;
+ if (t < 0.2) {
+ const k = snap(t / 0.2);
+ return pose({ sx: 1 + (0.6 - 0.65 * k) * i, sy: 1 + (-0.3 + 0.38 * k) * i });
+ }
+ const k = move((t - 0.2) / 0.16);
+ return pose({ sx: 1 - 0.05 * (1 - k) * i, sy: 1 + 0.08 * (1 - k) * i });
+ },
+ exitDur: 0.24,
+ exit: fadeExit,
+ },
+ {
+ id: "pop-in",
+ name: "Pop in",
+ unit: "glyph",
+ kind: "enter",
+ curve: "pop",
+ dur: 0.38,
+ each: 0.03,
+ order: "ease",
+ pivot: "baseline-centre",
+ widest: { scale: 1.12 },
+ tones: ["playful", "sales"],
+ never: ["luxury"],
+ enter(t, u, o) {
+ if (t < 0) return HIDDEN;
+ if (t >= 0.38) return REST;
+ const p = t / 0.38;
+ const s = p < 0.6 ? 1.12 * enter(p / 0.6) : p < 0.8 ? 1.12 - 0.15 * move((p - 0.6) / 0.2) : 0.97 + 0.03 * move((p - 0.8) / 0.2);
+ const r = sign(o, "pop", u.index) * 4 * DEG * (1 - enter(p)) * o.intensity;
+ return pose({ sx: 1 + (s - 1) * (s > 1 ? o.intensity : 1), sy: 1 + (s - 1) * (s > 1 ? o.intensity : 1), rot: r, opacity: at(p, 0.15) });
+ },
+ exitDur: 0.26,
+ exit(e) {
+ const s = 1 - exitC(e);
+ return pose({ sx: s, sy: s, opacity: s > 0.05 ? 1 : 0 });
+ },
+ },
+ {
+ id: "burst",
+ name: "Burst",
+ unit: "glyph",
+ kind: "enter",
+ curve: "pop",
+ dur: 0.45,
+ each: 0.022,
+ order: "centre",
+ pivot: "centre",
+ widest: { scale: 1.1 },
+ tones: ["playful", "sales"],
+ never: ["luxury"],
+ enter(t, u, o) {
+ if (t < 0) return HIDDEN;
+ if (t >= 0.45) return REST;
+ const p = t / 0.45;
+ const k = back14(p);
+ const cx = u.block.x + u.block.w / 2;
+ const cy = u.block.y + u.block.h / 2;
+ const ux = u.x + u.w / 2;
+ const uy = u.y + u.h / 2;
+ const travel = clamp(enter(p));
+ return pose({ dx: (cx - ux) * (1 - travel), dy: (cy - uy) * (1 - travel) - Math.sin(Math.PI * travel) * 0.3 * u.em * o.intensity, sx: Math.max(0, k), sy: Math.max(0, k), opacity: at(p, 0.1) });
+ },
+ exitDur: 0.3,
+ exit(e) {
+ const s = 1 - exitC(e);
+ return pose({ sx: s, sy: s, opacity: s > 0.05 ? 1 : 0 });
+ },
+ },
+ {
+ id: "inflate",
+ name: "Inflate",
+ unit: "glyph",
+ kind: "enter",
+ curve: "pop",
+ dur: 0.5,
+ each: 0.04,
+ order: "ease",
+ pivot: "baseline-centre",
+ widest: { scale: 1.15 },
+ tones: ["playful"],
+ never: ["luxury", "editorial", "tech"],
+ enter(t, u, o) {
+ if (t < 0) return HIDDEN;
+ if (t >= 0.5) return REST;
+ const p = t / 0.5;
+ const s = 0.6 + 0.4 * elastic14(p);
+ return pose({ sx: s, sy: s, rot: sign(o, "inflate", u.index) * 3 * DEG * (1 - p) * o.intensity, opacity: at(p, 0.12) });
+ },
+ exitDur: 0.3,
+ exit(e) {
+ const s = 1 - 0.4 * exitC(e);
+ return pose({ sx: s, sy: s, opacity: 1 - exitC(e) });
+ },
+ },
+ {
+ id: "merge",
+ name: "Merge",
+ unit: "line",
+ kind: "enter",
+ curve: "enter",
+ dur: 0.6,
+ each: 0.08,
+ order: "ease",
+ pivot: "centre",
+ tones: ["sport", "editorial", "tech"],
+ enter(t, u, o) {
+ const side = u.line % 2 === 0 ? -1 : 1;
+ if (t < 0) return pose({ dx: side * 0.4 * u.frame.w * o.intensity });
+ if (t >= 0.6) return REST;
+ return pose({ dx: side * 0.4 * u.frame.w * (1 - enter(t / 0.6)) * o.intensity });
+ },
+ exitDur: 0.42,
+ exit: (e, u) => pose({ dx: (u.line % 2 === 0 ? -1 : 1) * 0.4 * u.frame.w * exitC(e) }),
+ },
+ {
+ id: "plates",
+ name: "Plates",
+ unit: "line",
+ kind: "enter",
+ curve: "enter",
+ dur: 0.6,
+ each: 0.08,
+ order: "ease",
+ pivot: "centre",
+ tones: ["editorial", "tech", "sales"],
+ enter(t, u, o) {
+ const side = u.line % 2 === 0 ? -1 : 1;
+ if (t < 0) return pose({ dx: side * 0.4 * u.frame.w * o.intensity });
+ if (t >= 0.6) return REST;
+ return pose({ dx: side * 0.4 * u.frame.w * (1 - back11(t / 0.6)) * o.intensity });
+ },
+ exitDur: 0.42,
+ exit: (e, u) => pose({ dx: (u.line % 2 === 0 ? -1 : 1) * 0.4 * u.frame.w * exitC(e) }),
+ },
+ {
+ id: "slide-in",
+ name: "Slide in",
+ unit: "block",
+ kind: "enter",
+ curve: "enter",
+ dur: 0.5,
+ each: 0,
+ order: "ease",
+ pivot: "centre",
+ tones: ["luxury", "editorial", "sales", "tech", "beauty", "playful", "sport"],
+ enter(t, u, o) {
+ if (t < 0) return pose({ dx: 0.3 * u.frame.w * o.intensity, opacity: 0 });
+ if (t >= 0.5) return REST;
+ const k = quart.out(t / 0.5);
+ return pose({ dx: 0.3 * u.frame.w * (1 - k) * o.intensity, opacity: k });
+ },
+ exitDur: 0.34,
+ exit: (e, u) => pose({ dx: -0.3 * u.frame.w * exitC(e), opacity: 1 - exitC(e) }),
+ },
+ {
+ id: "flip-up",
+ name: "Flip up",
+ unit: "glyph",
+ kind: "enter",
+ curve: "enter",
+ dur: 0.65,
+ each: 0.045,
+ order: "ease",
+ pivot: "baseline-centre",
+ tones: ["tech", "sales"],
+ enter(t, u) {
+ if (t < 0) return flipPose(-95 * DEG, u);
+ if (t >= 0.65) return REST;
+ return flipPose(-95 * DEG * (1 - enter(t / 0.65)), u);
+ },
+ exitDur: 0.44,
+ exit: (e, u) => flipPose(95 * DEG * exitC(e), u),
+ },
+ {
+ id: "fold",
+ name: "Fold",
+ unit: "line",
+ kind: "enter",
+ curve: "enter",
+ dur: 0.5,
+ each: 0.12,
+ order: "ease",
+ pivot: "midline",
+ tones: ["editorial"],
+ enter(t) {
+ if (t < 0) return pose({ fold: Math.PI / 2, shade: 0.3 });
+ if (t >= 0.5) return REST;
+ const k = cubic.out(t / 0.5);
+ return pose({ fold: (Math.PI / 2) * (1 - k), shade: 0.3 * (1 - k) });
+ },
+ exitDur: 0.34,
+ exit: (e) => pose({ fold: (Math.PI / 2) * exitC(e), shade: 0.3 * exitC(e), opacity: e < 1 ? 1 : 0 }),
+ },
+ {
+ id: "tumble",
+ name: "Tumble",
+ unit: "word",
+ kind: "enter",
+ curve: "enter",
+ dur: 0.6,
+ each: 0.08,
+ order: "ease",
+ pivot: "bottom-left",
+ tones: ["playful"],
+ never: ["luxury", "editorial", "tech"],
+ enter(t, u, o) {
+ if (t < 0) return HIDDEN;
+ if (t >= 0.6) return REST;
+ const k = back12(t / 0.6);
+ return pose({ rot: 160 * DEG * (1 - k) * o.intensity, dy: 0.4 * u.em * (1 - k) * o.intensity, opacity: at(t, 0.18) });
+ },
+ exitDur: 0.4,
+ exit: fadeExit,
+ },
+ {
+ id: "type-on",
+ name: "Type on",
+ unit: "glyph",
+ kind: "move",
+ curve: "linear",
+ dur: 0.05,
+ each: 0.05,
+ order: "ease",
+ pivot: "baseline-left",
+ together: true,
+ tones: ["tech", "editorial"],
+ enter(t, u, o) {
+ return t >= u.index / o.rate ? REST : HIDDEN;
+ },
+ exitDur: 0.3,
+ exit: (e, u) => (e * u.count >= u.count - u.index ? HIDDEN : REST),
+ },
+ {
+ id: "scramble",
+ name: "Scramble",
+ unit: "glyph",
+ kind: "move",
+ curve: "linear",
+ dur: 0.6,
+ each: 0,
+ order: "ease",
+ pivot: "baseline-left",
+ together: true,
+ signature: true,
+ tones: ["tech", "sport"],
+ never: ["luxury", "beauty", "playful"],
+ enter(t, u, o) {
+ if (t < 0) return HIDDEN;
+ const lock = scrambleLock(u);
+ if (t >= lock) return REST;
+ // A new letter every two frames, seeded by slot and moment.
+ const step = Math.floor(t / (2 * F) + 1e-6);
+ const shown = otherLetter(u.text, o, "scramble", u.index, step);
+ const split = (2 + 8 * rng(o.seed, "split", step)) * (1 - t / 0.6) * o.intensity;
+ return pose({ shown, split });
+ },
+ exitDur: 0.3,
+ exit: fadeExit,
+ },
+ {
+ id: "neon-strike",
+ name: "Neon strike",
+ unit: "block",
+ kind: "fade",
+ curve: "linear",
+ dur: 14 * F,
+ each: 0,
+ order: "ease",
+ pivot: "centre",
+ signature: true,
+ tones: ["sport"],
+ never: ["luxury", "beauty"],
+ enter(t) {
+ if (t < 0) return pose({ glow: 0, shade: 0.6 });
+ const g = neonAt(t);
+ return g >= 1 && t >= 13 * F ? REST : pose({ glow: g, shade: 0.6 * (1 - g) });
+ },
+ exitDur: 0.3,
+ exit: (e) => pose({ glow: 1 - exitC(e), shade: 0.6 * exitC(e), opacity: 1 - exitC(e) * 0.6 }),
+ },
+ {
+ id: "split-flap",
+ name: "Split flap",
+ unit: "glyph",
+ kind: "move",
+ curve: "linear",
+ dur: 0.4,
+ each: 0.03,
+ order: "ease",
+ pivot: "midline",
+ tones: ["tech", "sales"],
+ enter(t, u, o) {
+ const flips = flapCount(u, o);
+ if (t < 0) return pose({ flap: { from: flapLetter(u, o, 0, flips), to: flapLetter(u, o, 0, flips), phase: 0 } });
+ const step = Math.floor(t / 0.05 + 1e-6);
+ if (step >= flips) return REST;
+ return pose({ flap: { from: flapLetter(u, o, step, flips), to: flapLetter(u, o, step + 1, flips), phase: (t - step * 0.05) / 0.05 } });
+ },
+ exitDur: 0.3,
+ exit: fadeExit,
+ },
+ {
+ id: "odometer",
+ name: "Odometer",
+ unit: "glyph",
+ kind: "move",
+ curve: "roll",
+ dur: 1.4,
+ each: 0.05,
+ order: "reverse",
+ pivot: "midline",
+ tones: ["tech", "sales"],
+ enter(t, u) {
+ // A separator ($ , . % ×) is never drawn before the figures round it: it fades in over the second half of its
+ // column's roll, with the digits.
+ if (!/^\p{Nd}$/u.test(u.text)) {
+ if (t < 0.55) return pose({ opacity: 0 });
+ if (t >= 0.85) return REST;
+ return pose({ opacity: (t - 0.55) / 0.3 });
+ }
+ const target = Number(u.text);
+ // Each figure rolls up once from a blank place below 0 to its own value (never more than ten places, so at 30 fps
+ // a column moves under half a figure a frame and never smears). A number's leading column only rises into place
+ // (never a leading zero); before its start a column is blank (never a placeholder 0).
+ const from = u.lead ? target : 0;
+ if (t < 0) return pose({ roll: from - 1, rollFrom: from });
+ if (t >= 1.4) return REST;
+ return pose({ roll: from - 1 + (target - from + 1) * roll(t / 1.4), rollFrom: from });
+ },
+ exitDur: 0.3,
+ exit: fadeExit,
+ },
+ {
+ id: "cut-paper",
+ name: "Cut paper",
+ unit: "word",
+ kind: "move",
+ curve: "snap",
+ dur: 0.3,
+ each: 0.12,
+ order: "ease",
+ stagger: "elements",
+ pivot: "centre",
+ widest: { scale: 1.15 },
+ tones: ["playful"],
+ never: ["luxury", "tech"],
+ enter(t, u, o) {
+ if (t < 0) return HIDDEN;
+ // Animated on twos, like paper moved by hand; it lands on its last step.
+ if (t >= 0.3) return REST;
+ const s = Math.floor(t * 12 + 1e-6) / 12;
+ const p = s / 0.3;
+ const rot = p < 0.6 ? (-8 + 11 * snap(p / 0.6)) * DEG : 3 * DEG * (1 - snap((p - 0.6) / 0.4));
+ const sc = p < 0.6 ? 1.15 - 0.15 * snap(p / 0.6) : 1;
+ return pose({ rot: rot * o.intensity, sx: 1 + (sc - 1) * o.intensity, sy: 1 + (sc - 1) * o.intensity });
+ },
+ exitDur: 0.2,
+ exit: (e) => (e < 0.5 ? pose({ rot: -4 * DEG }) : HIDDEN),
+ },
+ {
+ id: "weight-wave",
+ name: "Weight wave",
+ unit: "glyph",
+ kind: "move",
+ curve: "snap",
+ dur: 1,
+ each: 0.04,
+ order: "ease",
+ pivot: "baseline-left",
+ widest: { weight: 900 },
+ tones: ["tech", "sport"],
+ enter(t) {
+ if (t < 0) return HIDDEN;
+ if (t >= 1) return REST;
+ // 200 → 900 → the face's own weight; the drawer clamps to what the face has.
+ if (t < 0.5) return pose({ weight: 200 + 700 * snap(t / 0.5) });
+ return pose({ weight: 900 - 200 * snap((t - 0.5) / 0.5) });
+ },
+ exitDur: 0.3,
+ exit: fadeExit,
+ },
+ {
+ id: "ink-draw",
+ name: "Ink draw",
+ unit: "block",
+ kind: "draw",
+ curve: "draw",
+ dur: 0.75,
+ each: 0,
+ order: "ease",
+ pivot: "baseline-left",
+ tones: ["editorial", "beauty", "playful", "luxury"],
+ enter(t) {
+ if (t < 0) return pose({ reveal: { from: 0, to: 0, feather: 0.12 } });
+ if (t >= 0.75) return REST;
+ return pose({ reveal: { from: 0, to: draw(t / 0.75) * 1.12, feather: 0.12 } });
+ },
+ exitDur: 0.5,
+ exit: (e) => pose({ opacity: 1 - exitC(e) }),
+ },
+];
+
+/** Fake 3D: a letter turned θ about its baseline (0 = facing us), squeezed, sheared, shaded and faded as it turns. */
+function flipPose(theta: number, u: UnitInfo): Pose {
+ const a = Math.abs(theta);
+ return pose({ sy: Math.max(0.001, Math.cos(theta)), skewX: Math.sin(theta) * 0.12, dy: -Math.sin(theta) * 0.6 * u.cap, shade: 0.35 * Math.min(1, a / (Math.PI / 2)), opacity: clamp((Math.PI / 2 - a) / (Math.PI / 4)) });
+}
+
+/** When a scramble's slot locks onto its own letter: 0.25 s in, then left to right, every slot by 0.6 s. */
+export function scrambleLock(u: Pick<UnitInfo, "index" | "count">): number {
+ const each = u.count > 1 ? Math.min(0.03, 0.35 / (u.count - 1)) : 0;
+ return 0.25 + u.index * each;
+}
+
+/** The neon tube's light by frame: two false starts, then on. */
+const NEON = [0, 0, 0.6, 0, 0, 0, 0.4, 0, 0, 1, 1, 1, 0.8, 1];
+export function neonAt(t: number): number {
+ const f = Math.floor(t / F + 1e-6);
+ return f < 0 ? 0 : f >= NEON.length ? 1 : NEON[f];
+}
+
+/** How many flips a split-flap tile makes (4–8, seeded). */
+export const flapCount = (u: Pick<UnitInfo, "index">, o: Pick<PresetOptions, "seed">): number => 4 + Math.floor(rng(o.seed, "flaps", u.index) * 5);
+
+/** The letter a tile shows after `step` flips: seeded letters of its kind, ending on its own. */
+function flapLetter(u: UnitInfo, o: PresetOptions, step: number, flips: number): string {
+ // Separators (":", "·", "/") never flip: only letters and figures cycle, each through its own kind.
+ if (!/^[\p{L}\p{Nd}]$/u.test(u.text)) return u.text;
+ if (step >= flips) return u.text;
+ // A figure counts up to its own value (never past it), so a clock column only ever shows a time that can be (no
+ // "63" minutes on the way to "12").
+ if (/^\p{Nd}$/u.test(u.text)) return String(Math.max(0, Number(u.text) - (flips - step)));
+ return otherLetter(u.text, o, "flap", u.index, step);
+}
+
+export const PRESETS: Readonly<Record<PresetId, Preset>> = Object.freeze(Object.fromEntries(P.map((p) => [p.id, p])) as Record<PresetId, Preset>);
+export const PRESET_IDS = P.map((p) => p.id);
+
+/** The presets that suit a tone (and aren't ruled out for it). */
+export const presetsFor = (tone: Tone): Preset[] => P.filter((p) => p.tones.includes(tone) && !p.never?.includes(tone));
+
+// ---------------------------------------------------------------------------
+// Loops and emphasis (after the entrance)
+
+export type LoopId = "breathe" | "pulse" | "wiggle" | "light-sweep" | "chrome-flow" | "ghost-drift" | "push-in";
+
+export interface LoopPose {
+ /** Scale about the block's centre. */
+ s: number;
+ rot: number;
+ dx: number;
+ dy: number;
+ /** A light band's place across the block (0–1, from before its left edge to past its right), or null when none crosses. */
+ sweep: number | null;
+ /** A chrome horizon's shift (share of the cap height). */
+ flow: number;
+}
+
+export const LOOP_REST: Readonly<LoopPose> = Object.freeze({ s: 1, rot: 0, dx: 0, dy: 0, sweep: null, flow: 0 });
+
+export interface LoopOptions {
+ seed: number;
+ /** Seconds a cycle (each loop has its own default). */
+ period?: number;
+ /** Seconds between pulses or sweeps (one-shot when absent). */
+ every?: number;
+ /** For ghost-drift and push-in: the frame's width and the clip's length. */
+ frameW?: number;
+ duration?: number;
+ /** Seconds after the loop starts by which a sweep must have crossed (a sweep that can't finish by then doesn't start). */
+ until?: number;
+}
+
+/** A loop's pose `t` seconds after it starts. Breathe, pulse and wiggle are at rest at the end of every cycle. */
+export function loopAt(id: LoopId, t: number, o: LoopOptions): LoopPose {
+ if (t < 0) return LOOP_REST;
+ switch (id) {
+ case "breathe": {
+ const P = o.period ?? 2.8;
+ return { ...LOOP_REST, s: 1 + 0.02 * (1 - Math.cos((2 * Math.PI * t) / P)) / 2 };
+ }
+ case "pulse": {
+ // 100 → 102 % (held three frames) → 100 % in 300 ms, a few frames after landing; again every `every` seconds.
+ const local = o.every ? t % o.every : t;
+ const d = local - 4 * F;
+ if (d < 0 || d >= 0.3) return LOOP_REST;
+ const up = 0.3 / 2 - 1.5 * F;
+ const s = d < up ? Math.sin(((d / up) * Math.PI) / 2) : d < up + 3 * F ? 1 : Math.cos((((d - up - 3 * F) / (0.3 - up - 3 * F)) * Math.PI) / 2);
+ return { ...LOOP_REST, s: 1 + 0.02 * s };
+ }
+ case "wiggle": {
+ const P = o.period ?? 0.8;
+ const cycle = Math.floor(t / P);
+ const p = (t % P) / P;
+ const env = Math.sin(Math.PI * p);
+ return { ...LOOP_REST, rot: (rng(o.seed, "wiggle-r", cycle) * 2 - 1) * 3 * DEG * env, dx: (rng(o.seed, "wiggle-x", cycle) * 2 - 1) * 3 * env, dy: (rng(o.seed, "wiggle-y", cycle) * 2 - 1) * 3 * env };
+ }
+ case "light-sweep": {
+ // 800 ms across, starting 200 ms in; again every `every` seconds (never sooner than 1.6 s). A sweep that can't
+ // cross before `until` doesn't start (the last frame is the poster, with no band on it).
+ const every = o.every ? Math.max(1.6, o.every) : 0;
+ const local = every ? t % every : t;
+ const d = local - 0.2;
+ if (d < 0 || d >= 0.8) return LOOP_REST;
+ if (o.until !== undefined && t - d + 1.0 > o.until) return LOOP_REST;
+ return { ...LOOP_REST, sweep: move(d / 0.8) };
+ }
+ case "chrome-flow": {
+ const P = o.period ?? 2.5;
+ return { ...LOOP_REST, flow: 0.05 * Math.sin((2 * Math.PI * t) / P) };
+ }
+ case "ghost-drift": {
+ // 3 % of the frame's width a second, so a loop of the clip's length closes on a whole cycle of the pattern.
+ return { ...LOOP_REST, dx: 0.03 * (o.frameW ?? 1080) * t };
+ }
+ case "push-in": {
+ const d = o.duration ?? 5;
+ const k = (1 - Math.cos(Math.PI * clamp(t / d))) / 2;
+ return { ...LOOP_REST, s: 1 + 0.06 * k, dx: -0.015 * (o.frameW ?? 1080) * k };
+ }
+ }
+}
+
+export type { Ease };
diff --git a/src/lib/template-covers.generated.ts b/src/lib/template-covers.generated.ts
index 16b47551..5fbaba5e 100644
--- a/src/lib/template-covers.generated.ts
+++ b/src/lib/template-covers.generated.ts
@@ -25,19 +25,27 @@ export const TEMPLATE_COVERS: Record<string, TemplateCoverEntry> = {
"marketing/ad-five-stars": "93cc91cb",
"marketing/ad-hero-headline": "8ba3422e",
"marketing/m2-comic-panels": "5b751ae1",
- "marketing/m2-line-reveal": {"poster":"/previews/templates/marketing/m2-line-reveal.jpg?v=8cbf4273","video":"/previews/templates/marketing/m2-line-reveal.mp4?v=d1197cd3","at":4.958},
- "marketing/m2-offer-badge": {"poster":"/previews/templates/marketing/m2-offer-badge.jpg?v=7d152c52","video":"/previews/templates/marketing/m2-offer-badge.mp4?v=0cb7518f","at":4.958},
+ "marketing/m2-line-reveal": {"poster":"/previews/templates/marketing/m2-line-reveal.jpg?v=74a2886a","video":"/previews/templates/marketing/m2-line-reveal.mp4?v=b4281d49","at":4.958},
+ "marketing/m2-midnight-drop": {"poster":"/previews/templates/marketing/m2-midnight-drop.jpg?v=58e6043e","video":"/previews/templates/marketing/m2-midnight-drop.mp4?v=c870f49e","at":4.958},
+ "marketing/m2-nocturne": {"poster":"/previews/templates/marketing/m2-nocturne.jpg?v=f6c16dca","video":"/previews/templates/marketing/m2-nocturne.mp4?v=29d3729a","at":4.958},
+ "marketing/m2-offer-badge": {"poster":"/previews/templates/marketing/m2-offer-badge.jpg?v=99be5571","video":"/previews/templates/marketing/m2-offer-badge.mp4?v=3a80ac17","at":4.958},
"marketing/m2-paper-parade": "a21bc137",
- "marketing/m2-retro-starburst": {"poster":"/previews/templates/marketing/m2-retro-starburst.jpg?v=fd1bb596","video":"/previews/templates/marketing/m2-retro-starburst.mp4?v=4c8bb0ab","at":4.958},
+ "marketing/m2-prism-stage": {"poster":"/previews/templates/marketing/m2-prism-stage.jpg?v=02d04aae","video":"/previews/templates/marketing/m2-prism-stage.mp4?v=d86dd99a","at":4.958},
+ "marketing/m2-retro-starburst": {"poster":"/previews/templates/marketing/m2-retro-starburst.jpg?v=dd07b39f","video":"/previews/templates/marketing/m2-retro-starburst.mp4?v=50f9858b","at":4.958},
+ "marketing/m2-season-finale": {"poster":"/previews/templates/marketing/m2-season-finale.jpg?v=cd88f8e8","video":"/previews/templates/marketing/m2-season-finale.mp4?v=71466398","at":4.958},
"marketing/m2-sticker-pop": "eb15d9a1",
"marketing/mk-clean-listing": "875102cc",
- "marketing/ms-big-number": {"poster":"/previews/templates/marketing/ms-big-number.jpg?v=2253282e","video":"/previews/templates/marketing/ms-big-number.mp4?v=a68c4477","at":4.958},
- "marketing/ms-dashboard-zoom": {"poster":"/previews/templates/marketing/ms-dashboard-zoom.jpg?v=9f6863e1","video":"/previews/templates/marketing/ms-dashboard-zoom.mp4?v=90300e75","at":4.958},
- "marketing/ms-end-card": {"poster":"/previews/templates/marketing/ms-end-card.jpg?v=a445714e","video":"/previews/templates/marketing/ms-end-card.mp4?v=b706f02c","at":2.458},
- "marketing/ms-feature-cards": {"poster":"/previews/templates/marketing/ms-feature-cards.jpg?v=0adfaea1","video":"/previews/templates/marketing/ms-feature-cards.mp4?v=db6c688f","at":4.958},
- "marketing/ms-five-star-quote": {"poster":"/previews/templates/marketing/ms-five-star-quote.jpg?v=5a4d1301","video":"/previews/templates/marketing/ms-five-star-quote.mp4?v=af449d3c","at":4.958},
- "marketing/ms-kinetic-headline": {"poster":"/previews/templates/marketing/ms-kinetic-headline.jpg?v=b0473175","video":"/previews/templates/marketing/ms-kinetic-headline.mp4?v=911ab1f4","at":2.167},
- "marketing/ms-logo-sting": {"poster":"/previews/templates/marketing/ms-logo-sting.jpg?v=46c7b096","video":"/previews/templates/marketing/ms-logo-sting.mp4?v=bf3836cc","at":4.958},
+ "marketing/mm-marquee": {"poster":"/previews/templates/marketing/mm-marquee.jpg?v=38e869ea","video":"/previews/templates/marketing/mm-marquee.mp4?v=03de1453","at":4.958},
+ "marketing/mm-runway-titles": {"poster":"/previews/templates/marketing/mm-runway-titles.jpg?v=5b71e788","video":"/previews/templates/marketing/mm-runway-titles.mp4?v=59a521b6","at":4.958},
+ "marketing/ms-big-number": {"poster":"/previews/templates/marketing/ms-big-number.jpg?v=abb8f8b4","video":"/previews/templates/marketing/ms-big-number.mp4?v=71208fcc","at":4.958},
+ "marketing/ms-dashboard-zoom": {"poster":"/previews/templates/marketing/ms-dashboard-zoom.jpg?v=c668a573","video":"/previews/templates/marketing/ms-dashboard-zoom.mp4?v=d66d8690","at":4.958},
+ "marketing/ms-end-card": {"poster":"/previews/templates/marketing/ms-end-card.jpg?v=e564df2e","video":"/previews/templates/marketing/ms-end-card.mp4?v=9dae8de2","at":3.958},
+ "marketing/ms-feature-cards": {"poster":"/previews/templates/marketing/ms-feature-cards.jpg?v=22441f23","video":"/previews/templates/marketing/ms-feature-cards.mp4?v=1dbdbb4a","at":4.958},
+ "marketing/ms-five-star-quote": {"poster":"/previews/templates/marketing/ms-five-star-quote.jpg?v=3c2c82bd","video":"/previews/templates/marketing/ms-five-star-quote.mp4?v=4359c40d","at":4.958},
+ "marketing/ms-kind-words": {"poster":"/previews/templates/marketing/ms-kind-words.jpg?v=50e9b651","video":"/previews/templates/marketing/ms-kind-words.mp4?v=8751af96","at":4.958},
+ "marketing/ms-kinetic-headline": {"poster":"/previews/templates/marketing/ms-kinetic-headline.jpg?v=ff3d3096","video":"/previews/templates/marketing/ms-kinetic-headline.mp4?v=af6644f0","at":4.958},
+ "marketing/ms-logo-sting": {"poster":"/previews/templates/marketing/ms-logo-sting.jpg?v=7344d353","video":"/previews/templates/marketing/ms-logo-sting.mp4?v=cebf16a5","at":4.958},
+ "marketing/ms-stat-stack": {"poster":"/previews/templates/marketing/ms-stat-stack.jpg?v=fe15b920","video":"/previews/templates/marketing/ms-stat-stack.mp4?v=48ddf7b0","at":4.958},
"marketing/po-retro-sunburst": "4c19058c",
"marketing/po-riso-bloom": "69f64638",
"marketing/po-swiss-grid": "3c9c9370",
diff --git a/src/proxy.ts b/src/proxy.ts
index c9dcf9ab..722e2546 100644
--- a/src/proxy.ts
+++ b/src/proxy.ts
@@ -379,13 +379,14 @@ export function proxy(request: NextRequest) {
export const config = {
// Everything except build assets and the public folder's own files: the favicon and app icons,
- // the demo samples, the preset covers, the examples pages load (public/examples), vendored scripts (the 3D viewer's meshopt decoder) and the
+ // the demo samples, the preset covers, the examples pages load (public/examples), vendored scripts (the 3D viewer's meshopt decoder), the
+ // motion templates' own type faces (public/fonts) and the
// SVGs at the root. Generated SVGs under /api/files stay behind sign-in. The routes that take a file in a form
// (/api/uploads, a Soul finish, a Layers render, a skill upload, an Assist source, an explainer document), and Split
// soundtrack's mix export (a WAV in parts of 16 MB), make the same checks themselves (src/server/direct-gate.ts): the
// proxy would hold the whole file in memory first. So do a computer's report of a finished job and its results
// (src/app/api/gpu/computer/tasks), and live edit's kept master from a tab on its own computer (src/app/api/live/masters).
matcher: [
- "/((?!_next/static|_next/image|favicon\\.ico$|apple-icon\\.png$|samples/|previews/|examples/|vendor/|api/uploads$|api/generations/[^/]+/finish$|api/layers/renders$|api/assist/skills/upload$|api/assist/projects/[^/]+/sources$|api/explainer/document$|api/audio-tools/export$|api/gpu/computer/tasks/[^/]+/(?:report|outputs/[^/]+)$|api/live/masters$|[^/]+\\.svg$).*)",
+ "/((?!_next/static|_next/image|favicon\\.ico$|apple-icon\\.png$|samples/|previews/|examples/|vendor/|fonts/|api/uploads$|api/generations/[^/]+/finish$|api/layers/renders$|api/assist/skills/upload$|api/assist/projects/[^/]+/sources$|api/explainer/document$|api/audio-tools/export$|api/gpu/computer/tasks/[^/]+/(?:report|outputs/[^/]+)$|api/live/masters$|[^/]+\\.svg$).*)",
],
};
diff --git a/tests/end-card-layout.test.ts b/tests/end-card-layout.test.ts
index 4746ac7a..07a75692 100644
--- a/tests/end-card-layout.test.ts
+++ b/tests/end-card-layout.test.ts
@@ -28,10 +28,10 @@ function boxes(r: EndCardRest) {
describe("the end card's layout (end-card-layout)", () => {
for (const size of ["9:16", "16:9", "1:1", "4:5"] as const) {
for (const logo of [{ w: 1400, h: 360 }, null]) {
- it(`keeps a two-line headline's stack inside a ${size} frame, in order, nothing overlapping (${logo ? "logo" : "name"})`, () => {
+ it(`keeps a long headline's stack (one or two lines) inside a ${size} frame, in order, nothing overlapping (${logo ? "logo" : "name"})`, () => {
const r = rest(size, logo);
expect(r.overflow).toEqual([]);
- expect(r.headline.layout.lines.length).toBe(2);
+ expect(r.headline.layout.lines.length).toBeLessThanOrEqual(2);
const b = boxes(r);
for (const x of b) {
expect(x.top, `${size} ${x.name}`).toBeGreaterThanOrEqual(r.margin - 0.5);
@@ -85,7 +85,8 @@ describe("the end card's layout (end-card-layout)", () => {
const r = rest("9:16", null);
expect(still.headline.color).toBe(r.headline.color);
expect(still.cta!.color).toBe("#cfae6e");
- expect(still.cta!.text.color).toBe("#0e3b2f");
+ // The call to action is an outlined tag: its words take the tag's own colour, as on the animated card.
+ expect(still.cta!.text.color).toBe(r.cta!.label.color);
expect(still.headline.y).toBeCloseTo(r.headline.y, 6);
});
});
diff --git a/tests/kinetic-badge.test.ts b/tests/kinetic-badge.test.ts
new file mode 100644
index 00000000..158c6ebf
--- /dev/null
+++ b/tests/kinetic-badge.test.ts
@@ -0,0 +1,32 @@
+import { describe, expect, it } from "vitest";
+import { badgeSpot, discCover, outlinePoints } from "@/lib/motion/scenes/marketing/kit";
+import type { Outline } from "@/lib/motion/scene";
+
+// A bottle traced on a 100 × 200 grid: a narrow cap on a round body.
+const BOTTLE: Outline = { w: 100, h: 200, d: "M50 200L10 180L5 120L20 80L40 70L40 20L60 20L60 70L80 80L95 120L90 180Z", length: 600, start: [50, 200] };
+
+describe("a badge beside a product", () => {
+ it("keeps clear of the product (cap included) by 2 % of the short side whenever its bounds leave the room", () => {
+ const S = 1080;
+ for (const img of [
+ { x: 100, y: 300, w: 300, h: 600 },
+ { x: 80, y: 120, w: 420, h: 840 },
+ { x: 300, y: 500, w: 200, h: 400 },
+ ]) {
+ const bounds = { x: 76, y: 100, w: 928, h: 1200 };
+ const spot = badgeSpot(img, BOTTLE, S * 0.2, bounds, 0.75);
+ const pts = outlinePoints(BOTTLE, img);
+ expect(discCover(pts, spot.cx, spot.cy, spot.r + S * 0.02), JSON.stringify(img)).toBe(0);
+ // Inside its bounds.
+ expect(spot.cx - spot.r).toBeGreaterThanOrEqual(bounds.x - 1e-6);
+ expect(spot.cx + spot.r).toBeLessThanOrEqual(bounds.x + bounds.w + 1e-6);
+ }
+ });
+
+ it("without an outline, stands beside the picture when the bounds leave room", () => {
+ const img = { x: 100, y: 300, w: 300, h: 600 };
+ const spot = badgeSpot(img, null, 150, { x: 76, y: 100, w: 928, h: 1200 });
+ expect(spot.cx - spot.r).toBeGreaterThanOrEqual(img.x + img.w);
+ expect(spot.cover).toBe(0);
+ });
+});
diff --git a/tests/kinetic-covers.test.ts b/tests/kinetic-covers.test.ts
index 175dfbea..52920a71 100644
--- a/tests/kinetic-covers.test.ts
+++ b/tests/kinetic-covers.test.ts
@@ -17,6 +17,8 @@ interface Item {
kind: "text" | "image";
what: string;
alpha: number;
+ /** A photograph laid to the frame's edge (it may run under the chips). */
+ bleed?: boolean;
box: { x0: number; y0: number; x1: number; y1: number };
}
@@ -33,13 +35,15 @@ function items(nodes: readonly DisplayNode[], m: Matrix = IDENTITY, alpha = 1, o
const a = alpha * (n.opacity ?? 1);
if (n.type === "group") items(n.children, n.transform ? multiply(m, n.transform) : m, a, out);
else if (n.type === "text") {
+ // Decorative copies (ghosts, glows, shadows) are not the words.
+ if (n.decor) continue;
for (const r of n.runs) {
if (!r.text.trim()) continue;
const size = Number(/(\d+(\.\d+)?)px/.exec(r.font)![1]);
const rm = r.transform ? multiply(m, r.transform) : m;
out.push({ kind: "text", what: `${n.field} "${r.text}"`, alpha: a * (r.opacity ?? 1), box: boxOf(rm, r.x, r.y, measure(r.text, r.font), size) });
}
- } else if (n.type === "image") out.push({ kind: "image", what: n.src, alpha: a, box: boxOf(m, n.x, n.y, n.w, n.h) });
+ } else if (n.type === "image" && !n.decor) out.push({ kind: "image", what: n.src, alpha: a, box: boxOf(m, n.x, n.y, n.w, n.h), bleed: !!n.bleed });
}
return out;
}
@@ -76,6 +80,8 @@ describe("a code-drawn template's cover", () => {
const found = items(c.plan.evaluate(c.rest).nodes);
expect(found.some((i) => i.kind === "text") || found.some((i) => i.what === "logo"), c.id).toBe(true);
for (const i of found) {
+ // A photograph laid to the edge is the ground: it runs under the chips (the words on it never do).
+ if (i.bleed) continue;
const tag = `${c.id} ${i.what}`;
expect(i.box.y0, tag).toBeGreaterThanOrEqual(h * TILE_CHIPS.top - 1);
expect(i.box.y1, tag).toBeLessThanOrEqual(h * (1 - TILE_CHIPS.bottom) + 1);
diff --git a/tests/kinetic-poster-rules.test.ts b/tests/kinetic-poster-rules.test.ts
new file mode 100644
index 00000000..d8052a99
--- /dev/null
+++ b/tests/kinetic-poster-rules.test.ts
@@ -0,0 +1,184 @@
+import { describe, expect, it } from "vitest";
+import { IDENTITY, multiply, textNodes, type DisplayNode, type Matrix } from "@/lib/motion/display";
+import { fieldStops, kineticPalette, toLab } from "@/lib/motion/color";
+import { safeBox } from "@/lib/motion/grid";
+import type { Recipe } from "@/lib/motion/recipe";
+import { loadScene, SCENE_IDS } from "@/lib/motion/registry";
+import type { Scene, SceneInput } from "@/lib/motion/scene";
+import { setType, type BoxMeasure } from "@/lib/motion/type/glyphs";
+import { measure, RASTER_LOGO } from "./helpers/motion";
+
+// The poster rules from the second review: filled ghosts (never hairlines), lit two-stop fields, a readable foot that
+// reaches the safe line, line breaks at a clause, words that never collide on any frame or size, and a countdown that
+// ticks down to exactly what was typed.
+
+const MARKETING = SCENE_IDS.filter((id) => id.startsWith("marketing/"));
+const scenes: Scene[] = await Promise.all(MARKETING.map(loadScene));
+const SIZES = ["9:16", "4:5", "1:1", "16:9"] as const;
+
+const FIELDS: Record<string, Record<string, string>> = {
+ "marketing/kinetic-headline": { headline: "SHIP IT *TONIGHT.*", cta: "Start free", website: "lumenlabs.io", note: "Release 4.0" },
+ "marketing/line-reveal": { headline: "Quietly exceptional.", cta: "Discover the scent", website: "maison-ardent.com", note: "Est. 1987" },
+ "marketing/logo-sting": { tagline: "Software that ships itself", website: "lumenlabs.io", note: "Est. 2019" },
+ "marketing/feature-cards": { headline: "Month-end, minus the panic", point1: "Invoices that chase themselves", point2: "Payroll in two taps", point3: "Books that close on Friday", website: "ledgerly.app", note: "Three features" },
+ "marketing/stat-dashboard": { stat: "$1,284,000", label: "Revenue this quarter, up 38%", website: "ledgerly.app", note: "Q3 2026" },
+ "marketing/starburst": { headline: "Made to be noticed.", badge: "New!", website: "vesper-shoes.com", note: "SS26" },
+ "marketing/offer-badge": { offer: "20% off", headline: "THE GIFTING EDIT", cta: "Shop the edit", website: "soraskin.co", note: "Until 24 Dec" },
+ "marketing/big-number": { stat: "3×", caption: "faster month-end close, every month", website: "ledgerly.app", note: "2026 report" },
+ "marketing/quote": { quote: "“The only serum I’ve ever bought three times.”", name: "Amara K., verified buyer", website: "soraskin.co", note: "Verified reviews" },
+ "marketing/drop-countdown": { headline: "DROP 07", count: "03:12:45", when: "Friday · 9 PM", cta: "Set a reminder", website: "kova.store", note: "Season 07" },
+ "marketing/fragrance-reveal": { headline: "Nocturne", line: "Eau de parfum, for the hours after dark", cta: "Discover", website: "maison-ardent.com", note: "Est. 1987" },
+ "marketing/editorial-sale": { headline: "FINAL SALE", offer: "Up to 50% off", cta: "Shop the sale", website: "halden-studio.com", note: "SS26 Collection" },
+ "marketing/glass-spotlight": { headline: "Eau de Nuit", line: "Amber, iris and a trace of smoke", cta: "Discover", website: "aurele-paris.com", note: "Paris · Est. 1924" },
+ "marketing/announcement": { headline: "Opening Night", when: "Friday 14 March · 8 PM", place: "12 Rue des Martyrs, Paris", cta: "Reserve a table", website: "barlune.fr", note: "Doors at 7:30" },
+ "marketing/lookbook": { headline: "THE GOLD HOUR", accent: "Spring", line: "Collection 07 · Marrakech", website: "ateliernoor.com", note: "Spring/Summer 26" },
+ "marketing/stat-stack": { stat1: "98%", label1: "of tickets answered in an hour", stat2: "4.9", label2: "average rating", stat3: "3×", label3: "faster than last year", website: "orbit.help", note: "2026 report" },
+ "marketing/testimonials": { quote1: "“The calmest three days I’ve had all year.”", name1: "Léa M., Lisbon", quote2: "“Breakfast on the terrace was worth the trip alone.”", name2: "James O., London", quote3: "“We’ve booked again for September.”", name3: "Priya S., Mumbai", website: "halcyonhotels.com", note: "Guest reviews" },
+};
+
+function recipe(scene: string, over: Partial<Recipe> = {}): Recipe {
+ return {
+ v: 1,
+ scene,
+ seed: 11,
+ size: "9:16",
+ fps: 30,
+ duration: 5,
+ fields: FIELDS[scene] ?? {},
+ brand: { name: "Maison Ardent", colors: ["#6b1d2a", "#e9d8b4"], fonts: { heading: "Playfair Display", body: "Inter" } },
+ media: { product: "/previews/kinetic/product.png" },
+ export: { format: "mp4", blurSamples: 8, shutter: 180 },
+ ...over,
+ };
+}
+const input = (r: Recipe): SceneInput => ({ recipe: r, measure, logo: RASTER_LOGO, images: { product: { w: 800, h: 1024 } }, outlines: {} });
+
+const px = (font: string) => Number(/(\d+(?:\.\d+)?)px/.exec(font)![1]);
+const apply = (m: Matrix, x: number, y: number): [number, number] => [m[0] * x + m[2] * y + m[4], m[1] * x + m[3] * y + m[5]];
+
+/** Every readable run (not decoration) with its box (from its cap height to its baseline) and field, in design units. */
+function runs(nodes: readonly DisplayNode[], m: Matrix = IDENTITY, out: { field: string; text: string; x0: number; y0: number; x1: number; y1: number }[] = []) {
+ for (const n of nodes) {
+ if (n.type === "group") {
+ if (n.opacity !== undefined && n.opacity < 0.5) continue;
+ runs(n.children, n.transform ? multiply(m, n.transform) : m, out);
+ } else if (n.type === "text" && !n.decor) {
+ for (const r of n.runs) {
+ if (r.opacity !== undefined && r.opacity < 0.5) continue;
+ const s = px(r.font);
+ const rm = r.transform ? multiply(m, r.transform) : m;
+ const w = measure(r.text, r.font);
+ const pts = [apply(rm, r.x, r.y + s * 0.2), apply(rm, r.x + w, r.y + s * 0.2), apply(rm, r.x, r.y + s * 0.8), apply(rm, r.x + w, r.y + s * 0.8)];
+ out.push({ field: n.field, text: r.text, x0: Math.min(...pts.map((p) => p[0])), y0: Math.min(...pts.map((p) => p[1])), x1: Math.max(...pts.map((p) => p[0])), y1: Math.max(...pts.map((p) => p[1])) });
+ }
+ }
+ }
+ return out;
+}
+
+/** Every text node marked as a ghost (inside a group with id "ghost"). */
+function ghosts(nodes: readonly DisplayNode[], inGhost = false, out: DisplayNode[] = []): DisplayNode[] {
+ for (const n of nodes) {
+ if (n.type === "group") ghosts(n.children, inGhost || n.id === "ghost", out);
+ else if (inGhost && n.type === "text") out.push(n);
+ }
+ return out;
+}
+
+describe("poster rules", () => {
+ it("draws every ghost filled one tonal step from the field, never as a hairline", () => {
+ for (const scene of scenes) {
+ for (const look of ["light", "dark", "brand"]) {
+ const plan = scene.plan(input(recipe(scene.id, { controls: { look } })));
+ if (plan.overflow.length) continue;
+ for (const g of ghosts(plan.evaluate(plan.rest).nodes)) {
+ if (g.type !== "text") continue;
+ for (const r of g.runs) {
+ expect(r.stroke, `${scene.id} ${look}`).toBeUndefined();
+ expect(typeof r.fill === "string" && r.fill !== "transparent", `${scene.id} ${look}`).toBe(true);
+ }
+ }
+ }
+ }
+ });
+
+ it("lights every look's field with two analogous stops, the dark one in the brand's own hue with real colour", () => {
+ for (const look of ["light", "dark", "brand"] as const) {
+ const pal = kineticPalette(["#1f3fd1", "#ffb547"], look);
+ const s = fieldStops(pal);
+ const d = toLab(s.dark);
+ const l = toLab(s.light);
+ expect(l.L).toBeGreaterThan(d.L);
+ if (look === "dark") {
+ expect(d.L).toBeGreaterThan(0.08);
+ expect(d.L).toBeLessThan(0.15);
+ expect(Math.hypot(d.a, d.b)).toBeGreaterThan(0.05);
+ expect(l.L - d.L).toBeGreaterThan(0.17);
+ }
+ }
+ });
+
+ it("lets a 9:16 ad's words reach down to 81 % of the height (the app's 15 % and a pad)", () => {
+ const s = safeBox({ w: 1080, h: 1920 }, "ad");
+ expect(s.y + s.h).toBeCloseTo(1920 * 0.81);
+ });
+
+ it("puts every template's corner note on the frame when one is typed", () => {
+ for (const scene of scenes) {
+ const plan = scene.plan(input(recipe(scene.id)));
+ if (plan.overflow.length) continue;
+ const notes = textNodes(plan.evaluate(plan.rest).nodes).filter((n) => n.field === "note");
+ expect(notes.length, scene.id).toBeGreaterThan(0);
+ }
+ });
+
+ it("never lets two different fields' words collide, at rest or through the hold, at any size", () => {
+ for (const scene of scenes) {
+ for (const size of SIZES) {
+ const r = recipe(scene.id, { size });
+ const plan = scene.plan(input(r));
+ if (plan.overflow.length) continue;
+ for (const t of [plan.settled + 0.1, (plan.settled + plan.rest) / 2, plan.rest]) {
+ const all = runs(plan.evaluate(Math.min(plan.rest, t)).nodes);
+ for (let i = 0; i < all.length; i++) {
+ for (let j = i + 1; j < all.length; j++) {
+ const a = all[i];
+ const b = all[j];
+ // A script word crossing the title is the design (Runway Titles), not a collision.
+ if (a.field === b.field || [a.field, b.field].includes("accent")) continue;
+ const over = Math.min(a.x1, b.x1) - Math.max(a.x0, b.x0) > 2 && Math.min(a.y1, b.y1) - Math.max(a.y0, b.y0) > 2;
+ expect(over, `${scene.id} ${size} t=${t.toFixed(2)}: "${a.text}" (${a.field}) and "${b.text}" (${b.field})`).toBe(false);
+ }
+ }
+ }
+ }
+ }
+ });
+
+ it("counts the drop down a second at a time to exactly the typed time a second before the end", () => {
+ const scene = scenes[MARKETING.indexOf("marketing/drop-countdown")];
+ const plan = scene.plan(input(recipe("marketing/drop-countdown", { size: "4:5" })));
+ const count = (t: number) => textNodes(plan.evaluate(t).nodes).filter((n) => n.field === "count").flatMap((n) => n.runs.map((x) => x.text)).join("");
+ expect(count(plan.rest)).toContain("45");
+ const shown = new Set<string>();
+ for (let t = plan.rest - 3.4; t < plan.rest; t += 0.1) shown.add(count(t).slice(-2));
+ expect([...shown].some((s) => s === "46" || s === "47")).toBe(true);
+ });
+});
+
+describe("line breaks", () => {
+ const box: BoxMeasure = Object.assign((text: string, font: string) => text.length * px(font) * 0.5, { box: (_t: string, font: string) => ({ top: px(font) * 0.1, bottom: px(font) * 0.8, left: 0, right: 0 }) });
+ const spec = (text: string, width: number) => ({ field: "t", text, family: "Test", weight: 400, max: 60, min: 60, x: 0, y: 0, width, maxLines: 2, leading: 1 });
+
+ it("breaks after a clause's comma when it can", () => {
+ const set = setType(spec("Month-end, minus the panic", 60 * 0.5 * 17), box);
+ expect(set.lines.map((l) => l.text)).toEqual(["Month-end,", "minus the panic"]);
+ });
+
+ it("never ends a line on a little word (a, and, that, minus)", () => {
+ for (const text of ["Amber, iris and a trace of smoke", "Invoices that chase themselves", "Month-end, minus the panic"]) {
+ const set = setType(spec(text, 60 * 0.5 * Math.ceil(text.length * 0.62)), box);
+ for (const l of set.lines.slice(0, -1)) expect(l.text, text).not.toMatch(/\b(a|and|that|minus)$/);
+ }
+ });
+});
diff --git a/tests/kinetic-round3-rules.test.ts b/tests/kinetic-round3-rules.test.ts
new file mode 100644
index 00000000..01e1c697
--- /dev/null
+++ b/tests/kinetic-round3-rules.test.ts
@@ -0,0 +1,79 @@
+import { readFileSync, readdirSync } from "node:fs";
+import { join } from "node:path";
+import { describe, expect, it } from "vitest";
+import { themeFrom } from "@/components/ads/layout";
+import { textNodes, type DisplayNode } from "@/lib/motion/display";
+import { toLab } from "@/lib/motion/color";
+import { loadScene } from "@/lib/motion/registry";
+import type { SceneInput } from "@/lib/motion/scene";
+import { endCardRest } from "@/lib/motion/scenes/end-card/shared";
+import { ghostTone } from "@/lib/motion/scenes/marketing/poster";
+import { showcaseRecipe } from "@/lib/motion/showcase";
+import { TILE_COVER, TILE_CHIPS } from "@/lib/motion/sizes";
+import { measure, RASTER_LOGO } from "./helpers/motion";
+
+// The third review's rules: the brand's fonts are loaded in every weight a template sets (a cover measured before its
+// face arrives draws off-centre), the end card's stack is centred on the frame at the gallery tile's size, small facts
+// never type on letter by letter, ghost type stays a faint step off its ground, and a subhead never ends a line on a
+// little joining word.
+
+const root = process.cwd();
+const src = (p: string) => readFileSync(join(root, p), "utf8");
+
+describe("third review rules", () => {
+ it("loads every weight a template sets brand type in (the end card's product line and tag are 600)", () => {
+ const fonts = src("src/components/motion/fonts.ts");
+ const list = /export const FONT_WEIGHTS = \[([^\]]+)\]/.exec(fonts)![1].split(",").map((w) => Number(w.trim()));
+ const used = [...src("src/lib/motion/scenes/end-card/shared.ts").matchAll(/family: t\.(?:heading|body), weight: (\d+)/g)].map((m) => Number(m[1]));
+ expect(used.length).toBeGreaterThan(0);
+ for (const w of used) expect(list, `weight ${w}`).toContain(w);
+ });
+
+ it("centres the end card's stack on the frame at the gallery tile's size, the tag's words in the middle of the tag", () => {
+ const theme = themeFrom({ colors: ["#0e3b2f", "#cfae6e"], fonts: { heading: "Cormorant Garamond", body: "Manrope" } });
+ const r = endCardRest({ theme, content: { brand: "Aurèle", product: "Le Sérum Nuit", cta: "Discover the ritual", website: "aurele-paris.com" }, logo: { w: 1400, h: 360 }, measure, size: { ...TILE_COVER }, colors: ["#0e3b2f", "#cfae6e"], clear: { top: TILE_COVER.h * TILE_CHIPS.top, bottom: TILE_COVER.h * TILE_CHIPS.bottom } });
+ const W = TILE_COVER.w;
+ expect(r.logo!.x + r.logo!.w / 2).toBeCloseTo(W / 2, 3);
+ for (const b of [r.headline, r.site!]) {
+ expect(b.cx).toBeCloseTo(W / 2, 3);
+ for (const l of b.layout.lines) expect(Math.abs(measure(l.text, b.layout.font) - l.width)).toBeLessThanOrEqual(2);
+ }
+ const tag = r.cta!;
+ expect(tag.x + tag.w / 2).toBeCloseTo(W / 2, 3);
+ expect(tag.label.cx).toBeCloseTo(tag.x + tag.w / 2, 3);
+ });
+
+ it("never types small facts letter by letter in a Kinetic template", () => {
+ const dir = "src/lib/motion/scenes/marketing";
+ for (const f of readdirSync(join(root, dir))) expect(src(`${dir}/${f}`), f).not.toContain('"type-on"');
+ });
+
+ it("keeps ghost type a faint step (0.05 or less in lightness) off its ground, in the ground's own hue", () => {
+ for (const g of ["#0b0f19", "#1b1446", "#6b1d2a", "#f5efea", "#e9ecf5", "#2372ef"]) {
+ const d = Math.abs(toLab(ghostTone(g)).L - toLab(g).L);
+ expect(d, g).toBeGreaterThan(0.02);
+ expect(d, g).toBeLessThanOrEqual(0.05);
+ }
+ });
+
+ it("never ends a subhead's line on a little joining word, on the gallery cover or any size (Prism Stage)", async () => {
+ const scene = await loadScene("marketing/glass-spotlight");
+ const weak = /^(a|an|the|of|for|to|in|on|at|by|and|or|with|from)$/i;
+ for (const cover of [true, false]) {
+ const recipe = showcaseRecipe("m2-prism-stage", "marketing/glass-spotlight", 5, { cover })!;
+ const input: SceneInput = { recipe, measure, logo: RASTER_LOGO, images: { product: { w: 320, h: 614 } }, outlines: {} };
+ const plan = scene.plan(input);
+ const lines = new Map<number, string[]>();
+ const walk = (ns: readonly DisplayNode[]) => {
+ for (const n of textNodes(ns)) {
+ if (n.field !== "line" || n.decor) continue;
+ for (const run of n.runs) lines.set(Math.round(run.y), [...(lines.get(Math.round(run.y)) ?? []), run.text]);
+ }
+ };
+ walk(plan.evaluate(plan.rest).nodes);
+ const rows = [...lines.entries()].sort((a, b) => a[0] - b[0]).map(([, t]) => t.join(" ").trim().split(/\s+/));
+ expect(rows.length).toBeGreaterThan(0);
+ rows.slice(0, -1).forEach((words) => expect(weak.test(words[words.length - 1]), words.join(" ")).toBe(false));
+ }
+ });
+});
diff --git a/tests/kinetic-type-rules.test.ts b/tests/kinetic-type-rules.test.ts
new file mode 100644
index 00000000..06c1b9a0
--- /dev/null
+++ b/tests/kinetic-type-rules.test.ts
@@ -0,0 +1,40 @@
+import { describe, expect, it } from "vitest";
+import { LINE_GAP, setType, trackingFor, wordSpaceFor, type BoxMeasure } from "@/lib/motion/type/glyphs";
+
+const px = (font: string) => Number(/(\d+(?:\.\d+)?)px/.exec(font)![1]);
+// A face with a narrow space (0.1 em), letters 0.5 em, caps from 0.1 to 0.8 em and descenders to 1 em.
+const measure: BoxMeasure = Object.assign((text: string, font: string) => [...text].reduce((w, ch) => w + (ch === " " ? 0.1 : 0.5) * px(font), 0), {
+ box: (text: string, font: string) => ({ top: px(font) * 0.1, bottom: px(font) * (/[gjpqy]/.test(text) ? 1 : 0.8), left: 0, right: measure(text, font) }),
+});
+
+const spec = (text: string, o: Partial<Parameters<typeof setType>[0]> = {}) => ({ field: "t", text, family: "Test", weight: 400, max: 60, min: 60, x: 0, y: 0, width: 5000, maxLines: 4, leading: 1, ...o });
+
+describe("type rules", () => {
+ it("never tracks copy with lower-case letters open, nor tighter than 0 below hero size, nor anything tighter than -1 %", () => {
+ expect(trackingFor("Discover the scent", 0.14, 30)).toBe(0.01);
+ expect(trackingFor("Software that ships", -0.02, 40)).toBe(0);
+ expect(trackingFor("SHIP IT", -0.03, 300)).toBe(-0.01);
+ expect(trackingFor("MAISON", 0.25, 30)).toBe(0.25);
+ });
+
+ it("opens a narrow word space to at least the face's minimum, and keeps the words exactly as typed", () => {
+ const set = setType(spec("Software that ships itself", { style: "italic" }), measure);
+ const [a, b] = set.words;
+ const gap = b.x - (a.x + a.w);
+ expect(gap / set.size).toBeGreaterThanOrEqual(wordSpaceFor(60, "italic") - 1e-9);
+ expect(set.words.map((w) => w.gap + w.text).join("")).toBe("Software that ships itself");
+ });
+
+ it("never lets one line's ink touch the next line's", () => {
+ const set = setType(spec("Opening\nNight", { leading: 0.8 }), measure);
+ const capH = set.cap.bottom - set.cap.top;
+ const [l0, l1] = set.lines;
+ expect(l1.ink.y - (l0.ink.y + l0.ink.h)).toBeGreaterThanOrEqual(LINE_GAP * capH - 1e-9);
+ });
+
+ it("ends no line on a little joining word when the words allow it", () => {
+ const set = setType(spec("Eau de parfum, for the hours after dark", { width: 60 * 0.5 * 24, maxLines: 2 }), measure);
+ expect(set.lines.length).toBe(2);
+ expect(set.lines[0].text).not.toMatch(/\b(for|the)$/);
+ });
+});
diff --git a/tests/marketing-code-refusal.test.ts b/tests/marketing-code-refusal.test.ts
index 6eee8f15..37711ddd 100644
--- a/tests/marketing-code-refusal.test.ts
+++ b/tests/marketing-code-refusal.test.ts
@@ -23,7 +23,7 @@ afterAll(() => {
const CODE = TEMPLATES.filter(isCodeTemplate);
describe("code-drawn templates on the server", () => {
- it("are the ten Kinetic templates", () => expect(CODE).toHaveLength(10));
+ it("are the eighteen Kinetic templates", () => expect(CODE).toHaveLength(18));
for (const t of CODE) {
const input = { engine: "cloud" as const, format: t.format, templateId: t.id, prompt: "A bottle on a plinth" };
diff --git a/tests/marketing-kinetic-templates.test.ts b/tests/marketing-kinetic-templates.test.ts
index 2ac60040..ad1ff327 100644
--- a/tests/marketing-kinetic-templates.test.ts
+++ b/tests/marketing-kinetic-templates.test.ts
@@ -19,9 +19,9 @@ import { measure } from "./helpers/motion";
const CODE = TEMPLATES.filter(isCodeTemplate);
describe("the catalog's code-drawn templates", () => {
- it("are the six switched templates and the four new ones", () => {
+ it("are the switched templates and the ones drawn for Kinetic", () => {
expect(CODE.map((t) => t.id).sort()).toEqual(
- ["ms-kinetic-headline", "m2-line-reveal", "ms-logo-sting", "ms-feature-cards", "ms-dashboard-zoom", "m2-retro-starburst", "m2-offer-badge", "ms-big-number", "ms-five-star-quote", "ms-end-card"].sort(),
+ ["ms-kinetic-headline", "m2-line-reveal", "ms-logo-sting", "ms-feature-cards", "ms-dashboard-zoom", "m2-retro-starburst", "m2-offer-badge", "ms-big-number", "ms-five-star-quote", "ms-end-card", "m2-midnight-drop", "m2-nocturne", "m2-season-finale", "m2-prism-stage", "mm-marquee", "mm-runway-titles", "ms-stat-stack", "ms-kind-words"].sort(),
);
// Scenes, not type, stay on the video models.
for (const id of ["m2-sticker-pop", "m2-paper-parade", "m2-comic-panels", "m2-grid-shuffle", "ms-device-float"]) expect(isCodeTemplate(TEMPLATES.find((t) => t.id === id))).toBe(false);
@@ -111,8 +111,8 @@ describe("a template's recipe", () => {
it("is listed by the template's name and its first words, without the highlight's stars", () => {
const head = CODE.find((t) => t.id === "ms-kinetic-headline")!;
const w = templateWords(head, initialState(head));
- expect(w.title).toBe("Kinetic Headline · Invoices that chase themselves.");
- expect(w.prompt).toBe("Lumen Labs · Invoices that chase themselves. · Start free · lumenlabs.io");
+ expect(w.title).toBe("Kinetic Headline · SHIP IT TONIGHT.");
+ expect(w.prompt).toBe("Lumen Labs · SHIP IT TONIGHT. · Start free · lumenlabs.io · Release 4.0");
// A star that marks nothing is part of the words.
const s = initialState(head);
expect(templateWords(head, { ...s, fields: { ...s.fields, headline: "Rated 5* by *guests*" } }).title).toBe("Kinetic Headline · Rated 5* by guests");
diff --git a/tests/motion-continuity.test.ts b/tests/motion-continuity.test.ts
index 8c48aa99..34164c46 100644
--- a/tests/motion-continuity.test.ts
+++ b/tests/motion-continuity.test.ts
@@ -86,5 +86,5 @@ describe("no jumps (motion-continuity)", () => {
}
}
}
- });
+ }, 60_000);
});
diff --git a/tests/motion-fx.test.ts b/tests/motion-fx.test.ts
new file mode 100644
index 00000000..47c742f2
--- /dev/null
+++ b/tests/motion-fx.test.ts
@@ -0,0 +1,257 @@
+import { describe, expect, it } from "vitest";
+import { analogous, contrastOf, ensureContrast, fromLab, kineticPalette, mixOk, toLab, withLightness } from "@/lib/motion/color";
+import { columns, corner, gridFor, heroRange, inside, placementOf, safeBox, SCALE_CONTRAST, LADDER } from "@/lib/motion/grid";
+import { bokeh, lightBars, lightLeak, loopPeriod, meshGradient, nightGround, ribbon, rings } from "@/lib/motion/fx/background";
+import { echoStack, extrude, floorShadow, glowBehind, hardShadow, shadowTint, twoShadow } from "@/lib/motion/fx/depth";
+import { CHROME_STOPS, chromeInk, gradientInk, hollow, pillBox } from "@/lib/motion/fx/materials";
+import { arrow, bauhaus, blob, halftone, highlighter, keyline, pillTag, rule, squiggle } from "@/lib/motion/fx/overlays";
+import { coverCrop, duotone, photo, photoInType, product, pushIn, tiltedCard } from "@/lib/motion/fx/photo";
+import { blurSamples, grain, GRAIN_SIZE, GRAIN_TILES, grainPick, grainTile, vignette } from "@/lib/motion/fx/finish";
+import { LAYER_ORDER, layerTransform, stack } from "@/lib/motion/fx/stack";
+import type { DisplayNode, GroupNode, TextNode } from "@/lib/motion/display";
+import { TILE_CHIPS } from "@/lib/motion/sizes";
+
+// The look's building blocks: colour from a brand kit, the grid and safe areas, fields, depth, materials, overlays,
+// photography, finish and the layer stack. All pure and seeded: the same frame every time.
+
+const face: TextNode = { type: "text", field: "headline", runs: [{ text: "LUMEN", gap: "", font: '400 200px "Anton"', x: 100, y: 300, fill: "#ffffff" }] };
+
+describe("colour from a brand kit", () => {
+ it("converts to OKLab and back", () => {
+ for (const c of ["#3d5afe", "#c8102e", "#0e3b2f", "#f4b860", "#ffffff", "#000000"]) expect(fromLab(toLab(c))).toBe(c);
+ expect(mixOk("#000000", "#ffffff", 0.5)).not.toBe("#808080");
+ });
+
+ it("moves only lightness to reach contrast, keeping the brand's hue", () => {
+ const fixed = ensureContrast("#9fe7ff", "#fbfaf7", 4.5);
+ expect(contrastOf(fixed, "#fbfaf7")).toBeGreaterThanOrEqual(4.5);
+ expect(analogous(fixed, "#9fe7ff", 8)).toBe(true);
+ expect(withLightness("#3d5afe", 0.3)).not.toBe("#3d5afe");
+ });
+
+ it("derives each look: paper and night never pure, readable ink, tonal steps on the ground's hue", () => {
+ for (const kit of [["#3d5afe", "#9fe7ff"], ["#c8102e", "#f4b43c"], ["#0e3b2f", "#cfae6e"], ["#f4b860", "#0f5c5a"]]) {
+ for (const look of ["brand", "light", "dark"] as const) {
+ const p = kineticPalette(kit, look);
+ expect(p.paper).not.toBe("#ffffff");
+ expect(p.night).not.toBe("#000000");
+ expect(toLab(p.night).L).toBeGreaterThanOrEqual(0.1);
+ expect(toLab(p.night).L).toBeLessThanOrEqual(0.16);
+ expect(contrastOf(p.ink, p.ground), `${kit} ${look}`).toBeGreaterThanOrEqual(look === "brand" ? 3 : 4.5);
+ expect(analogous(p.tone1, p.ground, 12), `${kit} ${look} tone1`).toBe(true);
+ expect(Math.abs(toLab(p.tone2).L - toLab(p.ground).L)).toBeGreaterThan(Math.abs(toLab(p.tone1).L - toLab(p.ground).L));
+ }
+ }
+ expect(kineticPalette(["#3d5afe", "#9fe7ff"], "light").ground).toBe(kineticPalette(["#3d5afe", "#9fe7ff"], "light").paper);
+ expect(kineticPalette(["#3d5afe", "#9fe7ff"], "brand").ground).toBe("#3d5afe");
+ });
+});
+
+describe("grid and safe areas", () => {
+ it("keeps ad copy out of the app's top 14 %, bottom 19 % (its 15 % and a pad) and right 11 %", () => {
+ const s = safeBox({ w: 1080, h: 1920 }, "ad");
+ expect(s.y).toBeCloseTo(1920 * 0.14);
+ expect(s.y + s.h).toBeCloseTo(1920 * 0.81);
+ expect(s.x + s.w).toBeCloseTo(1080 * 0.89);
+ expect(s.x).toBeCloseTo(1080 * 0.07);
+ });
+
+ it("keeps cover copy between the tile's chips, and posts on the 7 % margin", () => {
+ const c = safeBox({ w: 1080, h: 1440 }, "cover");
+ expect(c.y).toBeCloseTo(1440 * TILE_CHIPS.top);
+ expect(c.y + c.h).toBeCloseTo(1440 * (1 - TILE_CHIPS.bottom));
+ const p = safeBox({ w: 1080, h: 1350 }, "post");
+ for (const [k, v] of Object.entries({ x: 75.6, y: 75.6, w: 1080 - 151.2, h: 1350 - 151.2 })) expect(p[k as keyof typeof p]).toBeCloseTo(v, 6);
+ });
+
+ it("lays 12 columns and four corner slots on the inset line", () => {
+ const g = gridFor({ w: 1080, h: 1350 });
+ const all = columns(g, 0, 12);
+ expect(all.x).toBeCloseTo(g.safe.x);
+ expect(all.w).toBeCloseTo(g.safe.w);
+ expect(columns(g, 6, 6).x + columns(g, 6, 6).w).toBeCloseTo(g.safe.x + g.safe.w);
+ expect(corner(g, "tl")).toEqual({ x: g.safe.x, y: g.safe.y, align: "left", from: "top" });
+ expect(corner(g, "br")).toEqual({ x: g.safe.x + g.safe.w, y: g.safe.y + g.safe.h, align: "right", from: "bottom" });
+ expect(inside({ x: 100, y: 100, w: 10, h: 10 }, g.safe)).toBe(true);
+ expect(inside({ x: 10, y: 100, w: 10, h: 10 }, g.safe)).toBe(false);
+ });
+
+ it("knows where a recipe is shown, and the size ladder keeps the hero 12× the details", () => {
+ expect(placementOf({ size: "9:16" })).toBe("ad");
+ expect(placementOf({ size: "9:16", controls: { placement: "story" } })).toBe("story");
+ expect(placementOf({ size: { w: 1080, h: 1440 }, controls: { cover: "tile" } })).toBe("cover");
+ expect(placementOf({ size: "4:5" })).toBe("post");
+ expect(heroRange({ w: 1080, h: 1920 })).toEqual({ min: 1080 * 0.14, max: 1080 * 0.4 });
+ expect(LADDER.hero[0] / LADDER.meta[1]).toBeGreaterThanOrEqual(SCALE_CONTRAST * 0.5);
+ expect(LADDER.hero[1] / LADDER.meta[0]).toBeGreaterThanOrEqual(SCALE_CONTRAST);
+ });
+});
+
+const json = (n: unknown) => JSON.stringify(n, (_, v) => (typeof v === "number" ? Math.round(v * 1000) / 1000 : v));
+
+describe("fields and atmosphere", () => {
+ it("move a mesh on seeded paths that close on the clip's length", () => {
+ const o = { w: 1080, h: 1920, colors: ["#3d5afe", "#2a3fb0", "#9fe7ff", "#1b2a80"], seed: 7, duration: 6, dark: true };
+ expect(json(meshGradient({ ...o, t: 0 }))).toBe(json(meshGradient({ ...o, t: 6 })));
+ expect(json(meshGradient({ ...o, t: 2 }))).not.toBe(json(meshGradient({ ...o, t: 0 })));
+ expect(json(meshGradient({ ...o, t: 2 }))).toBe(json(meshGradient({ ...o, t: 2 })));
+ expect(meshGradient({ ...o, t: 0 }).blend).toBe("screen");
+ expect(meshGradient({ ...o, t: 0, dark: false }).blend).toBeUndefined();
+ expect(loopPeriod(10, 6)).toBe(6);
+ expect(loopPeriod(4, 9)).toBe(4.5);
+ });
+
+ it("draw light bars, rings, an orb-lit night ground, bokeh, a ribbon and leaks only around a cut", () => {
+ const bars = lightBars({ x: 0, y: 0, w: 1080, h: 1920, count: 8, ground: "#0e3b2f", accent: "#cfae6e", t: 1, duration: 6, seed: 7 });
+ expect(bars.children.length).toBe(8);
+ expect(rings({ cx: 0, cy: 0, count: 6, gap: 90, colors: ["#ffffff"] }).children.length).toBe(6);
+ expect(nightGround({ w: 1080, h: 1920, night: "#101420", glow: "#3d5afe" })).toHaveLength(2);
+ expect(json(bokeh({ w: 1080, h: 1920, count: 20, colors: ["#ffffff"], seed: 7, t: 0, duration: 6 }))).toBe(json(bokeh({ w: 1080, h: 1920, count: 20, colors: ["#ffffff"], seed: 7, t: 6, duration: 6 })));
+ expect(lightLeak({ w: 1080, h: 1920, from: "left", p: 0, seed: 7 })).toBeNull();
+ expect(lightLeak({ w: 1080, h: 1920, from: "left", p: 0.5, seed: 7 })!.blend).toBe("screen");
+ const r = ribbon({ d: "M0 0C300 200 600 -200 900 0", from: [0, 0], to: [900, 0], width: 40, hue: "#9fe7ff", key: "r", bounds: { x: -100, y: -300, w: 1100, h: 600 } });
+ expect((r.children[0] as GroupNode).cache).toBeDefined();
+ });
+});
+
+describe("depth", () => {
+ it("follows the two-shadow rule: tight contact plus wide ambient, tinted toward the ground", () => {
+ const [ambient, contact] = twoShadow({ nodes: [face], size: 200, ground: "#3d5afe", bounds: { x: 100, y: 300, w: 500, h: 200 }, key: "lumen" });
+ expect(ambient.opacity).toBeCloseTo(0.14);
+ expect(ambient.transform![5]).toBeCloseTo(7);
+ expect((ambient.children[0] as GroupNode).soften).toBeCloseTo(16);
+ expect(contact.opacity).toBeCloseTo(0.3);
+ expect(contact.transform![5]).toBeCloseTo(2);
+ expect((contact.children[0] as GroupNode).soften).toBeCloseTo(1.5);
+ const tint = shadowTint("#3d5afe");
+ expect(tint).not.toBe("#000000");
+ expect(analogous(tint, "#3d5afe", 20)).toBe(true);
+ const shadowText = (contact.children[0] as GroupNode).children[0] as TextNode;
+ expect(shadowText.decor).toBe(true);
+ });
+
+ it("extrudes in stepped copies, darker toward the back, cached once the word has landed", () => {
+ const e = extrude({ face, color: "#f4b860", depth: 16, key: "x", bounds: { x: 100, y: 300, w: 500, h: 200 } });
+ expect(e.children.length).toBe(16);
+ expect(e.cache).toBeDefined();
+ const half = extrude({ face, color: "#f4b860", depth: 16, p: 0.5, key: "x", bounds: { x: 100, y: 300, w: 500, h: 200 } });
+ expect(half.children.length).toBe(8);
+ expect(half.cache).toBeUndefined();
+ const back = ((e.children[0] as GroupNode).children[0] as TextNode).runs[0].fill as string;
+ const front = ((e.children[15] as GroupNode).children[0] as TextNode).runs[0].fill as string;
+ expect(toLab(back).L).toBeLessThan(toLab(front).L);
+ });
+
+ it("offers hard shadows, echo stacks, glows and a floor shadow, all as decorative copies", () => {
+ expect(hardShadow(face, 200, "#c8102e").transform).toEqual([1, 0, 0, 1, 12, 12]);
+ expect(echoStack(face, { count: 3, dx: 6, dy: 6 }).map((g) => g.opacity)).toEqual([0.12, 0.25, 0.5]);
+ expect(glowBehind({ nodes: [face], color: "#9fe7ff", blur: 8, bounds: { x: 0, y: 0, w: 10, h: 10 }, key: "g" }).blend).toBe("lighter");
+ expect(floorShadow({ cx: 500, y: 1200, width: 400, ground: "#f4efe6", key: "p" }).cache).toBeDefined();
+ });
+});
+
+describe("materials and overlays", () => {
+ it("anchor a gradient to the line box in OKLab, and keep chrome's hard horizon", () => {
+ const g = gradientInk({ x: 0, y: 0, w: 600, h: 200 }, ["#3d5afe", "#5a7bff", "#9fe7ff"]);
+ expect(g.kind).toBe("linear");
+ expect(g.stops.length).toBe(5);
+ const c = chromeInk(10, 150, 200);
+ expect(c.fill.stops.map((s) => s.at)).toEqual(CHROME_STOPS.map((s) => s.at));
+ expect(hollow(200, "#ffffff").fill).toBe("transparent");
+ const pill = pillBox({ x: 100, y: 100, w: 200, h: 40 }, 40);
+ expect(pill.r).toBe(pill.h / 2);
+ });
+
+ it("tilt a pill, grow a jittered highlighter from the left, and draw rules and arrows on", () => {
+ const tag = pillTag({ x: 100, y: 100, w: 300, h: 80 }, "#f4b43c", [], { deg: -6 });
+ expect(tag.transform![1]).toBeCloseTo(Math.sin((-6 * Math.PI) / 180));
+ expect(highlighter({ capTop: 100, baseline: 200, x: 0, w: 400, color: "#f4b43c", seed: 7, p: 0 })).toBeNull();
+ const h = highlighter({ capTop: 100, baseline: 200, x: 0, w: 400, color: "#f4b43c", seed: 7 });
+ expect(h).toEqual(highlighter({ capTop: 100, baseline: 200, x: 0, w: 400, color: "#f4b43c", seed: 7 }));
+ expect((rule({ x: 0, y: 0, w: 100, color: "#fff", p: 0.5 }) as { stroke: { trim: number } }).stroke.trim).toBeGreaterThan(0);
+ expect(arrow({ x: 0, y: 0, size: 20, color: "#fff" }).type).toBe("path");
+ expect(squiggle({ x: 0, y: 0, w: 200, amp: 10, seed: 7, color: "#fff" }).type).toBe("path");
+ expect(bauhaus({ x: 0, y: 0, size: 50, color: "#c8102e", seed: 7 }).children).toHaveLength(3);
+ expect(blob({ cx: 0, cy: 0, r: 100, seed: 7, t: 1, fill: "#fff" })).toEqual(blob({ cx: 0, cy: 0, r: 100, seed: 7, t: 1, fill: "#fff" }));
+ expect((keyline([face], 7)[0] as TextNode).runs[0].stroke!.width).toBe(14);
+ });
+
+ it("set halftone dots by the square root of their coverage, once, cached", () => {
+ const h = halftone({ box: { x: 0, y: 0, w: 400, h: 400 }, spacing: 20, origin: [0, 0], reach: 500, color: "#000", key: "corner" });
+ expect(h.cache).toEqual({ key: "halftone|corner", bounds: { x: 0, y: 0, w: 400, h: 400 } });
+ const d = (h.children[0] as { d: string }).d;
+ expect(d.length).toBeGreaterThan(100);
+ expect(d).toBe((halftone({ box: { x: 0, y: 0, w: 400, h: 400 }, spacing: 20, origin: [0, 0], reach: 500, color: "#000", key: "corner" }).children[0] as { d: string }).d);
+ });
+});
+
+describe("photography and products", () => {
+ it("crops to cover, pushes in over the clip, and grades into the palette", () => {
+ expect(coverCrop({ w: 1000, h: 1000 }, { w: 500, h: 1000 })).toEqual({ x: 0.25, y: 0, w: 0.5, h: 1 });
+ expect(coverCrop({ w: 1000, h: 1000 }, { w: 1000, h: 1000 }, { x: 0.5, y: 0.5 }, 1.25).w).toBeCloseTo(0.8);
+ expect(pushIn(0, 5).zoom).toBe(1);
+ expect(pushIn(5, 5).zoom).toBeCloseTo(1.06);
+ const p = photo({ src: "photo", img: { w: 2000, h: 3000 }, box: { x: 0, y: 0, w: 1080, h: 1920 }, t: 2, duration: 5, grade: { dark: "#0e3b2f", light: "#cfae6e" } });
+ expect(p.isolate).toBeDefined();
+ expect(p.children).toHaveLength(3);
+ expect(duotone({ x: 0, y: 0, w: 10, h: 10 }, { dark: "#000000", light: "#ffffff" }).map((n) => (n as GroupNode).blend)).toEqual(["multiply", "screen"]);
+ });
+
+ it("shows a photo through the letters, sets tilted cards with their shadows, and sweeps light across a product once", () => {
+ const pit = photoInType(face, { src: "photo", img: { w: 1000, h: 1000 }, box: { x: 0, y: 0, w: 1080, h: 1080 }, t: 0, duration: 5, bounds: { x: 0, y: 0, w: 1080, h: 1080 } });
+ expect((pit.children[1] as GroupNode).blend).toBe("destination-in");
+ const card = tiltedCard({ src: "photo", img: { w: 1000, h: 1000 }, box: { x: 100, y: 100, w: 400, h: 500 }, t: 0, duration: 5, deg: 4, ground: "#f4efe6", key: "c" });
+ expect(card.children.length).toBe(4);
+ const still = product({ src: "product", box: { x: 300, y: 600, w: 480, h: 800 }, ground: "#f4efe6", t: 1, key: "p" });
+ const sweeping = product({ src: "product", box: { x: 300, y: 600, w: 480, h: 800 }, ground: "#f4efe6", t: 2.4, sweepAt: 2, key: "p" });
+ expect(json(still)).not.toBe(json(sweeping));
+ const done = product({ src: "product", box: { x: 300, y: 600, w: 480, h: 800 }, ground: "#f4efe6", t: 3, sweepAt: 2, key: "p" });
+ expect(json(done)).toBe(json(still));
+ });
+});
+
+describe("finish", () => {
+ it("makes seeded grain tiles that change on twos, the same frame always getting the same grain", () => {
+ const a = grainTile(7, 0);
+ expect(a.length).toBe(GRAIN_SIZE * GRAIN_SIZE);
+ expect(Buffer.from(a).equals(Buffer.from(grainTile(7, 0)))).toBe(true);
+ expect(Buffer.from(a).equals(Buffer.from(grainTile(7, 1)))).toBe(false);
+ const mean = a.reduce((s, v) => s + v, 0) / a.length;
+ expect(Math.abs(mean - 128)).toBeLessThan(2);
+ expect(grainPick(7, 0)).toEqual(grainPick(7, 1));
+ expect(grainPick(7, 2)).not.toEqual(grainPick(7, 1));
+ expect(grainPick(7, 2 * GRAIN_TILES).tile).toBe(0);
+ expect(grain({ w: 1080, h: 1920, seed: 7, frame: 3, dark: true })).toMatchObject({ blend: "screen", amount: 0.04 });
+ expect(grain({ w: 1080, h: 1920, seed: 7, frame: 3, dark: false })).toMatchObject({ blend: "overlay", amount: 0.05 });
+ });
+
+ it("darkens the corners with a vignette and picks motion-blur samples from speed", () => {
+ expect(vignette({ w: 1080, h: 1920 }).type).toBe("rect");
+ expect(blurSamples(0)).toBe(1);
+ expect(blurSamples(10)).toBe(5);
+ expect(blurSamples(400)).toBe(16);
+ });
+});
+
+describe("layer stack", () => {
+ it("orders layers bottom to top, grain under the readable type, and the product over the type when sandwiched", () => {
+ const n = (id: string): DisplayNode[] => [{ type: "rect", id, x: 0, y: 0, w: 1, h: 1 }];
+ const layers = LAYER_ORDER.map((role) => ({ role, nodes: n(role) }));
+ const ids = (nodes: DisplayNode[]) => nodes.map((g) => (g as GroupNode).id);
+ const o = { w: 1080, h: 1920, t: 0, duration: 5 };
+ expect(ids(stack([...layers].reverse(), o))).toEqual(LAYER_ORDER.map((r) => `layer-${r}`));
+ const sand = ids(stack(layers, { ...o, sandwich: true }));
+ expect(sand.indexOf("layer-subject")).toBe(sand.indexOf("layer-hero") + 1);
+ expect(sand.indexOf("layer-grain")).toBeLessThan(sand.indexOf("layer-hero"));
+ });
+
+ it("moves far layers less than near ones and settles each in at its own rate, home on the last frame", () => {
+ const o = { w: 1080, h: 1920, t: 5, duration: 5, camera: { x: 40, y: 0 } };
+ expect(layerTransform("ground", { ...o, push: false })![4]).toBeCloseTo(10);
+ expect(layerTransform("subject", { ...o, push: false })![4]).toBeCloseTo(40 / 1.2);
+ expect(layerTransform("meta", o)).toBeUndefined();
+ expect(layerTransform("ground", { ...o, t: 0, camera: undefined })![0]).toBeCloseTo(1.04);
+ expect(layerTransform("subject", { ...o, t: 0, camera: undefined })![0]).toBeCloseTo(1.1);
+ expect(layerTransform("ground", { ...o, camera: undefined })).toBeUndefined();
+ });
+});
diff --git a/tests/motion-marketing.test.ts b/tests/motion-marketing.test.ts
index 91352053..3e48a790 100644
--- a/tests/motion-marketing.test.ts
+++ b/tests/motion-marketing.test.ts
@@ -41,8 +41,19 @@ const FIELDS: Record<string, Record<string, string>> = {
"marketing/offer-badge": { offer: "20% off", headline: "The winter edit", cta: "Shop the sale" },
"marketing/big-number": { stat: "3×", caption: "faster month-end close" },
"marketing/quote": { quote: "“The only serum I've bought three times.”", name: "Amara K., verified buyer" },
+ "marketing/drop-countdown": { headline: "DROP 07", count: "03:12:45", when: "Friday · 9 PM", cta: "Set a reminder" },
+ "marketing/fragrance-reveal": { headline: "Nocturne", line: "Eau de parfum, for the hours after dark", cta: "Discover" },
+ "marketing/editorial-sale": { headline: "FINAL SALE", offer: "Up to 50% off", cta: "Shop the sale" },
+ "marketing/glass-spotlight": { headline: "Eau de Nuit", line: "Amber, iris and a trace of smoke", cta: "Discover" },
+ "marketing/announcement": { headline: "Opening Night", when: "Friday 14 March · 8 PM", place: "12 Rue des Martyrs, Paris", cta: "Reserve a table" },
+ "marketing/lookbook": { headline: "THE GOLD HOUR", accent: "Spring", line: "Collection 07 · Marrakech" },
+ "marketing/stat-stack": { stat1: "98%", label1: "of tickets answered in an hour", stat2: "4.9", label2: "average rating", stat3: "3×", label3: "faster than last year" },
+ "marketing/testimonials": { quote1: "“The calmest three days I’ve had all year.”", name1: "Léa M., Lisbon", quote2: "“Breakfast on the terrace was worth the trip alone.”", name2: "James O., London", quote3: "“We’ve booked again for September.”", name3: "Priya S., Mumbai" },
};
+/** Fields set as figures that roll through digits on the way in (any digit may show while they move). */
+const FIGURES = /^(statd?|count)$/;
+
function recipe(scene: string, over: Partial<Recipe> = {}): Recipe {
return {
v: 1,
@@ -68,7 +79,7 @@ const typedOf = (r: Recipe, field: string) => {
};
describe("the registry", () => {
- it("has the nine Marketing scenes", () => {
+ it("has every Marketing scene, each 5–8 s long", () => {
expect(MARKETING.sort()).toEqual(Object.keys(FIELDS).sort());
for (const s of scenes) expect(s.durations).toEqual({ min: 5, max: 8, default: 5 });
});
@@ -94,7 +105,7 @@ describe("determinism", () => {
}
}
}
- });
+ }, 60_000);
});
function walk(nodes: readonly DisplayNode[], out: DisplayNode[] = []): DisplayNode[] {
@@ -111,7 +122,7 @@ describe("spelling", () => {
it("sets every field exactly as typed at rest, and never draws a letter that wasn't typed", () => {
for (const scene of scenes) {
for (const field of Object.keys(FIELDS[scene.id])) {
- if (field === "stat") continue;
+ if (FIGURES.test(field)) continue;
for (const text of hostile) {
const base = recipe(scene.id);
const r = recipe(scene.id, { fields: { ...base.fields, [field]: text } });
@@ -128,7 +139,7 @@ describe("spelling", () => {
const t = (i / 30) * r.duration;
for (const n of textNodes(plan.evaluate(t).nodes)) {
const typed = typedOf(r, n.field);
- for (const run of n.runs) for (const ch of run.text) expect(typed.includes(ch) || (n.field === "stat" && /[0-9]/.test(ch)), `${scene.id} ${n.field} "${ch}" at ${t}`).toBe(true);
+ for (const run of n.runs) for (const ch of run.text) expect(typed.includes(ch) || (FIGURES.test(n.field) && /[0-9]/.test(ch)), `${scene.id} ${n.field} "${ch}" at ${t}`).toBe(true);
}
}
}
@@ -141,8 +152,8 @@ describe("spelling", () => {
const r = recipe(s.id, { fields: { headline: "Ship *faster* with *less*." } });
const plan = s.plan(input(r));
for (let i = 0; i <= 20; i++) for (const n of textNodes(plan.evaluate((i / 20) * 2.5).nodes)) for (const run of n.runs) expect(run.text).not.toContain("*");
- const words = textNodes(plan.evaluate(2).nodes).find((n) => n.field === "headline")!;
- expect(spelled(words.runs)).toBe("Ship faster with less.");
+ const words = textNodes(plan.evaluate(plan.rest).nodes).filter((n) => n.field === "headline");
+ expect(spelled(words.flatMap((n) => n.runs))).toBe("Ship faster with less.");
});
it("marks only paired stars round words, and keeps every other star as typed", () => {
@@ -158,14 +169,13 @@ describe("spelling", () => {
const s = scenes.find((x) => x.id === "marketing/kinetic-headline")!;
const r = recipe(s.id, { fields: { headline: "Rated 5* by *guests*" } });
const plan = s.plan(input(r));
- const exit = plan.timeline.byId.get("words.exit")!;
- const words = textNodes(plan.evaluate(exit.start - 0.01).nodes).find((n) => n.field === "headline")!;
- expect(spelled(words.runs)).toBe("Rated 5* by guests");
+ const words = textNodes(plan.evaluate(plan.rest).nodes).filter((n) => n.field === "headline");
+ expect(spelled(words.flatMap((n) => n.runs))).toBe("Rated 5* by guests");
});
it("names a field that doesn't fit instead of cutting it", () => {
for (const scene of scenes) {
- const field = Object.keys(FIELDS[scene.id]).find((f) => f !== "stat")!;
+ const field = Object.keys(FIELDS[scene.id]).find((f) => !FIGURES.test(f))!;
const r = recipe(scene.id, { fields: { ...recipe(scene.id).fields, [field]: "Supercalifragilisticexpialidociously ".repeat(14).trim() } });
expect(scene.plan(input(r)).overflow, scene.id).toContain(field);
}
@@ -234,10 +244,14 @@ function flatten(nodes: readonly DisplayNode[], m: Matrix = IDENTITY, alpha = 1,
if (n.blend && n.blend !== "source-over") continue;
flatten(n.children, n.transform ? multiply(m, n.transform) : m, a, out);
} else if (n.type === "text") {
+ // Decorative copies (ghosts, glows, shadows) are not the words.
+ if (n.decor) continue;
for (const r of n.runs) {
const size = Number(/(\d+(\.\d+)?)px/.exec(r.font)![1]);
const rm = r.transform ? multiply(m, r.transform) : m;
- out.push({ kind: "text", field: n.field, text: r.text, fill: typeof r.fill === "string" ? r.fill : "", box: boxOf(rm, r.x, r.y, measure(r.text, r.font), size) });
+ // A gradient fill reads as its weakest stop.
+ const fills = typeof r.fill === "string" ? [r.fill] : r.fill && "stops" in r.fill ? r.fill.stops.map((s) => s.color) : [""];
+ for (const fill of fills) out.push({ kind: "text", field: n.field, text: r.text, fill, box: boxOf(rm, r.x, r.y, measure(r.text, r.font), size) });
}
} else if ((n.type === "rect" || n.type === "ellipse" || n.type === "path") && typeof n.fill === "string" && /^#/.test(n.fill) && a >= 0.999) {
if (n.type === "rect") out.push({ kind: "shape", fill: n.fill, box: boxOf(m, n.x, n.y, n.w, n.h) });
@@ -303,7 +317,7 @@ describe("the rest frame", () => {
}
}
}
- });
+ }, 120_000); // every scene × size × look × palette × logo: well over the default 5 s on a busy machine
});
describe("outline (outline.ts)", () => {
diff --git a/tests/motion-presets.test.ts b/tests/motion-presets.test.ts
new file mode 100644
index 00000000..9e50fbde
--- /dev/null
+++ b/tests/motion-presets.test.ts
@@ -0,0 +1,580 @@
+import { describe, expect, it } from "vitest";
+import { back, CURVES, cubic, elastic, quart } from "@/lib/motion/ease";
+import { textNodes, type DisplayNode, type TextNode } from "@/lib/motion/display";
+import { drawType, planType, poseAt, staggerStarts, type TextMotion, type TypePlan } from "@/lib/motion/type/animate";
+import { setType, type TypeSpec } from "@/lib/motion/type/glyphs";
+import { F, flapCount, LOOP_REST, loopAt, neonAt, PRESET_IDS, PRESETS, presetsFor, REST, scrambleLock, cycleSet, type Pose, type PresetId } from "@/lib/motion/type/presets";
+import { spelled } from "@/lib/motion/layout";
+import { DURATION_LIMITS, STAGGER_LIMITS } from "@/lib/motion/tween";
+import { measure } from "./helpers/motion";
+
+// Kinetic text presets: each a pure function of time, frame-exact against its written spec, landing exactly on the
+// layout at rest, with the typed words intact at every frame.
+
+const FRAME = { w: 1080, h: 1920 };
+const DEG = Math.PI / 180;
+
+function makeSet(text = "Make it count", over: Partial<TypeSpec> = {}) {
+ return setType({ field: "headline", text, family: "Anton", weight: 400, max: 200, min: 60, x: 100, y: 300, width: 880, maxLines: 3, leading: 0.84, ...over }, measure);
+}
+
+function plan(id: PresetId, text = "Make it count", motion: Partial<TextMotion> = {}, spec: Partial<TypeSpec> = {}): TypePlan {
+ const preset = PRESETS[id];
+ const s = makeSet(id === "odometer" ? "$1,284" : text, { ...spec, widest: preset.widest, tabular: id === "odometer" || spec.tabular });
+ return planType("headline", s, { in: id, at: 1, seed: 7, ...motion }, FRAME);
+}
+
+/** Unit `i`'s pose `f` frames after its own start. */
+const at = (p: TypePlan, f: number, i = 0): Pose => poseAt(p, i, p.units[i].start + f * F);
+
+const close = (a: number | undefined, b: number, digits = 6) => expect(a).toBeCloseTo(b, digits);
+
+function expectRest(p: Pose) {
+ expect(p).toEqual(REST);
+}
+
+describe("frame-exact entrances", () => {
+ it("cut-rise: each line rises from below its clip, tilted 4°, in 700 ms on enter, opaque throughout", () => {
+ const p = plan("cut-rise");
+ const u = p.units[0].info;
+ const from = Math.max(1.1 * u.lh, u.clear.down);
+ const f0 = at(p, 0);
+ close(f0.dy, from);
+ close(f0.rot, 4 * DEG);
+ expect(f0.opacity).toBe(1);
+ expect(f0.clip).toBe(true);
+ const k = CURVES.enter(7 / 21);
+ close(at(p, 7).dy, (1 - k) * from);
+ close(at(p, 7).rot, (1 - k) * 4 * DEG);
+ expectRest(at(p, 21));
+ // A hero takes 850 ms.
+ const hero = plan("cut-rise", "Make it count", { hero: true });
+ expect(at(hero, 21).dy).toBeGreaterThan(0);
+ expectRest(at(hero, 26));
+ // It starts wholly below its line's clip, so not a sliver shows on the first frame.
+ expect(from).toBeGreaterThanOrEqual(u.clear.down);
+ });
+
+ it("cut-rise-glyph: letters rise 105 % of the line pitch with a 5° tilt in 650 ms", () => {
+ const p = plan("cut-rise-glyph");
+ const u = p.units[0].info;
+ const from = Math.max(1.05 * u.lh, u.clear.down);
+ close(at(p, 0).dy, from);
+ close(at(p, 0).rot, 5 * DEG);
+ const k = CURVES.enter(10 / 30 / 0.65);
+ close(at(p, 10).dy, (1 - k) * from);
+ expectRest(at(p, 20));
+ });
+
+ it("word-lift and word-drop: 0.6 em on decel in 450 ms, opaque by 60 % of the time", () => {
+ const p = plan("word-lift");
+ const em = p.set.size;
+ close(at(p, 0).dy, 0.6 * em);
+ expect(at(p, 0).opacity).toBe(0);
+ close(at(p, 6).dy, (1 - CURVES.decel(0.2 / 0.45)) * 0.6 * em);
+ close(at(p, 6).opacity, 0.2 / 0.27);
+ expectRest(at(p, 14));
+ const d = plan("word-drop");
+ close(at(d, 0).dy, -0.6 * em);
+ });
+
+ it("curtain: a feathered wipe left to right over 600 ms as the line drifts 0.1 em", () => {
+ const p = plan("curtain");
+ const em = p.set.size;
+ expect(at(p, 0).reveal).toEqual({ from: 0, to: 0, feather: 0.1 });
+ close(at(p, 9).reveal!.to, CURVES.move(0.5) * 1.1);
+ close(at(p, 9).dx, -(1 - CURVES.enter(0.5)) * 0.1 * em);
+ expectRest(at(p, 18));
+ });
+
+ it("bar-swipe: the bar grows in 7 frames, holds 2, words on when covered, then the bar leaves right in 240 ms", () => {
+ const p = plan("bar-swipe");
+ expect(at(p, 0).opacity).toBe(0);
+ close(at(p, 3).bar!.to, CURVES.snap(3 / 7));
+ expect(at(p, 3).opacity).toBe(0);
+ expect(at(p, 7).bar).toEqual({ from: 0, to: 1 });
+ expect(at(p, 7).opacity).toBe(1);
+ expect(at(p, 8).bar).toEqual({ from: 0, to: 1 });
+ close(at(p, 12).bar!.from, CURVES.snap((12 * F - 9 * F) / 0.24));
+ expectRest(at(p, 17));
+ });
+
+ it("focus-in: blur 16 → 0, opacity 0 → 1, scale 1.06 → 1 over 700 ms (cubic out)", () => {
+ const p = plan("focus-in");
+ expect(at(p, 0)).toMatchObject({ blur: 16, opacity: 0, sx: 1.06, sy: 1.06 });
+ const k = cubic.out(10 / 21);
+ close(at(p, 10).blur, 16 * (1 - k));
+ close(at(p, 10).opacity, k);
+ close(at(p, 10).sx, 1.06 - 0.06 * k);
+ expectRest(at(p, 21));
+ });
+
+ it("track-in: +0.40 em closes over 3 s on decel, opaque by 20 % and sharp by 40 % of the time", () => {
+ const p = plan("track-in");
+ expect(at(p, 0)).toMatchObject({ opacity: 0, blur: 6, tracking: 0.4 });
+ expect(at(p, 18).opacity).toBe(1);
+ close(at(p, 18).blur, 3);
+ close(at(p, 18).tracking!, 0.4 - 0.4 * CURVES.decel(0.2));
+ expect(at(p, 36).blur).toBe(0);
+ expectRest(at(p, 90));
+ });
+
+ it("snap-tight: +0.17 em of tracking snaps shut in 500 ms", () => {
+ const p = plan("snap-tight");
+ expect(at(p, 0).tracking).toBe(0.17);
+ close(at(p, 3).opacity, 0.1 / 0.12);
+ close(at(p, 3).tracking!, 0.17 * (1 - CURVES.enter(0.2)));
+ expectRest(at(p, 15));
+ });
+
+ it("slow-drift: 0.25 em from the left with opacity over 1.1 s on decel", () => {
+ const p = plan("slow-drift");
+ const em = p.set.size;
+ close(at(p, 0).dx, -0.25 * em);
+ const k = CURVES.decel((16 / 30) / 1.1);
+ close(at(p, 16).dx, -(1 - k) * 0.25 * em);
+ close(at(p, 16).opacity, k);
+ expectRest(at(p, 33));
+ });
+
+ it("stomp: 1.8 → 1 accelerating into the surface in 5 frames, a squash, a ring that grows and fades", () => {
+ const p = plan("stomp");
+ expect(at(p, 0)).toMatchObject({ sx: 1.8, sy: 1.8, opacity: 0 });
+ const s1 = 1.8 - 0.8 * CURVES.slam(1 / 5);
+ close(at(p, 1).sx, s1);
+ close(at(p, 1).opacity, 0.5);
+ expect(at(p, 5)).toMatchObject({ sx: 1.03, sy: 0.96 });
+ close(at(p, 5).ghost!.s, 1);
+ close(at(p, 5).ghost!.a, 0.35);
+ close(at(p, 7).sx, 1);
+ close(at(p, 7).ghost!.s, 1 + 0.15 * (2 / 7));
+ close(at(p, 7).ghost!.a, 0.35 * (5 / 7));
+ expectRest(at(p, 12));
+ });
+
+ it("stomp nudges the camera on impact and flashes only when asked", () => {
+ const p = plan("stomp", "SALE", { flash: true });
+ const impact = p.units[0].start + 5 * F;
+ const f = drawType(p, { fill: "#ffffff" }, impact + 0.001);
+ expect(Math.hypot(f.camera.x, f.camera.y)).toBeCloseTo(8 * Math.exp((-5 * 0.001) / (6 * F)), 3);
+ expect(f.flash).toBe(0.06);
+ expect(drawType(p, { fill: "#ffffff" }, impact + 7 * F).camera).toEqual({ x: 0, y: 0 });
+ expect(drawType(plan("stomp", "SALE"), { fill: "#ffffff" }, impact + 0.001).flash).toBe(0);
+ });
+
+ it("beat-cut: each word alone and as wide as the block for a beat, then the line lands together", () => {
+ const p = plan("beat-cut", "Run the city", { beat: 0.5 });
+ const u0 = p.units[0].info;
+ const s0 = Math.min(2.5, Math.max(1, (u0.block.w * 0.92) / u0.w));
+ close(at(p, 0, 0).sx, s0 * 1.15);
+ close(at(p, 4, 0).sx, s0);
+ expect(at(p, 0, 1).opacity).toBe(0);
+ expect(poseAt(p, 0, p.units[0].start + 0.5).opacity).toBe(0);
+ expect(poseAt(p, 1, p.units[0].start + 0.5).opacity).toBe(1);
+ close(poseAt(p, 0, p.units[0].start + 1.5).sx, 1.06);
+ expectRest(poseAt(p, 0, p.units[0].start + 1.5 + 6 * F));
+ });
+
+ it("punch: squash 1.6 × 0.7, stretch to 0.95 × 1.08, then 1 in 360 ms", () => {
+ const p = plan("punch");
+ expect(at(p, 0)).toMatchObject({ sx: 1.6, sy: 0.7 });
+ close(at(p, 6).sx, 0.95);
+ close(at(p, 6).sy, 1.08);
+ expectRest(at(p, 11));
+ });
+
+ it("pop-in: 0 → 1.12 at 60 % → 0.97 → 1 with a ±4° turn, 380 ms", () => {
+ const p = plan("pop-in");
+ expect(at(p, 0)).toMatchObject({ sx: 0, sy: 0, opacity: 0 });
+ close(Math.abs(at(p, 0).rot), 4 * DEG);
+ const q = (7 / 30) / 0.38;
+ close(at(p, 7).sx, 1.12 - 0.15 * CURVES.move((q - 0.6) / 0.2));
+ expectRest(at(p, 12));
+ });
+
+ it("burst: letters fly from the block's middle on back(1.4)", () => {
+ const p = plan("burst");
+ const u = p.units[0].info;
+ expect(at(p, 0).sx).toBe(0);
+ close(at(p, 0).dx, u.block.x + u.block.w / 2 - (u.x + u.w / 2));
+ close(at(p, 6).sx, back(1.4).out(0.2 / 0.45));
+ expectRest(at(p, 14));
+ });
+
+ it("inflate: 0.6 → 1 on elastic(1, 0.4) with a ±3° turn, 500 ms", () => {
+ const p = plan("inflate");
+ close(at(p, 0).sx, 0.6);
+ close(at(p, 6).sx, 0.6 + 0.4 * elastic(1, 0.4).out(0.4));
+ expectRest(at(p, 15));
+ });
+
+ it("merge and plates: odd lines from the left, even from the right, 40 % of the frame", () => {
+ const p = plan("merge", "Two lines\nmeet here");
+ close(at(p, 0, 0).dx, -0.4 * FRAME.w);
+ close(at(p, 0, 1).dx, 0.4 * FRAME.w);
+ expectRest(at(p, 18, 0));
+ const q = plan("plates", "Two lines\nmeet here");
+ close(at(q, 9, 0).dx, -0.4 * FRAME.w * (1 - back(1.1).out(0.5)));
+ });
+
+ it("slide-in: 30 % of the frame from the right on quart out", () => {
+ const p = plan("slide-in");
+ close(at(p, 0).dx, 0.3 * FRAME.w);
+ close(at(p, 6).dx, 0.3 * FRAME.w * (1 - quart.out(0.4)));
+ expectRest(at(p, 15));
+ });
+
+ it("echo-trail: copies 2.5 frames apart at 0.5 / 0.3 / 0.15 of the word's opacity, collapsing into it at rest", () => {
+ const p = plan("slide-in", "Make it count", { echo: 3 });
+ const t = p.units[0].start + 6 * F;
+ const echoes = (nodes: DisplayNode[]) =>
+ nodes.filter((n): n is Extract<DisplayNode, { type: "group" }> => n.type === "group" && n.children.length === 1 && n.children[0].type === "text" && !!(n.children[0] as TextNode).decor);
+ const trail = echoes(drawType(p, { fill: "#ffffff" }, t).nodes);
+ expect(trail).toHaveLength(3);
+ [0.5, 0.3, 0.15].forEach((a, k) => {
+ const q = poseAt(p, 0, t - (k + 1) * 2.5 * F);
+ close(trail[k].opacity, a * q.opacity);
+ // Each copy sits further back along the move (slide-in travels right to left).
+ close(trail[k].transform?.[4], q.dx);
+ expect(q.dx).toBeGreaterThan(at(p, 6).dx);
+ // An echo is decoration: the typed words are drawn once, by the unit itself.
+ expect((trail[k].children[0] as TextNode).runs.map((r) => r.text).join("")).toBe((trail[0].children[0] as TextNode).runs.map((r) => r.text).join(""));
+ });
+ expect(echoes(drawType(p, { fill: "#ffffff" }, p.settled + F).nodes)).toHaveLength(0);
+ expect(echoes(drawType(plan("slide-in"), { fill: "#ffffff" }, t).nodes)).toHaveLength(0);
+ });
+
+ it("flip-up: −95° to flat, squeezed by cos θ, sheared, shaded to 35 % and faded in by 45°", () => {
+ const p = plan("flip-up");
+ const u = p.units[0].info;
+ const f0 = at(p, 0);
+ expect(f0.opacity).toBe(0);
+ close(f0.sy, 0.001);
+ const th = -95 * DEG * (1 - CURVES.enter((10 / 30) / 0.65));
+ const f10 = at(p, 10);
+ close(f10.sy, Math.max(0.001, Math.cos(th)));
+ close(f10.skewX, Math.sin(th) * 0.12);
+ close(f10.dy, -Math.sin(th) * 0.6 * u.cap);
+ close(f10.shade, 0.35 * Math.min(1, Math.abs(th) / (Math.PI / 2)));
+ expectRest(at(p, 20));
+ });
+
+ it("fold: the top half hinges from 90° in 500 ms", () => {
+ const p = plan("fold");
+ close(at(p, 0).fold!, Math.PI / 2);
+ close(at(p, 6).fold!, (Math.PI / 2) * (1 - cubic.out(0.4)));
+ expectRest(at(p, 15));
+ });
+
+ it("tumble: 160° about the bottom left, 0.4 em, back(1.2), 600 ms", () => {
+ const p = plan("tumble");
+ close(at(p, 0).rot, 160 * DEG);
+ close(at(p, 0).dy, 0.4 * p.set.size);
+ expectRest(at(p, 18));
+ });
+
+ it("type-on: letters appear in steps at the typing rate, no easing", () => {
+ const p = plan("type-on", "Make it count", { rate: 20 });
+ const t = (f: number) => p.units[0].start + f * F;
+ expect(poseAt(p, 0, t(0)).opacity).toBe(1);
+ expect(poseAt(p, 1, t(1)).opacity).toBe(0);
+ expect(poseAt(p, 1, t(2)).opacity).toBe(1);
+ });
+
+ it("scramble: slots cycle letters of their own kind every two frames and lock left to right by 600 ms", () => {
+ const p = plan("scramble", "SIGNAL 42");
+ const n = p.units.length;
+ const f0 = at(p, 0, 0);
+ expect(f0.shown).toBeDefined();
+ expect(f0.shown).not.toBe(p.units[0].info.text);
+ expect(cycleSet(p.units[0].info.text)).toContain(f0.shown!);
+ expect(at(p, 1, 0).shown).toBe(f0.shown);
+ const digit = p.units.findIndex((u) => u.info.text === "4");
+ expect(cycleSet("4")).toContain(at(p, 0, digit).shown!);
+ expectRest(poseAt(p, 0, p.units[0].start + 0.25));
+ const last = scrambleLock(p.units[n - 1].info);
+ expect(last).toBeLessThanOrEqual(0.6);
+ expectRest(poseAt(p, n - 1, p.units[0].start + last));
+ });
+
+ it("neon-strike: off, 0.6, off, 0.4, off, on, 0.8, on — by frame", () => {
+ expect([0, 1, 2, 3, 6, 7, 9, 12, 13].map((f) => neonAt(f * F))).toEqual([0, 0, 0.6, 0, 0.4, 0, 1, 0.8, 1]);
+ const p = plan("neon-strike");
+ expect(at(p, 2)).toMatchObject({ glow: 0.6, shade: 0.6 * 0.4 });
+ expectRest(at(p, 13));
+ });
+
+ it("split-flap: 4–8 flips of 50 ms each, ending on the typed letter", () => {
+ const p = plan("split-flap", "GATE 12");
+ const flips = flapCount(p.units[0].info, p.options);
+ expect(flips).toBeGreaterThanOrEqual(4);
+ expect(flips).toBeLessThanOrEqual(8);
+ expect(at(p, 0).flap!.phase).toBe(0);
+ const lastFlip = poseAt(p, 0, p.units[0].start + (flips - 1) * 0.05 + 0.025);
+ expect(lastFlip.flap!.to).toBe("G");
+ expectRest(poseAt(p, 0, p.units[0].start + flips * 0.05));
+ });
+
+ it("split-flap: a figure counts up to its own value, so a clock never shows an impossible time on the way", () => {
+ const p = plan("split-flap", "03:12:45");
+ p.units.forEach((u, i) => {
+ if (!/^d$/.test(u.info.text)) return;
+ for (let f = -2; f < 30; f++) {
+ const q = poseAt(p, i, u.start + f * F);
+ if (!q.flap) continue;
+ for (const d of [q.flap.from, q.flap.to]) {
+ expect(/^d$/.test(d), d).toBe(true);
+ expect(Number(d)).toBeLessThanOrEqual(Number(u.info.text));
+ }
+ }
+ });
+ });
+
+ it("fade-rise: small facts fade in rising a few pixels in about a fifth of a second, whole (never typed)", () => {
+ const p = plan("fade-rise", "lumenlabs.io");
+ expect(p.units).toHaveLength(1);
+ expect(at(p, -1).opacity).toBe(0);
+ expect(at(p, 3).opacity).toBeGreaterThan(0.5);
+ expect(at(p, 3).dy).toBeGreaterThan(0);
+ expectRest(at(p, 7));
+ });
+
+ it("odometer: figures roll once from a blank place to their typed value, rightmost first; no leading zero; signs fade in with them", () => {
+ const p = plan("odometer");
+ const digits = p.units.filter((u) => /\d/.test(u.info.text));
+ const right = digits[digits.length - 1];
+ const left = digits[0];
+ expect(right.start).toBeLessThan(left.start);
+ expect(left.info.lead).toBe(true);
+ expect(right.info.lead).toBe(false);
+ const i = p.units.indexOf(right);
+ // Before it starts: blank (the place below 0), never a placeholder figure.
+ expect(poseAt(p, i, right.start - F).roll).toBe(-1);
+ expect(poseAt(p, i, right.start - F).rollFrom).toBe(0);
+ const target = Number(right.info.text);
+ close(poseAt(p, i, right.start + 0.7).roll!, -1 + (target + 1) * CURVES.roll(0.5));
+ // Under half a place a frame at its fastest.
+ for (let f = 0; f < 40; f++) expect(Math.abs(poseAt(p, i, right.start + (f + 1) * F).roll! - poseAt(p, i, right.start + f * F).roll!)).toBeLessThan(0.75);
+ // The leading column only rises into place: it never shows a figure below its own.
+ const li = p.units.indexOf(left);
+ expect(poseAt(p, li, left.start + 0.3).rollFrom).toBe(Number(left.info.text));
+ expectRest(poseAt(p, i, right.start + 1.4));
+ // A separator never shows before the figures round it: hidden, then it fades in over its column's second half
+ // without moving, and is at rest once the roll has passed.
+ const sign = p.units.findIndex((u) => u.info.text === ",");
+ const s0 = p.units[sign].start;
+ expect(poseAt(p, sign, s0 - F).opacity).toBe(0);
+ expect(poseAt(p, sign, s0 + 0.3).opacity).toBe(0);
+ for (let f = 0; f < 60; f++) {
+ const q = poseAt(p, sign, s0 + f * F);
+ expect(q.dx).toBe(0);
+ expect(q.dy).toBe(0);
+ }
+ expectRest(poseAt(p, sign, s0 + 0.9));
+ });
+
+ it("cut-paper: on twos (12 fps): −8° at 1.15, over to +3°, then 0", () => {
+ const p = plan("cut-paper");
+ close(at(p, 0).rot, -8 * DEG);
+ close(at(p, 0).sx, 1.15);
+ expect(at(p, 1)).toEqual(at(p, 0));
+ const s = 1 / 12;
+ close(at(p, 3).rot, (-8 + 11 * CURVES.snap(s / 0.3 / 0.6)) * DEG);
+ expectRest(at(p, 9));
+ });
+
+ it("weight-wave: 200 → 900 → the face's weight, 500 ms each", () => {
+ const p = plan("weight-wave");
+ expect(at(p, 0).weight).toBe(200);
+ close(at(p, 6).weight!, 200 + 700 * CURVES.snap(0.4));
+ expect(at(p, 15).weight).toBe(900);
+ expectRest(at(p, 30));
+ });
+
+ it("ink-draw: a feathered wipe along the word on the draw curve", () => {
+ const p = plan("ink-draw");
+ expect(at(p, 0).reveal!.to).toBe(0);
+ close(at(p, 11).reveal!.to, CURVES.draw((11 / 30) / 0.75) * 1.12);
+ expectRest(at(p, 23));
+ });
+});
+
+// ---------------------------------------------------------------------------
+
+const TEXTS = ["Make it count", "Invoices that chase themselves.", "Le Sérum\nNuit", "SALE 20% OFF"];
+
+function nonDecor(nodes: readonly DisplayNode[]): TextNode[] {
+ return textNodes(nodes).filter((n) => !n.decor);
+}
+
+describe("every preset", () => {
+ it("rests exactly on the layout: one text node, spelled exactly as typed, nothing swapped or moved", () => {
+ for (const id of PRESET_IDS) {
+ for (const text of TEXTS) {
+ const p = plan(id, text);
+ const settledAt = p.settled + 0.001;
+ for (let i = 0; i < p.units.length; i++) expectRest(poseAt(p, i, settledAt));
+ const frame = drawType(p, { fill: "#111111" }, settledAt);
+ expect(frame.still, `${id} "${text}"`).toBe(true);
+ const fields = nonDecor(frame.nodes);
+ expect(fields.length, id).toBe(1);
+ const typed = id === "odometer" ? "$1,284" : text;
+ expect(spelled(fields[0].runs), `${id} "${text}"`).toBe(typed.trim());
+ for (const r of fields[0].runs) expect(r.shown, id).toBeUndefined();
+ }
+ }
+ });
+
+ it("draws only typed letters as each run's text at every frame (a scramble's stand-in is `shown`, never `text`)", () => {
+ for (const id of PRESET_IDS) {
+ const text = "Make it count";
+ const p = plan(id, text, { exitAt: 6 });
+ const typed = id === "odometer" ? "$1,284" : text;
+ for (let f = 0; f <= 7.5 * 30; f += 1) {
+ for (const n of textNodes(drawType(p, { fill: "#111111" }, f * F).nodes)) for (const r of n.runs) expect(typed.includes(r.text), `${id} f${f} "${r.text}"`).toBe(true);
+ }
+ }
+ });
+
+ it("is deterministic: the same frame whatever order frames are asked in", () => {
+ for (const id of PRESET_IDS) {
+ const p = plan(id, "Make it count", { exitAt: 5, loop: "breathe" });
+ const times = [0.9, 1.05, 1.4, 2.2, 3.3, 5.2, 5.5];
+ const forward = times.map((t) => JSON.stringify(drawType(p, { fill: "#111111" }, t)));
+ const backward = [...times].reverse().map((t) => JSON.stringify(drawType(p, { fill: "#111111" }, t))).reverse();
+ expect(backward, id).toEqual(forward);
+ const again = planType("headline", p.set, p.motion, FRAME);
+ expect(times.map((t) => JSON.stringify(drawType(again, { fill: "#111111" }, t))), id).toEqual(forward);
+ }
+ });
+
+ it("keeps its events inside the timing rules: durations by kind, staggers by unit, eased gaps", () => {
+ for (const id of PRESET_IDS) {
+ for (const text of TEXTS) {
+ const p = plan(id, text, { exitAt: 6 });
+ for (const e of p.events) {
+ const [lo, hi] = DURATION_LIMITS[e.kind];
+ expect(e.dur, `${id} ${e.id} ${e.kind}`).toBeGreaterThanOrEqual(lo - 1e-9);
+ expect(e.dur, `${id} ${e.id} ${e.kind}`).toBeLessThanOrEqual(hi + 1e-9);
+ }
+ const groups = new Map<string, number[]>();
+ for (const e of p.events) if (e.group) groups.set(e.group, [...(groups.get(e.group) ?? []), e.start]);
+ for (const [g, starts] of groups) {
+ const [lo, hi] = STAGGER_LIMITS[p.events.find((e) => e.group === g)!.unit!];
+ for (let i = 1; i < starts.length; i++) {
+ expect(starts[i] - starts[i - 1], `${id} ${g}`).toBeGreaterThanOrEqual(lo - 1e-6);
+ expect(starts[i] - starts[i - 1], `${id} ${g}`).toBeLessThanOrEqual(hi + 1e-6);
+ }
+ }
+ }
+ }
+ });
+
+ it("exits in 60–75 % of its entrance's time, ending gone, without overshooting", () => {
+ for (const id of PRESET_IDS) {
+ const pr = PRESETS[id];
+ // (Emphasis moves that only fade away, like the weight wave, are not entrances played back.)
+ if (!pr.together && pr.dur >= 0.35 && pr.dur <= 1.1 && id !== "weight-wave") {
+ expect(pr.exitDur / pr.dur, id).toBeGreaterThanOrEqual(0.6 - 1e-9);
+ expect(pr.exitDur / pr.dur, id).toBeLessThanOrEqual(0.75 + 1e-9);
+ }
+ const p = plan(id, "Make it count", { exitAt: 5 });
+ expect(poseAt(p, 0, p.gone! + 0.01).opacity, id).toBe(0);
+ // Moves away only: the distance from rest never shrinks through the exit.
+ if (["bar-swipe", "type-on", "cut-paper", "curtain", "ink-draw", "neon-strike", "fold", "beat-cut"].includes(id)) continue;
+ let last = -1;
+ for (let k = 0; k <= 20; k++) {
+ const q = pr.exit(k / 20, p.units[0].info, p.options);
+ const d = Math.abs(q.dx) + Math.abs(q.dy) + Math.abs(q.sx - 1) + Math.abs(q.sy - 1) + Math.abs(q.rot) + (1 - q.opacity) + q.blur / 16 + (q.tracking ?? 0);
+ expect(d, `${id} exit ${k / 20}`).toBeGreaterThanOrEqual(last - 1e-9);
+ last = d;
+ }
+ }
+ });
+
+ it("starts with the entrance's first pose and ends gone after its exit", () => {
+ for (const id of PRESET_IDS) {
+ const p = plan(id, "Make it count", { exitAt: 5 });
+ expect(poseAt(p, 0, 0), id).toEqual(PRESETS[id].enter(-1, p.units[0].info, p.options));
+ }
+ });
+});
+
+describe("staggers", () => {
+ it("open wide and tighten, in order, from the middle, seeded, or from the right", () => {
+ const s = staggerStarts(6, 0.03, "ease", 7, "letters");
+ const gaps = s.slice(1).map((v, i) => v - s[i]);
+ expect(gaps[0]).toBeGreaterThan(gaps[gaps.length - 1]);
+ for (const g of gaps) expect(g).toBeGreaterThanOrEqual(0.02 - 1e-9);
+ const c = staggerStarts(5, 0.03, "centre", 7, "letters");
+ expect(c[2]).toBe(0);
+ expect(Math.min(...c)).toBe(0);
+ const r = staggerStarts(4, 0.05, "reverse", 7, "letters");
+ expect(r[3]).toBe(0);
+ expect(r[0]).toBe(Math.max(...r));
+ expect(staggerStarts(4, 0.03, "seeded", 7, "letters")).toEqual(staggerStarts(4, 0.03, "seeded", 7, "letters"));
+ });
+
+ it("start a line's letters when the line before is 60 % through", () => {
+ const p = plan("cut-rise-glyph", "Big\nideas");
+ const line0 = p.units.filter((u) => u.info.line === 0);
+ const line1 = p.units.filter((u) => u.info.line === 1);
+ const span0 = Math.max(...line0.map((u) => u.start)) - line0[0].start + 0.65;
+ close(line1[0].start - line0[0].start, span0 * 0.6);
+ });
+});
+
+describe("loops", () => {
+ it("breathe 1 → 1.02 → 1 and back at rest at the end of every cycle", () => {
+ expect(loopAt("breathe", 0, { seed: 7 }).s).toBe(1);
+ close(loopAt("breathe", 1.4, { seed: 7 }).s, 1.02);
+ close(loopAt("breathe", 2.8, { seed: 7 }).s, 1);
+ });
+
+ it("pulse a CTA 2 % a few frames after landing, held three frames, in 300 ms", () => {
+ expect(loopAt("pulse", 0, { seed: 7 })).toEqual(LOOP_REST);
+ const peak = loopAt("pulse", 4 * F + 0.15, { seed: 7 }).s;
+ close(peak, 1.02);
+ expect(loopAt("pulse", 4 * F + 0.31, { seed: 7 })).toEqual(LOOP_REST);
+ });
+
+ it("sweep light across in 800 ms, 200 ms after it starts, never again sooner than 1.6 s, never one that cannot finish in time", () => {
+ expect(loopAt("light-sweep", 0.1, { seed: 7 }).sweep).toBeNull();
+ close(loopAt("light-sweep", 0.6, { seed: 7 }).sweep!, CURVES.move(0.5));
+ expect(loopAt("light-sweep", 1.1, { seed: 7 }).sweep).toBeNull();
+ expect(loopAt("light-sweep", 1.2 + 0.3, { seed: 7, every: 1.2 }).sweep).toBeNull();
+ close(loopAt("light-sweep", 1.6 + 0.6, { seed: 7, every: 1.2 }).sweep!, CURVES.move(0.5));
+ // A sweep that would still be crossing at `until` never starts.
+ expect(loopAt("light-sweep", 1.6 + 0.6, { seed: 7, every: 1.2, until: 2.4 }).sweep).toBeNull();
+ close(loopAt("light-sweep", 0.6, { seed: 7, every: 1.2, until: 2.4 }).sweep!, CURVES.move(0.5));
+ });
+
+ it("wiggle within ±3° and 3 units, seeded, at rest between cycles; ghost-drift 3 % of the width a second", () => {
+ for (let t = 0; t < 3; t += 0.05) {
+ const w = loopAt("wiggle", t, { seed: 7 });
+ expect(Math.abs(w.rot)).toBeLessThanOrEqual(3 * DEG + 1e-9);
+ expect(Math.abs(w.dx)).toBeLessThanOrEqual(3 + 1e-9);
+ }
+ close(loopAt("wiggle", 0.8, { seed: 7 }).rot, 0);
+ close(loopAt("ghost-drift", 2, { seed: 7, frameW: 1080 }).dx, 0.03 * 1080 * 2);
+ });
+
+ it("a light sweep crosses the words inside an isolated layer, so it lights only the letters", () => {
+ const p = plan("cut-rise", "Make it count", { loop: "light-sweep" });
+ const f = drawType(p, { fill: "#111111" }, p.loopStart + 0.6);
+ const top = f.nodes[0];
+ expect(top.type === "group" && !!top.isolate).toBe(true);
+ expect(f.still).toBe(false);
+ expect(drawType(p, { fill: "#111111" }, p.loopStart + 1.2).still).toBe(true);
+ });
+});
+
+describe("tones", () => {
+ it("rule out the moves a tone never takes", () => {
+ expect(presetsFor("luxury").map((p) => p.id)).not.toContain("stomp");
+ expect(presetsFor("luxury").map((p) => p.id)).toContain("cut-rise");
+ expect(presetsFor("beauty").map((p) => p.id)).not.toContain("scramble");
+ expect(presetsFor("sales").map((p) => p.id)).toContain("stomp");
+ for (const id of PRESET_IDS) expect(PRESETS[id].tones.length, id).toBeGreaterThan(0);
+ });
+});
diff --git a/tests/motion-scenes.test.ts b/tests/motion-scenes.test.ts
index e0e6afef..07c34e79 100644
--- a/tests/motion-scenes.test.ts
+++ b/tests/motion-scenes.test.ts
@@ -24,7 +24,7 @@ const cp = (...c: number[]) => String.fromCodePoint(...c);
describe("the registry", () => {
it("has the five end-card styles", () => {
expect(END_CARD_IDS.sort()).toEqual(END_CARD_VARIANTS.map((v) => `end-card/${v}`).sort());
- for (const s of scenes) expect(s.durations).toEqual({ min: 2, max: 3, default: 2.5 });
+ for (const s of scenes) expect(s.durations).toEqual({ min: 2, max: 5, default: 2.5 });
});
});
@@ -133,14 +133,15 @@ describe("timing (motion-timing)", () => {
}
}
expect(duration - plan.settled, `${scene.id} ${duration}s hold`).toBeGreaterThanOrEqual(1);
- // The last frame is the rest frame; through the hold only the camera moves, coming home on the last frame.
+ // The last frame is the rest frame; through the hold only the camera moves (the card's light and texture stay
+ // put under it), coming home on the last frame.
expect(plan.rest).toBeCloseTo((Math.round(duration * r.fps) - 1) / r.fps, 9);
const still = plan.evaluate(plan.rest);
for (const t of [plan.settled + 0.01, (plan.settled + plan.rest) / 2, plan.rest - 1 / r.fps]) {
const held = plan.evaluate(t);
- expect(held.nodes).toHaveLength(1);
- const cam = held.nodes[0];
- expect(cam.type === "group" && cam.id === "camera" && JSON.stringify(cam.children)).toBe(JSON.stringify(still.nodes));
+ const cam = held.nodes[held.nodes.length - 1];
+ expect(cam.type === "group" && cam.id === "camera").toBe(true);
+ expect(JSON.stringify(cam.type === "group" ? [...held.nodes.slice(0, -1), ...cam.children.filter((n) => !(n.type === "group" && n.id === "sweep"))] : null)).toBe(JSON.stringify(still.nodes));
}
expect(JSON.stringify(plan.evaluate(duration))).toBe(JSON.stringify(still));
expect(plan.still(plan.rest)).toBe(true);
diff --git a/tests/motion-type.test.ts b/tests/motion-type.test.ts
new file mode 100644
index 00000000..8f9f0bad
--- /dev/null
+++ b/tests/motion-type.test.ts
@@ -0,0 +1,188 @@
+import { existsSync, readFileSync, statSync } from "node:fs";
+import { join } from "node:path";
+import { describe, expect, it } from "vitest";
+import { facesOf, fontOf, isKineticFamily, KINETIC_FACES, KINETIC_UNICODE_RANGE, weightFor } from "@/lib/motion/type/faces";
+import { heroTracking, isAllCaps, PAIRING_IDS, pairingFaces, pairingFor, PAIRINGS } from "@/lib/motion/type/pairings";
+import { figureCell, inkOf, setSpelling, setType, type BoxMeasure, type TypeSpec } from "@/lib/motion/type/glyphs";
+import { planType, drawType } from "@/lib/motion/type/animate";
+import { textNodes } from "@/lib/motion/display";
+import { spelled } from "@/lib/motion/layout";
+import { measure } from "./helpers/motion";
+
+// Kinetic's own type: self-hosted open-licence faces, nine pairings, and type set for motion with exact text.
+
+const ROOT = join(__dirname, "..");
+const pub = (url: string) => join(ROOT, "public", url.replace(/^\//, ""));
+
+describe("Kinetic faces", () => {
+ it("ships every face as a subset WOFF2 with its licence, at the size and version listed", () => {
+ expect(KINETIC_FACES.length).toBeGreaterThanOrEqual(30);
+ let total = 0;
+ for (const f of KINETIC_FACES) {
+ const file = pub(f.file);
+ expect(existsSync(file), f.file).toBe(true);
+ expect(statSync(file).size, f.id).toBe(f.bytes);
+ expect(readFileSync(file).subarray(0, 4).toString("latin1"), f.id).toBe("wOF2");
+ expect(f.bytes, `${f.id} stays small (subset)`).toBeLessThan(100 * 1024);
+ expect(existsSync(pub(f.licence)), f.licence).toBe(true);
+ expect(readFileSync(pub(f.licence), "utf8"), f.licence).toMatch(/SIL OPEN FONT LICENSE/i);
+ expect(f.v).toMatch(/^[0-9a-f]{8}$/);
+ total += f.bytes;
+ }
+ expect(total).toBeLessThan(1.5 * 1024 * 1024);
+ expect(KINETIC_UNICODE_RANGE).toMatch(/^U\+0020-007E/);
+ });
+
+ it("never ships a face under a closed or Fontshare licence", () => {
+ const banned = /satoshi|clash|general sans|cabinet|switzer|helvetica|futura|gotham|proxima/i;
+ for (const f of KINETIC_FACES) expect(f.family, f.id).not.toMatch(banned);
+ });
+
+ it("loads only the faces asked for, in the styles asked for", () => {
+ expect(facesOf(["Kinetic Anton"]).map((f) => f.id)).toEqual(["anton"]);
+ expect(facesOf([{ family: "Kinetic Instrument Serif", style: "italic" }]).map((f) => f.id)).toEqual(["instrument-serif-italic"]);
+ expect(facesOf(["Kinetic Instrument Serif"]).map((f) => f.id).sort()).toEqual(["instrument-serif", "instrument-serif-italic"]);
+ expect(facesOf(["Inter", "Playfair Display", null, undefined])).toEqual([]);
+ expect(isKineticFamily("Kinetic Fraunces Soft")).toBe(true);
+ expect(isKineticFamily("Inter")).toBe(false);
+ });
+
+ it("never takes over a brand font: families a brand kit can pick stay on the web-font service", () => {
+ // A brand set in Manrope or Anton keeps every weight and script the web-font service has.
+ for (const f of KINETIC_FACES) expect(f.family, f.id).toMatch(/^Kinetic /);
+ for (const brand of ["Anton", "Manrope", "Outfit", "Instrument Serif", "Unbounded", "Caveat", "Fraunces", "Inter"]) expect(isKineticFamily(brand), brand).toBe(false);
+ expect(facesOf(["Manrope", "Anton"])).toEqual([]);
+ });
+
+ it("asks a face only for a weight it has (a static face isn't faked bolder)", () => {
+ expect(weightFor("Kinetic Anton", 800)).toBe(400);
+ expect(weightFor("Kinetic Big Shoulders Display", 400)).toBe(600);
+ expect(weightFor("Kinetic Big Shoulders Display", 950)).toBe(900);
+ expect(weightFor("Kinetic Space Mono", 650)).toBe(700);
+ expect(fontOf("Kinetic Bodoni Moda Display", 120.4, 500, "italic")).toBe('italic 500 120px "Kinetic Bodoni Moda Display", Georgia, serif');
+ });
+});
+
+describe("type pairings", () => {
+ it("are all hosted faces, with weights and styles each face has", () => {
+ for (const id of PAIRING_IDS) {
+ const p = PAIRINGS[id];
+ for (const role of [p.hero, p.accent, p.meta, p.body, p.figures]) {
+ if (!role) continue;
+ const faces = KINETIC_FACES.filter((f) => f.family === role.family && f.style === (role.style ?? "normal"));
+ expect(faces.length, `${id} ${role.family} ${role.style ?? "normal"}`).toBeGreaterThan(0);
+ expect(faces.some((f) => role.weight >= f.weight[0] && role.weight <= f.weight[1]), `${id} ${role.family} ${role.weight}`).toBe(true);
+ }
+ expect(pairingFaces(id).length, id).toBeGreaterThanOrEqual(2);
+ expect(pairingFaces(id).length, `${id}: two families plus one mono at most`).toBeLessThanOrEqual(4);
+ }
+ });
+
+ it("set condensed caps tight and luxury caps wide, never tracking body copy", () => {
+ expect(PAIRINGS.T1.hero.leading).toBeGreaterThanOrEqual(0.82);
+ expect(PAIRINGS.T1.hero.leading).toBeLessThanOrEqual(0.9);
+ for (const id of PAIRING_IDS) expect(PAIRINGS[id].body.tracking, id).toBe(0);
+ for (const id of PAIRING_IDS) expect(PAIRINGS[id].meta.tracking, id).toBeGreaterThanOrEqual(0.06);
+ expect(heroTracking(PAIRINGS.T4, "MAISON")).toBe(0.25);
+ expect(heroTracking(PAIRINGS.T4, "Maison")).toBe(-0.005);
+ expect(isAllCaps("20% OFF")).toBe(true);
+ expect(pairingFor("beauty").id).toBe("T5");
+ expect(pairingFor("unknown").id).toBe("T1");
+ });
+});
+
+const spec = (text: string, over: Partial<TypeSpec> = {}): TypeSpec => ({ field: "headline", text, family: "Anton", weight: 400, max: 200, min: 60, x: 100, y: 300, width: 880, maxLines: 3, leading: 0.84, ...over });
+
+/** A measure with kerning: "AV" and "To" are 0.2 em tighter than their letters' sum. */
+const kerned: BoxMeasure = (text, font) => {
+ const px = Number(/(\d+)px/.exec(font)![1]);
+ let w = measure(text, font);
+ for (const pair of ["AV", "To"]) w -= (text.split(pair).length - 1) * 0.2 * px;
+ return w;
+};
+
+describe("type set for motion", () => {
+ it("spells the typed words back from its lines, words and letters, in any script", () => {
+ for (const text of ["Make it count", "Invoices that chase\nthemselves.", "Le Sérum Nuit", "مرحبا بالعالم", "東京の夜", "👩‍👩‍👧 family first", "office fluff"]) {
+ const s = setType(spec(text), measure);
+ expect(setSpelling(s), text).toBe(text.trim());
+ const p = planType("headline", s, { in: "cut-rise-glyph", at: 0 }, { w: 1080, h: 1920 });
+ expect(spelled(textNodes(drawType(p, { fill: "#000" }, 10).nodes)[0].runs), text).toBe(text.trim());
+ }
+ });
+
+ it("places each letter from the measured line up to it, so kerning survives when letters move apart", () => {
+ const s = setType(spec("AVATAR To", { max: 100, min: 100 }), kerned);
+ const font = s.font;
+ const line = "AVATAR To";
+ s.glyphs.forEach((g, k) => {
+ const offset = [...line].findIndex((_, i) => [...line.slice(0, i)].filter((c) => c !== " ").length === k && line[i] !== " ");
+ const expected = s.lines[0].x + kerned(line.slice(0, offset + 1), font) - measure(g.text, font);
+ expect(g.x, g.text).toBeCloseTo(expected, 6);
+ });
+ });
+
+ it("adds tracking after every letter (spaces too) and widens the line by it", () => {
+ const plain = setType(spec("BIG IDEA", { max: 100, min: 100 }), measure);
+ const tracked = setType(spec("BIG IDEA", { max: 100, min: 100, tracking: 0.1 }), measure);
+ expect(tracked.lines[0].w - plain.lines[0].w).toBeCloseTo(0.1 * 100 * 7, 6);
+ expect(tracked.glyphs[3].x - plain.glyphs[3].x).toBeCloseTo(0.1 * 100 * 4, 6);
+ });
+
+ it("chooses its size so the animation's widest moment fits, else flags the overflow", () => {
+ const s = setType(spec("LUMEN", { max: 300, min: 60, width: 700 }), measure);
+ const wide = setType(spec("LUMEN", { max: 300, min: 60, width: 700, widest: { tracking: 0.4 } }), measure);
+ expect(wide.size).toBeLessThan(s.size);
+ expect(wide.lines[0].w + 0.4 * wide.size * 4).toBeLessThanOrEqual(700 + 1e-6);
+ expect(setType(spec("SUPERCALIFRAGILISTIC", { max: 100, min: 60, width: 500, widest: { tracking: 0.4 } }), measure).overflow).toBe(true);
+ expect(setType(spec("Big", { max: 200, min: 60, width: 400, widest: { scale: 1.15 } }), measure).lines[0].w * 1.15).toBeLessThanOrEqual(400 + 1e-6);
+ });
+
+ it("aligns the first line's cap top to y, and centres or right-aligns lines in the box", () => {
+ const s = setType(spec("Big idea", { max: 100, min: 100 }), measure);
+ expect(s.lines[0].y + s.cap.top).toBeCloseTo(300, 6);
+ const c = setType(spec("Big idea", { max: 100, min: 100, align: "centre" }), measure);
+ expect(c.lines[0].x + c.lines[0].w / 2).toBeCloseTo(100 + 440, 6);
+ const r = setType(spec("Big idea", { max: 100, min: 100, align: "right" }), measure);
+ expect(r.lines[0].x + r.lines[0].w).toBeCloseTo(980, 6);
+ });
+
+ it("hangs an opening quote outside the left edge, and starts other lines at the ink", () => {
+ const boxed: BoxMeasure = Object.assign((t: string, f: string) => measure(t, f), { box: (t: string, f: string) => ({ top: 10, bottom: 80, left: t.startsWith("B") ? 6 : 0, right: measure(t, f) }) });
+ const q = setType(spec("“Big idea”", { max: 100, min: 100 }), boxed);
+ expect(q.glyphs[1].x).toBeCloseTo(100, 6);
+ const b = setType(spec("Big idea", { max: 100, min: 100 }), boxed);
+ expect(b.lines[0].x).toBeCloseTo(100 - 6, 6);
+ });
+
+ it("puts figures in equal cells when tabular, so a changing number never jitters", () => {
+ const narrow1: BoxMeasure = (t, f) => {
+ const px = Number(/(\d+)px/.exec(f)![1]);
+ return [...t].reduce((w, c) => w + (c === "1" ? 0.3 : 0.5) * px, 0);
+ };
+ const s = setType(spec("1,184", { max: 100, min: 100, tabular: true }), narrow1);
+ const cell = figureCell(narrow1, s.font);
+ expect(cell).toBe(50);
+ const ones = s.glyphs.filter((g) => g.text === "1");
+ // A "1" sits centred in a full figure's cell.
+ expect(ones[0].x - s.lines[0].x).toBeCloseTo((50 - 30) / 2, 6);
+ });
+
+ it("moves joining scripts and ligature lines by word only, with no tracking", () => {
+ const ar = setType(spec("مرحبا بالعالم", { tracking: 0.2 }), measure);
+ expect(ar.tracking).toBe(0);
+ expect(ar.splittable).toBe(false);
+ expect(ar.glyphs).toEqual([]);
+ const lig = setType(spec("office fluff"), measure);
+ expect(lig.lines[0].glyphs).toBeNull();
+ const p = planType("headline", lig, { in: "pop-in", at: 0 }, { w: 1080, h: 1920 });
+ expect(p.units.map((u) => u.info.kind)).toEqual(["word", "word"]);
+ });
+
+ it("estimates ink without browser metrics, and uses the browser's where given", () => {
+ expect(inkOf(measure, "Hg", '400 100px "Anton"').bottom).toBe(100);
+ expect(inkOf(measure, "H", '400 100px "Anton"')).toEqual({ top: 10, bottom: 82, left: 0, right: 50 });
+ const boxed: BoxMeasure = Object.assign((t: string, f: string) => measure(t, f), { box: () => ({ top: 1, bottom: 2, left: 3, right: 4 }) });
+ expect(inkOf(boxed, "H", "x")).toEqual({ top: 1, bottom: 2, left: 3, right: 4 });
+ });
+});
diff --git a/tests/runtime-auth.test.ts b/tests/runtime-auth.test.ts
index d518f403..74288c30 100644
--- a/tests/runtime-auth.test.ts
+++ b/tests/runtime-auth.test.ts
@@ -154,6 +154,7 @@ describe("proxy matcher (C13)", () => {
expect(matches("/next.svg")).toBe(false);
expect(matches("/samples/demo-model.glb")).toBe(false);
expect(matches("/vendor/meshopt_decoder.js")).toBe(false);
+ expect(matches("/fonts/kinetic/anton.woff2")).toBe(false);
expect(matches("/previews/presets/effect-set-on-fire.jpg")).toBe(false);
expect(matches("/previews/presets/motion-fpv-drone.mp4")).toBe(false);
expect(matches("/favicon.ico")).toBe(false);
diff --git a/tests/template-covers.test.ts b/tests/template-covers.test.ts
index 3e8bfb05..c0a7825d 100644
--- a/tests/template-covers.test.ts
+++ b/tests/template-covers.test.ts
@@ -131,10 +131,10 @@ describe("the template covers manifest", () => {
lines.push(` ${JSON.stringify(key)}: ${JSON.stringify(gen.slimEntry(key, { poster: e.poster, ...(e.video && { video: e.video }), ...(e.at && { at: e.at }), ...(e.frames && { frames: e.frames }) }))}`);
}
}
- // The studios' tiles (246, with Keyframes → animation, Outfit lookbook, Music video and Marketing's four code-drawn
+ // The studios' tiles (254, with Keyframes → animation, Outfit lookbook, Music video and Marketing's twelve code-drawn
// templates), Fuobe Soul's looks (139), AI Influencer's types (9), the empty pages' examples (6) and the studios'
// ready-made starters with a cover of their own (24).
- expect(lines).toHaveLength(246 + 139 + 9 + 6 + 24);
+ expect(lines).toHaveLength(254 + 139 + 9 + 6 + 24);
const text = `{\n${lines.join(",\n")}\n}`;
expect(text.length).toBeLessThan(37_000);
expect(gzipSync(text).length).toBeLessThan(8_000);