Skip to main content

Welcome to svgblock

PyPI version Python 3.10+ No dependencies Coverage 95%+ 50 themes 31 animations 26 easings SVG output

What svgblock does

Table of Contents

How a block is built

⬆ back to top

How to use

Step 1: install svgblock

pip install svgblock

Step 2: write your first block

from svgblock import Block, RiseIn, Theme

(
    Block(theme=Theme.NEON, width=900, animation=RiseIn())
    .title("Hello, I'm Bob")
    .text("I build **small tools** in **pure Python** and I love open source.")
    .subsection("What I am learning")
    .text("Right now I am studying **graph algorithms** and **computer vision**.")
    .save("assets/block.svg")
)

Step 3: run the script

python generate_blocks.py

Step 4: use the SVG

<img src="assets/block.svg" alt="About me" width="900">
![About me](assets/block.svg)

Optional: add more blocks

from svgblock import Block, FadeIn, PopIn, Theme

Block(theme=Theme.DRACULA, animation=FadeIn()).title("About me").text("...").save("assets/about.svg")
Block(theme=Theme.NORD, animation=PopIn()).title("Projects").text("...").save("assets/projects.svg")

Optional: use the repository locally

git clone https://github.com/JonatasCortes/svgblock.git
cd svgblock
pip install -e .

⬆ back to top

Building a block

from svgblock import Block, FadeIn, Theme

Block(theme=Theme.RED, width=900, padding=32, animation=FadeIn())

Dividers

.divider()      # full width
.divider(0.6)   # 60% of the width, centered

Text markers

.text("**bold**, __underlined__, --struck-- and ##italic##")
.text(r"A literal \*\* needs a backslash before each asterisk.")

Columns

from svgblock import Block, Column, Theme

(
    Block(theme=Theme.NORD)
    .columns(
        Column(1).subsection("Weight 1").text("A narrow column."),
        Column(2).subsection("Weight 2").text("A column twice as wide."),
    )
)

Tables

.table(
    ["Language", "Level", "Typed"],
    [
        ["Python", "**Advanced**", True],
        ["Rust", "##Learning##", True],
        ["COBOL", "--Retired--", None],
    ],
    align=("left", "center", "center"),
    weights=(2, 2, 1),
    striped=True,
    row_dividers=True,
    column_dividers=True,
)

Images

(
    Block(theme=Theme.NEON)
    .columns(
        Column().image("assets/logo.png", width=350),
        Column().subsection("A logo beside the text").text("The image sits in a column and the text takes the rest of the width."),
    )
)

⬆ back to top

Animations

from svgblock import Block, PopIn, RiseIn, RiseOut, Sequence, Show, Hide

# Default values
Block(animation=RiseIn())

# A configured animation
Block(animation=RiseIn(distance=80, duration=1.2))

# A sequence: enter, rest for 3 seconds and enter again, forever
Block(animation=Sequence(PopIn(), Show(3), loop_limit=None))

# Enter, rest and leave, forever
Block(animation=Sequence(RiseIn(), Show(2), RiseOut(), Hide(0.5), loop_limit=None))

fade in animation fade out animation focus in animation focus out animation rise in animation rise out animation drop in animation drop out animation slide in animation slide out animation pop in animation pop out animation zoom in animation zoom out animation spin in animation spin out animation flip in animation flip out animation unfold in animation unfold out animation flicker in animation flicker out animation glitch in animation glitch out animation pulse animation float animation sway animation rotate animation drift animation shake animation jelly animation

Easings

from svgblock import Bounce, CubicBezier, DropIn, EaseOutBack, RiseIn, Spring, Steps

RiseIn(easing=EaseOutBack())
RiseIn(easing=CubicBezier(0.4, 0, 0.2, 1))
RiseIn(easing=Steps(10))
RiseIn(easing=Spring(), duration=1.4)
DropIn(distance=120, fade=False, easing=Bounce(), duration=1.4)

ease in animation without easing ease in animation with easing ease out animation without easing ease out animation with easing ease in out animation without easing ease in out animation with easing overshoot animation without easing overshoot animation with easing custom curve animation without easing custom curve animation with easing steps animation without easing steps animation with easing spring animation without easing spring animation with easing bounce animation without easing bounce animation with easing

Repeating animations

from svgblock import Float, Pulse

Pulse()                  # runs once
Pulse(loop_limit=4)      # runs five times
Pulse(loop_limit=None)   # never stops
Float(loop_limit=None)   # any ambient animation works the same way

Sequences

from svgblock import (Float, Hide, PopIn, Pulse, RiseIn, RiseOut, Sequence, Show,
                      ZoomIn, ZoomOut)

Sequence(PopIn(), Show(3), loop_limit=None)

Sequence(Hide(0.5), RiseIn(), Pulse(loop_limit=1), Show(2), loop_limit=None)

# Enter, float for three runs, leave
Sequence(RiseIn(), Float(loop_limit=2), RiseOut(), loop_limit=None)

Sequence(ZoomIn(), Show(2), ZoomOut(), Hide(0.5), loop_limit=None)

appear, stay, leave sequence leave the way it came sequence rise, float, leave sequence land and wobble sequence neon sign sequence glitch alert sequence keep turning sequence fade in, then breathe sequence

⬆ back to top

Customization

Editing a theme

from svgblock import Block, Theme

# Changes the theme for the whole program: set it before building the blocks
Theme.RED.value.update(title_text="#FF9900", title_bar="#FF9900")
Block(theme=Theme.RED).title("Orange titles on the red theme")

# Makes a variation and keeps the original untouched
softer_red = Theme.RED.value.copy()
softer_red.update(background_center="#2A1414", text="#FFD9D9")
Block(theme=softer_red).title("A softer red")

default theme customized theme

Customizing spacing

default spacing customized spacing

Customizing an animation

from svgblock import (DropIn, FadeIn, FlipIn, FocusIn, Jelly, Linear, PopIn, Pulse,
                      RiseIn, Shake, SlideIn, SpinIn, Sway, UnfoldIn)

RiseIn(distance=80, duration=1.6, fade=False)
DropIn(distance=20, duration=0.4)
SlideIn(direction="left", distance=120)
PopIn(start_scale=0.3, duration=1.2)
SpinIn(angle=-120, focus=True)
FlipIn(axis="vertical")
UnfoldIn(edge="left", fade=True)
FocusIn(blur=16, duration=1.6)
Pulse(amount=0.1, duration=1, loop_limit=4)
Sway(angle=8, pivot="bottom", loop_limit=None)
Shake(amount=16, shakes=10)
FadeIn(duration=2, easing=Linear())

default animation customized animation

Creating your own theme

from svgblock import Block, ThemeData

ocean = ThemeData(
    background_center="#1B2B34", background_edge="#0B1014",
    border_start="#6699CC", border_end="#223344",
    title_text="#99C794", title_bar="#99C794",
    subsection_text="#FAC863", subsection_marker="#FAC863",
    text="#D8DEE9", highlight="#FFFFFF",
    underline="#6699CC", strikethrough="#65737E", italic="#C0C5CE",
    table_background="#10181D", table_header_background="#223540",
    table_header_text="#99C794", table_text="#D8DEE9",
    table_divider="#33505F", table_stripe_background="#15222A",
    table_border="#33505F", divider="#6699CC",
)

Block(theme=ocean).title("Ocean").text("A theme created in my own code.").save("assets/ocean.svg")

⬆ back to top

Themes

from svgblock import Block, Theme

Block(theme=Theme.DRACULA)

# List every ready-made theme
for theme in Theme:
    print(theme.name)

Dark colors

red theme orange theme yellow theme green theme blue theme purple theme pink theme obsidian theme

Light colors

mint theme chocomint theme lavender theme peach theme sky theme

Seasons

spring theme summer theme autumn theme winter theme

Drinks

wine theme beer theme coffee theme matcha theme berrymatcha theme latte theme

Countries and geography

brazil theme usa theme miami theme france theme japandark theme japanlight theme sakura theme india theme china theme mexico theme fiesta theme greece theme egypt theme

Aesthetics and culture

neon theme cyberpunk theme steampunk theme synthwave theme lofi theme

Classical UI dev themes

dracula theme mocha theme nord theme solarizeddark theme solarizedlight theme atlas theme

Mythology and concepts

heaven theme hell theme abyss theme

⬆ back to top

Troubleshooting

⬆ back to top

Made with love

Metadata

Release files for svgblock 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for svgblock 1.0.0
File Size Uploaded Provenance Actions
svgblock-1.0.0.tar.gz 41.8 kB Without provenance Details for svgblock-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for svgblock 1.0.0
File Interpreter ABI Platform Actions
svgblock-1.0.0-py3-none-any.whl Python 3 none any Details for svgblock-1.0.0-py3-none-any.whl

Total release size: 87.5 kB

Release files / svgblock-1.0.0.tar.gz

Download URL svgblock-1.0.0.tar.gz
Size 41.8 kB
Tags Source
SHA-256 checksum
How to use checksums
594a34e23b541f72a8c50e32c8f1d87a4a6af190d4e8f1eff2e9784c98fe9f9c
BLAKE2b-256 checksum
How to use checksums
a52901c65d3eacaa8a092d1fa17c77a6fa7f94d9f12f2c7c8f4f32e46ef71be0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.2

Release files / svgblock-1.0.0-py3-none-any.whl

Download URL svgblock-1.0.0-py3-none-any.whl
Size 45.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f721e2ba41b909269f218dff6b9eebe1af4b22b4c492728174e7d2a289b32626
BLAKE2b-256 checksum
How to use checksums
1d48b87043e4e4198397d2782e157995506ac25fc0939417cfd9562c817a660a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.2

Security for svgblock 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page