deckkit 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- deckkit/__init__.py +12 -0
- deckkit/_bundled_fonts.py +54 -0
- deckkit/_diagnostics.py +48 -0
- deckkit/_font_assets/SOURCES.txt +9 -0
- deckkit/_font_assets/SourceCodePro-Bold.ttf +0 -0
- deckkit/_font_assets/SourceCodePro-BoldIt.ttf +0 -0
- deckkit/_font_assets/SourceCodePro-It.ttf +0 -0
- deckkit/_font_assets/SourceCodePro-LICENSE.txt +93 -0
- deckkit/_font_assets/SourceCodePro-Regular.ttf +0 -0
- deckkit/_font_assets/SourceSans3-Bold.ttf +0 -0
- deckkit/_font_assets/SourceSans3-BoldIt.ttf +0 -0
- deckkit/_font_assets/SourceSans3-It.ttf +0 -0
- deckkit/_font_assets/SourceSans3-LICENSE.txt +93 -0
- deckkit/_font_assets/SourceSans3-Regular.ttf +0 -0
- deckkit/_variable_evaluation.py +82 -0
- deckkit/animation.py +211 -0
- deckkit/annotations.py +161 -0
- deckkit/backends/__init__.py +1 -0
- deckkit/backends/_font_embedding.py +41 -0
- deckkit/backends/_pptx_fonts.py +230 -0
- deckkit/backends/_pptx_shadows.py +241 -0
- deckkit/backends/_pptx_tables.py +251 -0
- deckkit/backends/pptx.py +1225 -0
- deckkit/backends/pptx_animation.py +175 -0
- deckkit/backends/svg.py +527 -0
- deckkit/canvas/__init__.py +40 -0
- deckkit/canvas/_geometry.py +49 -0
- deckkit/canvas/clipping.py +336 -0
- deckkit/canvas/context.py +34 -0
- deckkit/canvas/elements.py +306 -0
- deckkit/canvas/path.py +250 -0
- deckkit/canvas/scene.py +74 -0
- deckkit/canvas/style.py +31 -0
- deckkit/charts/__init__.py +59 -0
- deckkit/charts/axes.py +249 -0
- deckkit/charts/chart.py +244 -0
- deckkit/charts/content.py +132 -0
- deckkit/charts/context.py +45 -0
- deckkit/charts/interval.py +166 -0
- deckkit/charts/legends.py +82 -0
- deckkit/charts/marks.py +410 -0
- deckkit/charts/scales.py +205 -0
- deckkit/citations.py +200 -0
- deckkit/compiler.py +410 -0
- deckkit/context.py +72 -0
- deckkit/deck.py +168 -0
- deckkit/drawables/__init__.py +42 -0
- deckkit/drawables/bounds.py +17 -0
- deckkit/drawables/connector.py +22 -0
- deckkit/drawables/drawable.py +38 -0
- deckkit/drawables/ellipse.py +21 -0
- deckkit/drawables/group.py +10 -0
- deckkit/drawables/image.py +14 -0
- deckkit/drawables/line.py +18 -0
- deckkit/drawables/path.py +78 -0
- deckkit/drawables/rectangle.py +24 -0
- deckkit/drawables/rich_text.py +176 -0
- deckkit/drawables/table.py +42 -0
- deckkit/drawables/text.py +29 -0
- deckkit/effects.py +84 -0
- deckkit/expanded_views.py +561 -0
- deckkit/fonts.py +329 -0
- deckkit/geometry.py +48 -0
- deckkit/identity.py +72 -0
- deckkit/layout.py +398 -0
- deckkit/layouts/__init__.py +20 -0
- deckkit/layouts/_content.py +27 -0
- deckkit/layouts/annotations.py +217 -0
- deckkit/layouts/containers.py +202 -0
- deckkit/layouts/grid.py +299 -0
- deckkit/layouts/modifiers.py +200 -0
- deckkit/layouts/primitives.py +213 -0
- deckkit/layouts/table.py +139 -0
- deckkit/measurement.py +420 -0
- deckkit/paint.py +73 -0
- deckkit/py.typed +0 -0
- deckkit/reconcile.py +119 -0
- deckkit/semantic.py +47 -0
- deckkit/theme.py +364 -0
- deckkit/themes/__init__.py +91 -0
- deckkit/themes/clarity.py +98 -0
- deckkit/tokens.py +226 -0
- deckkit/units.py +73 -0
- deckkit/variables.py +212 -0
- deckkit/view_expansion.py +185 -0
- deckkit/views/__init__.py +100 -0
- deckkit/views/_code_source.py +42 -0
- deckkit/views/_drawing.py +52 -0
- deckkit/views/canvas.py +27 -0
- deckkit/views/code.py +481 -0
- deckkit/views/code_evolution.py +284 -0
- deckkit/views/composite_view.py +19 -0
- deckkit/views/divider.py +38 -0
- deckkit/views/ellipse.py +38 -0
- deckkit/views/grid.py +156 -0
- deckkit/views/hstack.py +43 -0
- deckkit/views/image.py +43 -0
- deckkit/views/layout_view.py +30 -0
- deckkit/views/line.py +31 -0
- deckkit/views/modifier_views.py +281 -0
- deckkit/views/path.py +36 -0
- deckkit/views/primitive_view.py +16 -0
- deckkit/views/pygments_highlighter.py +67 -0
- deckkit/views/rectangle.py +61 -0
- deckkit/views/section_number.py +21 -0
- deckkit/views/semantic/__init__.py +51 -0
- deckkit/views/semantic/before_after.py +109 -0
- deckkit/views/semantic/bullet_graph.py +216 -0
- deckkit/views/semantic/card.py +129 -0
- deckkit/views/semantic/code_block.py +41 -0
- deckkit/views/semantic/diff.py +642 -0
- deckkit/views/semantic/estimate_interval.py +137 -0
- deckkit/views/semantic/figure.py +55 -0
- deckkit/views/semantic/item_list.py +171 -0
- deckkit/views/semantic/metric.py +74 -0
- deckkit/views/semantic/pill.py +69 -0
- deckkit/views/semantic/pipeline.py +94 -0
- deckkit/views/semantic/pipeline_stage.py +59 -0
- deckkit/views/semantic/semantic_view.py +76 -0
- deckkit/views/semantic/sparkline.py +164 -0
- deckkit/views/semantic/table.py +439 -0
- deckkit/views/semantic/terminal.py +361 -0
- deckkit/views/semantic/timeline.py +158 -0
- deckkit/views/slide.py +37 -0
- deckkit/views/slide_number.py +20 -0
- deckkit/views/slides/__init__.py +16 -0
- deckkit/views/slides/section_slide.py +89 -0
- deckkit/views/slides/slide_margins.py +32 -0
- deckkit/views/slides/slide_with_margins.py +22 -0
- deckkit/views/slides/title_and_content.py +49 -0
- deckkit/views/slides/title_and_content_slide.py +55 -0
- deckkit/views/spacer.py +45 -0
- deckkit/views/stack.py +36 -0
- deckkit/views/text.py +142 -0
- deckkit/views/view.py +229 -0
- deckkit/views/vstack.py +31 -0
- deckkit/views/zstack.py +27 -0
- deckkit-0.1.0.dist-info/METADATA +123 -0
- deckkit-0.1.0.dist-info/RECORD +144 -0
- deckkit-0.1.0.dist-info/WHEEL +5 -0
- deckkit-0.1.0.dist-info/licenses/LICENSE +21 -0
- deckkit-0.1.0.dist-info/licenses/src/deckkit/_font_assets/SourceCodePro-LICENSE.txt +93 -0
- deckkit-0.1.0.dist-info/licenses/src/deckkit/_font_assets/SourceSans3-LICENSE.txt +93 -0
- deckkit-0.1.0.dist-info/top_level.txt +1 -0
deckkit/__init__.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"""Deck compilation entry points.
|
|
2
|
+
|
|
3
|
+
Author-facing building blocks live in focused namespaces: ``deckkit.views``,
|
|
4
|
+
``deckkit.views.semantic``, and ``deckkit.themes``. Lower-level extension
|
|
5
|
+
contracts likewise remain in their defining modules instead of being mirrored
|
|
6
|
+
at the package root.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from .compiler import CompiledDeck, CompiledSlide, CompiledView, Compiler
|
|
10
|
+
from .deck import Deck
|
|
11
|
+
|
|
12
|
+
__all__ = ["CompiledDeck", "CompiledSlide", "CompiledView", "Compiler", "Deck"]
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"""Pinned fonts used by the default Clarity theme."""
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
from .fonts import (
|
|
6
|
+
FileFontResolver,
|
|
7
|
+
Font,
|
|
8
|
+
PptxTypeface,
|
|
9
|
+
ResolvedFont,
|
|
10
|
+
SystemFontResolver,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
SOURCE_SANS = Font("Source Sans 3")
|
|
14
|
+
SOURCE_CODE = Font("Source Code Pro")
|
|
15
|
+
|
|
16
|
+
_DIRECTORY = Path(__file__).resolve().with_name("_font_assets")
|
|
17
|
+
_FILES = {
|
|
18
|
+
Font(family.family, weight, italic): str(_DIRECTORY / f"{stem}-{style}.ttf")
|
|
19
|
+
for family, stem in ((SOURCE_SANS, "SourceSans3"), (SOURCE_CODE, "SourceCodePro"))
|
|
20
|
+
for weight, italic, style in (
|
|
21
|
+
(400, False, "Regular"),
|
|
22
|
+
(700, False, "Bold"),
|
|
23
|
+
(400, True, "It"),
|
|
24
|
+
(700, True, "BoldIt"),
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
_TYPEFACES = {
|
|
28
|
+
path: PptxTypeface(font.family, font.numeric_weight == 700, font.italic)
|
|
29
|
+
for font, path in _FILES.items()
|
|
30
|
+
}
|
|
31
|
+
_REQUESTS = {
|
|
32
|
+
(font.family.casefold(), font.numeric_weight, font.italic): font for font in _FILES
|
|
33
|
+
}
|
|
34
|
+
_FILES_RESOLVER = FileFontResolver(_FILES)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class DefaultFontResolver:
|
|
38
|
+
"""Use the packaged faces first, then resolve other faces on the system."""
|
|
39
|
+
|
|
40
|
+
def __init__(self) -> None:
|
|
41
|
+
self._system = SystemFontResolver()
|
|
42
|
+
|
|
43
|
+
def resolve(self, source: Font) -> ResolvedFont:
|
|
44
|
+
bundled = _REQUESTS.get(
|
|
45
|
+
(source.family.casefold(), source.numeric_weight, source.italic)
|
|
46
|
+
)
|
|
47
|
+
if bundled is not None:
|
|
48
|
+
return _FILES_RESOLVER.resolve(bundled)
|
|
49
|
+
return self._system.resolve(source)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def is_bundled_face(face: ResolvedFont) -> bool:
|
|
53
|
+
"""Check that the resolved file is bundled with its original typeface."""
|
|
54
|
+
return face.index == 0 and _TYPEFACES.get(face.path) == face.powerpoint_typeface
|
deckkit/_diagnostics.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"""Attach slide and build context without changing exception types."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from collections.abc import Iterator
|
|
6
|
+
from contextlib import contextmanager
|
|
7
|
+
from dataclasses import dataclass
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@dataclass(frozen=True)
|
|
11
|
+
class SlideLocation:
|
|
12
|
+
number: int
|
|
13
|
+
label: str | None = None
|
|
14
|
+
|
|
15
|
+
@contextmanager
|
|
16
|
+
def context(self, step: int | None = None) -> Iterator[None]:
|
|
17
|
+
try:
|
|
18
|
+
yield
|
|
19
|
+
except Exception as error:
|
|
20
|
+
# Export can call a helper that already knows the specific build.
|
|
21
|
+
if not getattr(error, "_deckkit_slide_context", False):
|
|
22
|
+
message = f"Slide {self.number}"
|
|
23
|
+
if self.label:
|
|
24
|
+
message += f" ({self.label})"
|
|
25
|
+
if step == 0:
|
|
26
|
+
message += ", opening state"
|
|
27
|
+
elif step is not None:
|
|
28
|
+
message += f", build step {step}"
|
|
29
|
+
|
|
30
|
+
setattr(error, "_deckkit_slide_context", True)
|
|
31
|
+
if (
|
|
32
|
+
type(error).__str__ is BaseException.__str__
|
|
33
|
+
and len(error.args) == 1
|
|
34
|
+
and isinstance(error.args[0], str)
|
|
35
|
+
):
|
|
36
|
+
error.args = (f"{message}: {error.args[0]}",)
|
|
37
|
+
elif callable(add_note := getattr(error, "add_note", None)):
|
|
38
|
+
add_note(message)
|
|
39
|
+
else:
|
|
40
|
+
# Keep structured exceptions such as KeyError intact on Python 3.9.
|
|
41
|
+
context = _SlideContext(message)
|
|
42
|
+
context.__cause__ = error.__cause__ or error.__context__
|
|
43
|
+
raise error from context
|
|
44
|
+
raise
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class _SlideContext(Exception):
|
|
48
|
+
"""A traceback context for exceptions that need to retain their arguments."""
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
DeckKit includes unmodified static TrueType faces from these Adobe releases.
|
|
2
|
+
|
|
3
|
+
Source Sans 3, version 3.052
|
|
4
|
+
https://github.com/adobe-fonts/source-sans/tree/3.052R
|
|
5
|
+
License: SourceSans3-LICENSE.txt
|
|
6
|
+
|
|
7
|
+
Source Code Pro, version 2.042 upright and 1.062 italic
|
|
8
|
+
https://github.com/adobe-fonts/source-code-pro/tree/d3f1a59
|
|
9
|
+
License: SourceCodePro-LICENSE.txt
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
© 2023 Adobe (http://www.adobe.com/), with Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark of Adobe in the United States and/or other countries.
|
|
2
|
+
|
|
3
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
4
|
+
|
|
5
|
+
This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
-----------------------------------------------------------
|
|
9
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
10
|
+
-----------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
PREAMBLE
|
|
13
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
14
|
+
development of collaborative font projects, to support the font creation
|
|
15
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
16
|
+
open framework in which fonts may be shared and improved in partnership
|
|
17
|
+
with others.
|
|
18
|
+
|
|
19
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
20
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
21
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
22
|
+
redistributed and/or sold with any software provided that any reserved
|
|
23
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
24
|
+
however, cannot be released under any other type of license. The
|
|
25
|
+
requirement for fonts to remain under this license does not apply
|
|
26
|
+
to any document created using the fonts or their derivatives.
|
|
27
|
+
|
|
28
|
+
DEFINITIONS
|
|
29
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
30
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
31
|
+
include source files, build scripts and documentation.
|
|
32
|
+
|
|
33
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
34
|
+
copyright statement(s).
|
|
35
|
+
|
|
36
|
+
"Original Version" refers to the collection of Font Software components as
|
|
37
|
+
distributed by the Copyright Holder(s).
|
|
38
|
+
|
|
39
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
40
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
41
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
42
|
+
new environment.
|
|
43
|
+
|
|
44
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
45
|
+
writer or other person who contributed to the Font Software.
|
|
46
|
+
|
|
47
|
+
PERMISSION & CONDITIONS
|
|
48
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
49
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
50
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
51
|
+
Software, subject to the following conditions:
|
|
52
|
+
|
|
53
|
+
1) Neither the Font Software nor any of its individual components,
|
|
54
|
+
in Original or Modified Versions, may be sold by itself.
|
|
55
|
+
|
|
56
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
57
|
+
redistributed and/or sold with any software, provided that each copy
|
|
58
|
+
contains the above copyright notice and this license. These can be
|
|
59
|
+
included either as stand-alone text files, human-readable headers or
|
|
60
|
+
in the appropriate machine-readable metadata fields within text or
|
|
61
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
62
|
+
|
|
63
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
64
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
65
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
66
|
+
presented to the users.
|
|
67
|
+
|
|
68
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
69
|
+
Software shall not be used to promote, endorse or advertise any
|
|
70
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
71
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
72
|
+
permission.
|
|
73
|
+
|
|
74
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
75
|
+
must be distributed entirely under this license, and must not be
|
|
76
|
+
distributed under any other license. The requirement for fonts to
|
|
77
|
+
remain under this license does not apply to any document created
|
|
78
|
+
using the Font Software.
|
|
79
|
+
|
|
80
|
+
TERMINATION
|
|
81
|
+
This license becomes null and void if any of the above conditions are
|
|
82
|
+
not met.
|
|
83
|
+
|
|
84
|
+
DISCLAIMER
|
|
85
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
86
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
87
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
88
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
89
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
90
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
91
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
92
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
93
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Copyright 2010-2022 Adobe (http://www.adobe.com/), with Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark of Adobe in the United States and/or other countries.
|
|
2
|
+
|
|
3
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
4
|
+
|
|
5
|
+
This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
-----------------------------------------------------------
|
|
9
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
10
|
+
-----------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
PREAMBLE
|
|
13
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
14
|
+
development of collaborative font projects, to support the font creation
|
|
15
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
16
|
+
open framework in which fonts may be shared and improved in partnership
|
|
17
|
+
with others.
|
|
18
|
+
|
|
19
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
20
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
21
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
22
|
+
redistributed and/or sold with any software provided that any reserved
|
|
23
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
24
|
+
however, cannot be released under any other type of license. The
|
|
25
|
+
requirement for fonts to remain under this license does not apply
|
|
26
|
+
to any document created using the fonts or their derivatives.
|
|
27
|
+
|
|
28
|
+
DEFINITIONS
|
|
29
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
30
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
31
|
+
include source files, build scripts and documentation.
|
|
32
|
+
|
|
33
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
34
|
+
copyright statement(s).
|
|
35
|
+
|
|
36
|
+
"Original Version" refers to the collection of Font Software components as
|
|
37
|
+
distributed by the Copyright Holder(s).
|
|
38
|
+
|
|
39
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
40
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
41
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
42
|
+
new environment.
|
|
43
|
+
|
|
44
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
45
|
+
writer or other person who contributed to the Font Software.
|
|
46
|
+
|
|
47
|
+
PERMISSION & CONDITIONS
|
|
48
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
49
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
50
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
51
|
+
Software, subject to the following conditions:
|
|
52
|
+
|
|
53
|
+
1) Neither the Font Software nor any of its individual components,
|
|
54
|
+
in Original or Modified Versions, may be sold by itself.
|
|
55
|
+
|
|
56
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
57
|
+
redistributed and/or sold with any software, provided that each copy
|
|
58
|
+
contains the above copyright notice and this license. These can be
|
|
59
|
+
included either as stand-alone text files, human-readable headers or
|
|
60
|
+
in the appropriate machine-readable metadata fields within text or
|
|
61
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
62
|
+
|
|
63
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
64
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
65
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
66
|
+
presented to the users.
|
|
67
|
+
|
|
68
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
69
|
+
Software shall not be used to promote, endorse or advertise any
|
|
70
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
71
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
72
|
+
permission.
|
|
73
|
+
|
|
74
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
75
|
+
must be distributed entirely under this license, and must not be
|
|
76
|
+
distributed under any other license. The requirement for fonts to
|
|
77
|
+
remain under this license does not apply to any document created
|
|
78
|
+
using the Font Software.
|
|
79
|
+
|
|
80
|
+
TERMINATION
|
|
81
|
+
This license becomes null and void if any of the above conditions are
|
|
82
|
+
not met.
|
|
83
|
+
|
|
84
|
+
DISCLAIMER
|
|
85
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
86
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
87
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
88
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
89
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
90
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
91
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
92
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
93
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
Binary file
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"""Plan variable updates before resolving text and measuring layouts."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from collections.abc import Mapping
|
|
6
|
+
from dataclasses import dataclass, replace
|
|
7
|
+
from typing import Any
|
|
8
|
+
|
|
9
|
+
from .context import Context
|
|
10
|
+
from .expanded_views import ExpandedContainer, ExpandedDeferred, ExpandedView
|
|
11
|
+
from .variables import (
|
|
12
|
+
_VARIABLE_VALUES,
|
|
13
|
+
Occurrence,
|
|
14
|
+
Variable,
|
|
15
|
+
_VariableValues,
|
|
16
|
+
section_count,
|
|
17
|
+
slide_count,
|
|
18
|
+
)
|
|
19
|
+
from .view_expansion import expand_view
|
|
20
|
+
from .views.slide import Slide
|
|
21
|
+
from .views.view import View
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@dataclass(frozen=True)
|
|
25
|
+
class VariableBuild:
|
|
26
|
+
tree: ExpandedView
|
|
27
|
+
current: Mapping[Variable[Any], Any]
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class VariableEvaluation:
|
|
31
|
+
"""Deck-local state. The authored variable definitions hold no results."""
|
|
32
|
+
|
|
33
|
+
def __init__(
|
|
34
|
+
self, variables: tuple[Variable[Any], ...] = (), *, first_slide_number: int = 1
|
|
35
|
+
) -> None:
|
|
36
|
+
self._variables = tuple(dict.fromkeys((slide_count, section_count, *variables)))
|
|
37
|
+
self._current: dict[Variable[Any], Any] = {slide_count: first_slide_number - 1}
|
|
38
|
+
self._captured: dict[tuple[Variable[Any], str], Any] = {}
|
|
39
|
+
|
|
40
|
+
def begin_slide(self, slide: Slide | None) -> None:
|
|
41
|
+
if slide is None:
|
|
42
|
+
self._current[slide_count] += 1
|
|
43
|
+
return
|
|
44
|
+
for variable in self._variables:
|
|
45
|
+
update = variable._on_slide
|
|
46
|
+
if update is not None:
|
|
47
|
+
previous = self._current.get(variable, variable.initial)
|
|
48
|
+
self._current[variable] = update(previous, slide)
|
|
49
|
+
|
|
50
|
+
def expand(self, view: View, context: Context) -> VariableBuild:
|
|
51
|
+
occurrences: list[Occurrence[Any]] = []
|
|
52
|
+
tree = expand_view(view, context, occurrences=occurrences)
|
|
53
|
+
for occurrence in occurrences:
|
|
54
|
+
variable = occurrence.variable
|
|
55
|
+
identity = variable, occurrence.key
|
|
56
|
+
if identity not in self._captured:
|
|
57
|
+
value = occurrence._transform(
|
|
58
|
+
self._current.get(variable, variable.initial)
|
|
59
|
+
)
|
|
60
|
+
self._captured[identity] = value
|
|
61
|
+
self._current[variable] = value
|
|
62
|
+
return VariableBuild(tree, self._current.copy())
|
|
63
|
+
|
|
64
|
+
def resolve(self, build: VariableBuild) -> ExpandedView:
|
|
65
|
+
values = _VariableValues(build.current, self._current, self._captured)
|
|
66
|
+
assignment = _VARIABLE_VALUES.set(values)
|
|
67
|
+
|
|
68
|
+
def resolve_node(node: ExpandedView) -> ExpandedView:
|
|
69
|
+
if isinstance(node, ExpandedDeferred):
|
|
70
|
+
environment = node.context.environment.with_token(
|
|
71
|
+
_VARIABLE_VALUES, assignment
|
|
72
|
+
)
|
|
73
|
+
return resolve_node(
|
|
74
|
+
node.resolve(replace(node.context, environment=environment))
|
|
75
|
+
)
|
|
76
|
+
if isinstance(node, ExpandedContainer) and node.children:
|
|
77
|
+
children = tuple(resolve_node(child) for child in node.children)
|
|
78
|
+
if any(old is not new for old, new in zip(node.children, children)):
|
|
79
|
+
return replace(node, _children=children)
|
|
80
|
+
return node
|
|
81
|
+
|
|
82
|
+
return resolve_node(build.tree)
|
deckkit/animation.py
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
"""Backend-independent presentation builds and animation intent."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass, field
|
|
6
|
+
from enum import Enum
|
|
7
|
+
from typing import TYPE_CHECKING, Union
|
|
8
|
+
|
|
9
|
+
if TYPE_CHECKING:
|
|
10
|
+
from .context import State
|
|
11
|
+
from .drawables import Bounds, Drawable
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class Easing(str, Enum):
|
|
15
|
+
LINEAR = "linear"
|
|
16
|
+
EASE_IN = "ease-in"
|
|
17
|
+
EASE_OUT = "ease-out"
|
|
18
|
+
EASE_IN_OUT = "ease-in-out"
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class FallbackPolicy(str, Enum):
|
|
22
|
+
ERROR = "error"
|
|
23
|
+
CROSSFADE = "crossfade"
|
|
24
|
+
DISCRETE = "discrete"
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@dataclass(frozen=True)
|
|
28
|
+
class Animation:
|
|
29
|
+
duration: float = 0.4
|
|
30
|
+
easing: Easing = Easing.EASE_IN_OUT
|
|
31
|
+
delay: float = 0.0
|
|
32
|
+
fallback: FallbackPolicy = FallbackPolicy.ERROR
|
|
33
|
+
|
|
34
|
+
def __post_init__(self) -> None:
|
|
35
|
+
if self.duration < 0 or self.delay < 0:
|
|
36
|
+
raise ValueError("Animation duration and delay must be nonnegative")
|
|
37
|
+
|
|
38
|
+
@property
|
|
39
|
+
def is_discrete(self) -> bool:
|
|
40
|
+
return self.duration == 0
|
|
41
|
+
|
|
42
|
+
@classmethod
|
|
43
|
+
def discrete(cls, *, delay: float = 0.0) -> Animation:
|
|
44
|
+
return cls(
|
|
45
|
+
duration=0,
|
|
46
|
+
easing=Easing.LINEAR,
|
|
47
|
+
delay=delay,
|
|
48
|
+
fallback=FallbackPolicy.DISCRETE,
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
@classmethod
|
|
52
|
+
def smooth(
|
|
53
|
+
cls,
|
|
54
|
+
duration: float = 0.4,
|
|
55
|
+
*,
|
|
56
|
+
delay: float = 0.0,
|
|
57
|
+
fallback: FallbackPolicy = FallbackPolicy.ERROR,
|
|
58
|
+
) -> Animation:
|
|
59
|
+
return cls(duration, Easing.EASE_IN_OUT, delay, fallback)
|
|
60
|
+
|
|
61
|
+
@classmethod
|
|
62
|
+
def linear(
|
|
63
|
+
cls,
|
|
64
|
+
duration: float = 0.4,
|
|
65
|
+
*,
|
|
66
|
+
delay: float = 0.0,
|
|
67
|
+
fallback: FallbackPolicy = FallbackPolicy.ERROR,
|
|
68
|
+
) -> Animation:
|
|
69
|
+
return cls(duration, Easing.LINEAR, delay, fallback)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
class TransitionEffect(str, Enum):
|
|
73
|
+
APPEAR = "appear"
|
|
74
|
+
FADE = "fade"
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
@dataclass(frozen=True)
|
|
78
|
+
class Transition:
|
|
79
|
+
insertion: TransitionEffect
|
|
80
|
+
removal: TransitionEffect
|
|
81
|
+
animation: Animation = field(default_factory=Animation.smooth)
|
|
82
|
+
|
|
83
|
+
@classmethod
|
|
84
|
+
def fade(cls, duration: float = 0.3) -> Transition:
|
|
85
|
+
return cls(
|
|
86
|
+
TransitionEffect.FADE,
|
|
87
|
+
TransitionEffect.FADE,
|
|
88
|
+
Animation(duration, Easing.EASE_IN_OUT, fallback=FallbackPolicy.CROSSFADE),
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
@classmethod
|
|
92
|
+
def appear(cls) -> Transition:
|
|
93
|
+
return cls(
|
|
94
|
+
TransitionEffect.APPEAR,
|
|
95
|
+
TransitionEffect.APPEAR,
|
|
96
|
+
Animation.discrete(),
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
@dataclass(frozen=True)
|
|
101
|
+
class OnAdvance:
|
|
102
|
+
"""Start a build when the presenter advances the presentation."""
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
@dataclass(frozen=True)
|
|
106
|
+
class WithPrevious:
|
|
107
|
+
delay: float = 0.0
|
|
108
|
+
|
|
109
|
+
def __post_init__(self) -> None:
|
|
110
|
+
if self.delay < 0:
|
|
111
|
+
raise ValueError("Trigger delay must be nonnegative")
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
@dataclass(frozen=True)
|
|
115
|
+
class AfterPrevious:
|
|
116
|
+
delay: float = 0.0
|
|
117
|
+
|
|
118
|
+
def __post_init__(self) -> None:
|
|
119
|
+
if self.delay < 0:
|
|
120
|
+
raise ValueError("Trigger delay must be nonnegative")
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
Trigger = Union[OnAdvance, WithPrevious, AfterPrevious]
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
@dataclass(frozen=True)
|
|
127
|
+
class TimelineStep:
|
|
128
|
+
state: State
|
|
129
|
+
trigger: Trigger = field(default_factory=OnAdvance)
|
|
130
|
+
animation: Animation = field(default_factory=Animation.discrete)
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
@dataclass(frozen=True)
|
|
134
|
+
class SlideTimeline:
|
|
135
|
+
initial: State
|
|
136
|
+
subsequent: tuple[TimelineStep, ...] = ()
|
|
137
|
+
|
|
138
|
+
def __post_init__(self) -> None:
|
|
139
|
+
from .context import State
|
|
140
|
+
|
|
141
|
+
if not isinstance(self.initial, State):
|
|
142
|
+
raise TypeError("timeline initial value must be State")
|
|
143
|
+
if any(not isinstance(step, TimelineStep) for step in self.subsequent):
|
|
144
|
+
raise TypeError("timeline steps must be TimelineStep values")
|
|
145
|
+
|
|
146
|
+
@classmethod
|
|
147
|
+
def static(cls, state: State | None = None) -> SlideTimeline:
|
|
148
|
+
"""Create a timeline with one state and no presentation advances."""
|
|
149
|
+
from .context import State
|
|
150
|
+
|
|
151
|
+
if state is not None and not isinstance(state, State):
|
|
152
|
+
raise TypeError("timeline state must be State")
|
|
153
|
+
return cls(state if state is not None else State())
|
|
154
|
+
|
|
155
|
+
@classmethod
|
|
156
|
+
def advance_through(cls, initial: State, *states: State) -> SlideTimeline:
|
|
157
|
+
"""Advance through arbitrary state snapshots on successive presenter clicks."""
|
|
158
|
+
from .context import State
|
|
159
|
+
|
|
160
|
+
if not isinstance(initial, State) or any(
|
|
161
|
+
not isinstance(state, State) for state in states
|
|
162
|
+
):
|
|
163
|
+
raise TypeError("timeline values must be State values")
|
|
164
|
+
return cls(initial, tuple(TimelineStep(state) for state in states))
|
|
165
|
+
|
|
166
|
+
@classmethod
|
|
167
|
+
def steps(cls, count: int) -> SlideTimeline:
|
|
168
|
+
"""Create ``count`` click-advanced states numbered ``step=0`` onward."""
|
|
169
|
+
from .context import State
|
|
170
|
+
|
|
171
|
+
if isinstance(count, bool) or not isinstance(count, int):
|
|
172
|
+
raise TypeError("step count must be an integer")
|
|
173
|
+
if count < 1:
|
|
174
|
+
raise ValueError("step count must be at least one")
|
|
175
|
+
return cls.advance_through(*(State(step=number) for number in range(count)))
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
class EffectKind(str, Enum):
|
|
179
|
+
INSERT = "insert"
|
|
180
|
+
REMOVE = "remove"
|
|
181
|
+
MOVE = "move"
|
|
182
|
+
CHANGE = "change"
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
@dataclass(frozen=True)
|
|
186
|
+
class VisualState:
|
|
187
|
+
bounds: Bounds
|
|
188
|
+
drawable: Drawable
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
@dataclass(frozen=True)
|
|
192
|
+
class EffectInstance:
|
|
193
|
+
identity: str
|
|
194
|
+
kind: EffectKind
|
|
195
|
+
before: VisualState | None
|
|
196
|
+
after: VisualState | None
|
|
197
|
+
animation: Animation = field(default_factory=Animation.discrete)
|
|
198
|
+
transition: Transition | None = None
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
@dataclass(frozen=True)
|
|
202
|
+
class BuildProgram:
|
|
203
|
+
trigger: Trigger
|
|
204
|
+
effects: tuple[EffectInstance, ...]
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
@dataclass(frozen=True)
|
|
208
|
+
class AnimationProgram:
|
|
209
|
+
"""Resolved builds independent of PPTX, HTML, or frame sampling."""
|
|
210
|
+
|
|
211
|
+
builds: tuple[BuildProgram, ...]
|