2017 © Pedro Peláez
 

library geopattern

Generate beautiful SVG patterns.

image

redeyeventures/geopattern

Generate beautiful SVG patterns.

  • Tuesday, October 21, 2014
  • by arcdigital
  • Repository
  • 6 Watchers
  • 90 Stars
  • 3,675 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 17 Forks
  • 3 Open issues
  • 4 Versions
  • 7 % Grown

The README.md

GeoPattern Build Status

Latest Version Latest unstable Version, (*1)

This is a PHP port of jasonlong/geo_pattern., (*2)

Generate beautiful tiling SVG patterns from a string. The string is converted into a SHA and a color and pattern are determined based on the values in the hash. The color is determined by shifting the hue and saturation from a default (or passed in) base color. One of 16 patterns is used (or you can specify one) and the sizing of the pattern elements is also determined by the hash values., (*3)

You can use the generated pattern as the background-image for a container. Using the base64 representation of the pattern still results in SVG rendering, so it looks great on retina displays., (*4)

See the GitHub Guides site as an example of what this library can do. (GitHub Guides uses the original ruby version)., (*5)

Installation

Run this command in your root project:, (*6)

composer require redeyeventures/geopattern

Installation (without composer)

Download or clone the src directory from GitHub., (*7)

Rename the src folder to GeoPattern and put it somewhere your app can access it from., (*8)

Add this line to your code:, (*9)

require_once('path/to/folder/geopattern_loader.php');

You can then follow the usage instructions below., (*10)

Usage

Make a new pattern:, (*11)

$geopattern = new \RedeyeVentures\GeoPattern\GeoPattern();
$geopattern->setString('Mastering Markdown');

To specify a base background color (with a hue and saturation that adjusts depending on the string):, (*12)

$geopattern->setBaseColor('#ffcc00');

To use a specific background color (w/o any hue or saturation adjustments):, (*13)

$geopattern->setColor('#ffcc00');

To use a specific pattern generator:, (*14)

$geopattern->setGenerator('sine_waves');

Get the SVG string:, (*15)

$svg = $geopattern->toSVG();

Get the Base64 encoded string:, (*16)

$base64 = $geopattern->toBase64();

Get a data URI:, (*17)

$dataURI = $geopattern->toDataURI(); #data:image/svg+xml;base64,...

Get a data URL:, (*18)

$dataURL = $geopattern->toDataURL(); #url("data:image/svg+xml;base64,...")

You can use the data URL string to set the background:, (*19)

<div style="background-image: {$dataURL)"></div>

The setString, setBaseColor, setGenerator methods are chainable. You can also pass an array to the GeoPattern constructor containing the string, baseColor, color, and/or generator values., (*20)

If the GeoPattern object is cast as a string, it will provide the SVG string., (*21)

Contributing

  1. Fork it ( http://github.com/redeyeventures/geopattern-php/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Original Project

See https://github.com/jasonlong/geo_pattern for more info and links to ports for other languages., (*22)

Based on jasonlong/geo_pattern @ ac27b5bb50a8d2061ff63254c915e9ca96a40480., (*23)

The Versions

21/10 2014

dev-master

9999999-dev

Generate beautiful SVG patterns.

  Sources   Download

MIT

The Development Requires

pattern background svg geometric

21/10 2014

v1.1.1

1.1.1.0

Generate beautiful SVG patterns.

  Sources   Download

MIT

The Development Requires

pattern background svg geometric

23/07 2014

v1.1.0

1.1.0.0

Generate beautiful SVG patterns.

  Sources   Download

MIT

The Development Requires

pattern background svg geometric

26/02 2014

v1.0.0

1.0.0.0

Generate beautiful SVG patterns.

  Sources   Download

MIT

The Development Requires

pattern background svg geometric