Created
January 14, 2021 13:40
-
-
Save rikschennink/da1550cb0aba521d4ce4b96124254308 to your computer and use it in GitHub Desktop.
A macro that generates faux code SVG path elements
This file contains hidden or 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
{% macro codeline(x, y, totalStatements, spaceWidth) %} | |
{% set offset = x %} | |
{% for i in range(0, totalStatements) -%} | |
{% set width = [2, 4, 8, 12, 24] | random %} | |
{% set opacity = [0.5, 0.75, 1] | random %} | |
<path d="M{{ offset }} {{ y }} h{{width}}" opacity="{{ opacity }}"/> | |
{% set offset = offset + width + spaceWidth %} | |
{% endfor %} | |
{% endmacro %} | |
{% macro codelines(offset, total, indent, lineHeight, spaceWidth) %} | |
{% for i in range(offset, total) -%} | |
{% set totalStatements = [1, 3, 5, 7, 9] | random %} | |
{{ codeline(indent * spaceWidth, i * lineHeight, totalStatements, spaceWidth) }} | |
{% set indent = indent + [-1, 0, 1] | random %} | |
{% if indent < 0 %} | |
{% set indent = 0 %} | |
{% endif %} | |
{% endfor %} | |
{% endmacro %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ignore the logos