api

API for interacting with svg-stockpile.

License

License

GroupId

GroupId

com.mikebull94.svg-stockpile
ArtifactId

ArtifactId

api
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

api
API for interacting with svg-stockpile.
Source Code Management

Source Code Management

https://github.com/MikeBull94/svg-stockpile

Download api

How to add to project

<!-- https://jarcasting.com/artifacts/com.mikebull94.svg-stockpile/api/ -->
<dependency>
    <groupId>com.mikebull94.svg-stockpile</groupId>
    <artifactId>api</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.mikebull94.svg-stockpile/api/
implementation 'com.mikebull94.svg-stockpile:api:1.0.0'
// https://jarcasting.com/artifacts/com.mikebull94.svg-stockpile/api/
implementation ("com.mikebull94.svg-stockpile:api:1.0.0")
'com.mikebull94.svg-stockpile:api:jar:1.0.0'
<dependency org="com.mikebull94.svg-stockpile" name="api" rev="1.0.0">
  <artifact name="api" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.mikebull94.svg-stockpile', module='api', version='1.0.0')
)
libraryDependencies += "com.mikebull94.svg-stockpile" % "api" % "1.0.0"
[com.mikebull94.svg-stockpile/api "1.0.0"]

Dependencies

compile (3)

Group / Artifact Type Version
com.google.guava : guava jar 19.0
org.slf4j : slf4j-api jar 1.7.19
org.slf4j : slf4j-jdk14 jar 1.7.19

test (2)

Group / Artifact Type Version
junit : junit jar 4.12
org.mockito : mockito-core jar 1.10.19

Project Modules

There are no modules declared in this project.

svg-stockpile

Build Status

Introduction

svg-stockpile is an optimizing and stacking tool for Scalable Vector Graphics, written in Java.

With SVGs being heavily supported on the web many may wish to compress and package all of their SVG assets into a single optimized file. This technique is known as using a sprite-sheet, and can be achieved in SVG documents with the use of fragment identifiers, the use of which is fairly supported by most modern browsers.

Each fragment renders part of the SVG document by defining a view identifier. The unique views may then be rendered in an HTML document via the <img> tag, such as in the following example:

<img src="example.svg#layer1" alt="Example" width="50" height="50" />

Documentation

Javadocs are available for both the API and the [Gradle Plugin] gradle-plugin-javadoc.

Installation

This project is available in the Maven Central Repository. The artifacts are signed with my personal GPG key.

API

To install the API in a Maven project, add the following dependency to your pom.xml file:

<dependency>
  <groupId>com.mikebull94.svg-stockpile</groupId>
  <artifactId>api</artifactId>
  <version>1.0.0</version>
</dependency>

To install the API in a Gradle project, add the following dependency to your build.gradle file:

dependencies {
    compile group: 'com.mikebull94.svg-stockpile', name: 'api', version: '1.0.0'
}

Gradle Plugin

To install the Gradle Plugin into your build lifecycle, add the following code to your build.gradle file:

import com.mikebull94.stockpile.svg.SvgViewBox

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath group: 'com.mikebull94.svg-stockpile', name: 'gradle-plugin', version: '1.0.0'
    }
}

apply plugin: 'com.mikebull94.svg-stockpile'

stockpile {
    inputDir = projectDir
    output = file('output.svg')
    viewBox = new SvgViewBox(0, 0, 500, 500)
}

build.dependsOn stockpile

Example

An example class is included to show how typical API interaction is performed. It can be ran on a set of input SVGs such as the Wikimedia Community Logo variations distributed with this project, which are licensed for any purpose within the public domain.

The example requires the following program arguments:

  • inputDir - The input directory of SVGs (e.g. api/src/main/resources)
  • output - The output file (e.g. api/build/resources/main/output.svg)
  • minX - The minimum x-coordinate of the viewBox.
  • minY - The minimum y-coordinate of the viewBox.
  • width - The width of the viewBox in pixels.
  • height - The height of the viewBox in pixels.

Correctly populated arguments should look similar to this:

api/src/main/resources api/build/resources/main/output.svg 0 0 500 500

Building

Gradle is used as the project's build system. The [Gradle Wrapper] gradle-wrapper is included in the distribution, therefore you do not need to install Gradle on your system.

To build the program, run the tests, and generate Javadoc, run:

  • ./gradlew (on Unix-like platforms such as Linux and Mac OS X)
  • gradlew (on Windows using the gradlew.bat batch file)

FindBugs™ and PMD are used to lint the Java code and will fail the build on rule violations.

Testing

Tests are written in a behaviour-driven-development style and run using JUnit and Mockito.

Integration tests for the Gradle Plugin run using the Gradle TestKit.

Code coverage reports for the unit tests are generated by JaCoCo.

Dependencies

License

This project is available under the terms of the ISC license. See the LICENSE file for the copyright information and licensing terms.

Versions

Version
1.0.0