Skip to content

jselzer/geopattern

Repository files navigation

GeoPattern

Status License


Generate beautiful tiling SVG patterns from a string. This is a Java port of the original Ruby library by Jason Long.

For an example of the library in use, see https://github.com/jselzer/geopattern-swing.

📝 Table of Contents

🧐 About

GeoPattern is a library for generating tiled SVG images based on a seed string. The string is converted to a SHA and a pattern and colour are determined using the values in the hash.

All of the patterns in the original GeoPattern library are implemented and tested to confirm that they exactly match the original. For an example of what GeoPatterns look like, see the live preview page implemented by Brandon Mills for the Javascript port.

🏁 Getting Started

You can download the latest release JAR from the Github Releases page.

Alternatively, you can pull it from the central Maven repositories:

<dependency>
  <groupId>io.github.jselzer</groupId>
  <artifactId>geopattern</artifactId>
  <version>1.0.0</version>
</dependency>

Building

Building requires a Java JDK (>= 11) and Gradle. Intellij IDEA is recommended.

🎈 Usage

Make a new pattern:

Pattern pattern = new PatternGenerator("seed string").generate();

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

Pattern pattern = new PatternGenerator("seed string", new AdjustableColorPreset(Color.MAGENTA)).generate();

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

Pattern pattern = new PatternGenerator("seed string", new FixedColorPreset(Color.MAGENTA)).generate();

To use a specific pattern generator:

Pattern pattern = new PatternGenerator("seed string", List.of(PatternType.SINE_WAVES)).generate();

To use a subset of the available patterns:

Pattern pattern = new PatternGenerator("seed string", List.of(PatternType.SINE_WAVES, PatternType.CHEVRONS)).generate();

To construct a pattern using a Builder:

PatternGenerator patternGenerator = PatternGenerator.builder()
				.seedString("seed string")
				.colorPreset(new FixedColorPreset(new Color(255, 40, 96)))
				.desiredPatterns(List.of(PatternType.CHEVRONS))
				.build();

To get an SVG String:

String svg = pattern.toSvg();

⛏️ Built Using

🎉 Acknowledgements

About

Generate beautiful tiled images - in Java!

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages