• Stars
    star
    129
  • Rank 277,735 (Top 6 %)
  • Language
    Python
  • License
    MIT License
  • Created over 10 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Python-port of @jasonlong's lovely SVG generation library.

GeoPatterns

Generate beautiful SVG patterns from a string. This is a Python-port of Jason Long's Ruby library.

Installation

GeoPatterns is installable via pip:

$ pip install geopatterns

Usage

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+');
}

You can use cairosvg to save the SVG string as a PNG image. First, install cairosvg:

pip install cairosvg

And then run:

>>> import cairosvg
>>> from geopatterns import GeoPattern
>>> pattern = GeoPattern('A string for your consideration.', generator='xes')
>>> cairosvg.svg2png(bytestring=pattern.svg_string, write_to="output.png")

If you just want to visualize the pattern, you can use cairosvg with PIL:

>>> import matplotlib.pyplot as plt
>>> from PIL import Image
>>> import cairosvg
>>> from geopatterns import GeoPattern
>>> pattern = GeoPattern('A string for your consideration.', generator='xes')
>>> png = cairosvg.svg2png(bytestring=pattern.svg_string)
>>> image = Image.open(BytesIO(png))
>>> plt.imshow(image)
>>> plt.show()

More Repositories

1

hello-social-registration

A "pluggable" authentication scheme making use of the new django-registration. Currently "supporting" Twitter and Facebook (OAuth 2.0). Extracted from Hello! Ranking.
Python
35
star
2

perpetual

Repeat one, done right.
Objective-C
25
star
3

hello-coda-slider

A fork of Niall Doherty's Coda Slider jQuery script, modified for my use on Hello! Ranking.
JavaScript
21
star
4

dotfiles

My dotfiles.
Shell
20
star
5

django-textmate.tmbundle

My personal edits to the Django Textmate bundle. Use it for source code highlighting nirvana.
Python
20
star
6

shiver

Be in the know when your favorite streamers go live on Twitch, right in your menu bar.
Objective-C
19
star
7

dota2.py

A Python library for DotA 2's WebAPI.
Python
15
star
8

chaoticsoul

A mildly-popular two column WordPress theme based off of a certain designer's old website.
PHP
10
star
9

errors

A set of custom error pages for Apache (I always need them but always forget to make them).
9
star
10

elsydeon-2016

The Hubot-powered bot for my Twitch channel.
CoffeeScript
7
star
11

avalonstar-tv

The code that powers the website and the overlays for http://twitch.tv/avalonstar.
CSS
7
star
12

jekyll-widont

Yet another widow-bashing-Liquid-filter for Jekyll.
Ruby
7
star
13

avalonstar.com

This be something. Something awesome.
CSS
7
star
14

avalonstar-live

The control center for avalonstar.tv.
CSS
6
star
15

tsunku

Revyver's Hubot. Also, a manager of idols. Also, a troll.
CoffeeScript
5
star
16

baymax

"Hello, I am your personal Twitch companion."
CoffeeScript
5
star
17

elophant.py

A Python library for Elophant's League of Legends API.
Python
4
star
18

angelicsoul

A inverted modification of the mildly popular two-column WordPress theme.
PHP
3
star
19

atvbot

A chat bot for avalonstar.tv that runs as the broadcaster to capture certain broadcaster-only messages. This bot responds to nothing.
CoffeeScript
3
star
20

avalonstar-tv-chat

[ARCHIVED] The Ember.js application currently powering Avalonstar's chat overlay.
CoffeeScript
3
star
21

docker-obs

My custom thing for running OBS off of my Unraid server. Just because.
3
star
22

aidoru

Idols. Japanese idols.
Python
3
star
23

avalonstar-overlays

CSS animation-based overlays for my Twitch channel.
CSS
3
star
24

shiver-broadcaster

The best way to stream to Twitch, for your Mac.
Objective-C
2
star
25

shiver-electron

Shiver, the Twitch notifier and viewer. Built on Electron.
JavaScript
2
star
26

landale

My next set of overlays.
TypeScript
2
star
27

rykros

TypeScript
2
star
28

anxia

A mindfully-designed Twitter client for people with extreme social media anxiety.
TypeScript
2
star
29

django-project-template

My personal project template skeleton, because I do this way too much.
Python
2
star
30

decibyte

Your video game musicโ€”played, managed and organized the way it should have always been.
Objective-C
2
star
31

homeassistant

๐Ÿ  My (basic, but growing) Home Assistant configuration.
2
star
32

landale-next

Overlays 2023.
TypeScript
1
star
33

igctpp

This shit matters.
1
star
34

lettersaurus

Elegant subscriber letters, and dinosaurs.
1
star
35

xsplit

Backups of my XSplit configurations. These are serious business.
1
star
36

next-js-blog-with-comments

JavaScript
1
star
37

avalonstar-sails

The site that powers the channel (deprecated).
JavaScript
1
star
38

me

My website. Like, the personal one.
HTML
1
star
39

sayonarane

Jen's site, on GitHub for sanity.
PHP
1
star
40

pounce

๐Ÿˆ
1
star
41

prior-inventions

List of prior inventions and original works of authorship.
1
star
42

skeleton

My Django skeleton layout. Nekkid.
1
star
43

django-twittersync

A generic Django app that syncs the public tweets from multiple twitter users.
Python
1
star