Generate beautiful SVG patterns from a string. This is a Python-port of Jason Long's Ruby library.
GeoPatterns is installable via pip
:
$ pip install geopatterns
Create a new pattern by initializing GeoPattern()
with a string and a
generator (the result of this string/generator pair is the above image).
>>> from geopatterns import GeoPattern
>>> pattern = GeoPattern('A string for your consideration.', generator='xes')
Currently available generators are:
hexagons
overlapping_circles
overlapping_rings
plaid
plus_signs
rings
sinewaves
squares
triangles
xes
Get the SVG string:
>>> print(pattern.svg_string)
u'<svg xmlns="http://www.w3.org/2000/svg" ...
Get the Base64-encoded string:
>>> print(pattern.base64_string)
'PHN2ZyB4bWxucz0iaHR0cDov...
In the case of the Base64-encoded string, you can use it in CSS as follows:
body {
background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz...zdmc+');
}