Skip to content

Instantly share code, notes, and snippets.

@rikschennink
Created January 14, 2021 13:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rikschennink/da1550cb0aba521d4ce4b96124254308 to your computer and use it in GitHub Desktop.
Save rikschennink/da1550cb0aba521d4ce4b96124254308 to your computer and use it in GitHub Desktop.
A macro that generates faux code SVG path elements
{% 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 %}
@rikschennink
Copy link
Author

Ignore the logos

Screenshot 2021-01-14 at 14 37 48

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment