-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
187 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,99 +1,156 @@ | ||
# + tags=["hide_inp"] | ||
# --- | ||
# jupyter: | ||
# jupytext: | ||
# cell_markers: '"""' | ||
# cell_metadata_filter: tags,title,-all | ||
# formats: py:percent | ||
# text_representation: | ||
# extension: .py | ||
# format_name: percent | ||
# format_version: '1.3' | ||
# jupytext_version: 1.16.4 | ||
# --- | ||
|
||
# %% tags=["hide_inp"] | ||
from chalk.core import BaseDiagram | ||
from chalk import * | ||
# - | ||
|
||
|
||
# Each diagram has an origin and an envelope. | ||
# Manipulating the position of the diagram with respect to its origin and envelope allows for precise control of the layout. | ||
# Note that the Chalk API is immutable and always returns a new ``Diagram`` object. | ||
# %% [markdown] | ||
""" | ||
Each diagram has an origin and an envelope. | ||
Manipulating the position of the diagram with respect to its origin and envelope allows for precise control of the layout. | ||
Note that the Chalk API is immutable and always returns a new ``Diagram`` object. | ||
""" | ||
|
||
# ### Diagram.show_origin | ||
# %% [markdown] | ||
""" | ||
### Diagram.show_origin | ||
""" | ||
|
||
# + tags=["hide_inp"] | ||
# %% tags=["hide_inp"] | ||
help(BaseDiagram.show_origin) | ||
# - | ||
|
||
# | ||
# %% [markdown] | ||
""" | ||
triangle(1).show_origin() | ||
""" | ||
|
||
# %% | ||
d = triangle(1).show_origin() | ||
from IPython.display import HTML, Image | ||
d.render("test.png") | ||
Image("test.png") | ||
|
||
|
||
triangle(1).show_origin().render_svg("/tmp/test.svg") | ||
# %% | ||
triangle(1).show_origin() | ||
|
||
# ### Diagram.show_envelope | ||
# %% [markdown] | ||
""" | ||
### Diagram.show_envelope | ||
""" | ||
|
||
# + tags=["hide_inp"] | ||
# %% tags=["hide_inp"] | ||
help(BaseDiagram.show_envelope) | ||
# - | ||
|
||
# %% Cell 2 | ||
rectangle(1, 1).show_envelope() | ||
|
||
|
||
# %% | ||
triangle(1).show_envelope() | ||
|
||
|
||
# %% | ||
rectangle(1, 1).show_beside(triangle(1), unit_x) | ||
|
||
|
||
# %% | ||
(rectangle(1, 1) | triangle(1)).pad(1.4) | ||
|
||
|
||
# %% | ||
arc(1, 0, 90) | ||
|
||
# ### Diagram.align_* | ||
# %% [markdown] | ||
""" | ||
### Diagram.align_* | ||
""" | ||
|
||
# + tags=["hide_inp"] | ||
# %% tags=["hide_inp"] | ||
help(BaseDiagram.align_t) | ||
# - | ||
|
||
# | ||
# %% [markdown] | ||
""" | ||
triangle(1).align_t().show_origin() | ||
""" | ||
|
||
# %% | ||
triangle(1).align_t().show_origin() | ||
|
||
# %% | ||
|
||
# %% | ||
triangle(1).align_t().show_beside(rectangle(1, 1).align_b(), unit_x) | ||
|
||
|
||
# + tags=["hide_inp"] | ||
# %% tags=["hide_inp"] | ||
help(BaseDiagram.align_r) | ||
# - | ||
|
||
# ### Diagram.center_xy | ||
# %% [markdown] | ||
""" | ||
### Diagram.center_xy | ||
""" | ||
|
||
# + tags=["hide_inp"] | ||
# %% tags=["hide_inp"] | ||
help(BaseDiagram.center_xy) | ||
# - | ||
|
||
# | ||
# %% [markdown] | ||
""" | ||
""" | ||
|
||
# %% | ||
triangle(1).center_xy().show_envelope().show_origin() | ||
|
||
|
||
# ### Diagram.pad_* | ||
# %% [markdown] | ||
""" | ||
### Diagram.pad_* | ||
""" | ||
|
||
# + tags=["hide_inp"] | ||
# %% tags=["hide_inp"] | ||
help(BaseDiagram.pad) | ||
# - | ||
|
||
|
||
# | ||
# %% [markdown] | ||
""" | ||
""" | ||
|
||
# %% | ||
triangle(1).pad(1.5).show_envelope().show_origin() | ||
|
||
|
||
# ### Diagram.with_envelope | ||
# %% [markdown] | ||
""" | ||
### Diagram.with_envelope | ||
""" | ||
|
||
# + tags=["hide_inp"] | ||
# %% tags=["hide_inp"] | ||
help(BaseDiagram.with_envelope) | ||
# - | ||
|
||
|
||
# | ||
# %% [markdown] | ||
""" | ||
""" | ||
|
||
|
||
# %% | ||
(rectangle(1, 1) + triangle(0.5)) | rectangle(1, 1) | ||
|
||
|
||
# %% | ||
(rectangle(1, 1) + triangle(0.5)).with_envelope(triangle(0.5)) | rectangle(1, 1).fill_color("red") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.