iceberg-dsl
A compositional diagramming and animation library as an eDSL in Python
Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (9.5%) to scientific vocabulary
Repository
A compositional diagramming and animation library as an eDSL in Python
Basic Info
- Host: GitHub
- Owner: revalo
- License: mit
- Language: Python
- Default Branch: main
- Size: 29.2 MB
Statistics
- Stars: 218
- Watchers: 3
- Forks: 6
- Open Issues: 2
- Releases: 1
Metadata Files
README.md
IceBerg
Iceberg is a compositional diagramming and graphics library embedded in Python. It is designed to be performant, extensible, and easy to use.
The above animation was 33 lines of code
Playground
Online Interactive Playground on Colab!
Documentation
A walkthrough tutorial on diagramming with Iceberg can be found here.
Showcase
Geometry

Neural Network
A composable Neural Network diagramming class written in iceberg. Full example in examples/neural_network.py.

```python import iceberg as ice
network = NeuralNetwork( # Number of nodes in each layer! layernodecounts=[3, 4, 4, 2], nodebordercolor=ice.Colors.BLACK, linepathstyle=ice.PathStyle(ice.Colors.BLACK, thickness=3), )
canvas = ice.Blank(ice.Bounds(size=(1080, 720)), background=ice.Colors.WHITE) scene = canvas.add_centered(network) scene.render("test.png")
```
Tex, Arrangements, SVG Outputs
Iceberg supports Tex and Arrangements. Full example in examples/connect.py.
```python import iceberg as ice
leftellipse = ice.Ellipse( rectangle=ice.Bounds(size=(CIRCLEWIDTH, _CIRCLEWIDTH)), bordercolor=ice.Color.fromhex("#d63031"), borderthickness=BORDERTHICKNESS, fillcolor=ice.Color.fromhex("#ff7675"), ).pad(CIRCLE_PAD)
rightellipse = ice.Ellipse( rectangle=ice.Bounds(size=(CIRCLEWIDTH, _CIRCLEWIDTH)), bordercolor=ice.Color.fromhex("#0984e3"), borderthickness=BORDERTHICKNESS, fillcolor=ice.Color.fromhex("#74b9ff"), ).pad(CIRCLE_PAD)
ellipses = ice.Arrange( [leftellipse, rightellipse], gap=500, )
with ellipses:
# Within this context, we can use relative_bounds to get the bounds of the
# left_ellipse and right_ellipse relative to the ellipses object.
arrow = ice.Arrow(
leftellipse.relativebounds.corners[Corner.MIDDLERIGHT],
rightellipse.relativebounds.corners[Corner.MIDDLELEFT],
linepathstyle=ice.PathStyle(
color=ice.Colors.BLACK,
thickness=3,
),
)
arrowlabel = ice.MathTex("f(x) = x^2").scale(4) arrow = ice.LabelArrow( arrow, arrowlabel, ice.Corner.BOTTOM_MIDDLE, distance=20, ) connection = ice.Compose([ellipses, arrow])
textblock = ice.Text( "This is some really long text, and it's going to wrap around at some point, because it's so long and I spent a lot of time on it.", fontstyle=ice.FontStyle( family=FONTFAMILY, size=28, color=ice.Colors.BLACK, ), width=connection.bounds.width, )
scene = ice.Arrange( [connection, textblock], gap=10, arrangedirection=ice.Arrange.Direction.VERTICAL, ) ```
Animations
IceBerg can take a difference between two scenes and interpolate the difference.
```python sceneA = blank.addcentered(arrangeA) sceneB = blank.addcentered(arrangeB)
Interpolate between two different arrangements.
scene = tween(sceneA, sceneB, t / self.duration) ```
Install
The library is still under development, hence updates are frequent. To install the latest version, run the following command:
pip install git+https://github.com/revalo/iceberg.git
Not recommended yet, but if you want a stable version, use the PyPI package.:
pip install -U iceberg-dsl
Quickstart
Full example in examples/quickstart.py.
```python import iceberg as ice
What font?
FONTFAMILY = "Arial"
Create a blank canvas.
canvas = ice.Blank(ice.Bounds(size=(1080, 720)))
Create a rectangle.
rectangle = ice.Rectangle( ice.Bounds(size=(500, 100)), ice.Colors.WHITE, border_thickness=3, )
Create some text.
text = ice.SimpleText( text="Hello, World!", fontstyle=ice.FontStyle( family=FONT_FAMILY, size=28, color=ice.Colors.WHITE, ), )
Combine the rectangle and text into a new object that has
the text placed 10 pixels under the rectangle.
rectangleandtext = rectangle.next_to(text, ice.Directions.DOWN * 10)
Place the rectangle and text in the center of the canvas.
scene = canvas.addcentered(rectangleand_text) scene.render("test.png") ```
Should produce:

Citation
Cite Iceberg by clicking the "cite this repository" button on the right sidebar.
@software{IceBerg_Contributors_IceBerg_Compositional_2023,
author = {{IceBerg Contributors}},
license = {MIT},
month = jul,
title = {{IceBerg – Compositional Graphics & Diagramming}},
url = {https://github.com/revalo/iceberg},
year = {2023}
}
Owner
- Name: Shreyas Kapur
- Login: revalo
- Kind: user
- Location: Berkeley
- Company: UC Berkeley
- Website: https://shreyaskapur.com
- Repositories: 29
- Profile: https://github.com/revalo
PhD Student @ Berkeley AI; Previously CS @ MIT
Citation (CITATION.cff)
# YAML 1.2
---
authors:
-
name: "IceBerg Contributors"
cff-version: "1.2.0"
date-released: 2023-07-04
license: MIT
title: IceBerg – Compositional Graphics & Diagramming
url: "https://github.com/revalo/iceberg"
GitHub Events
Total
- Watch event: 11
- Push event: 1
- Pull request review comment event: 1
- Pull request review event: 3
- Pull request event: 2
Last Year
- Watch event: 11
- Push event: 1
- Pull request review comment event: 1
- Pull request review event: 3
- Pull request event: 2
Packages
- Total packages: 1
-
Total downloads:
- pypi 199 last-month
- Total dependent packages: 1
- Total dependent repositories: 0
- Total versions: 8
- Total maintainers: 1
pypi.org: iceberg-dsl
A compositional diagramming tool for Python.
- Homepage: https://github.com/revalo/iceberg
- Documentation: https://github.com/revalo/iceberg/README.md
- License: MIT
-
Latest release: 0.1.2
published about 2 years ago
Rankings
Maintainers (1)
Dependencies
- absl-py >=1.0.0
- glfw ==2.5.1
- numpy >=1.21.0
- skia-python ==87.5
- tqdm >=4.62.3
- absl-py >=1.0.0
- glfw ==2.5.1
- numpy >=1.21.0
- skia-python ==87.5
- tqdm >=4.62.3