npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

relaxed-svg

v0.2.0

Published

SVG plugin for ReLaXed

Downloads

45

Readme

relaxed-svg

This ReLaXed plugin provides utilities to work with SVG:

  • SVG optimization (to reduce the size and complexity of your SVGs)
  • SVG animation, which enable to display only certain elements of a SVG, making it possible to do progressive slides in presentations.

Usage

Install with npm install -g relaxed-svg and add svg to the plugins of your project's config.yml:

plugins:
  - svg:
      jpeg-quality: 90

Parameters

  • jpeg-quality (default: 85) Compression quality the SVG optimizer should use when converting PNGs to JPEG. Set to 100 for no compression.

SVG optimization

Optimized SVGs are smaller in size and (hopefully) look exactly the same. They make PDF rendering faster and in most case also lead to smaller PDF file sizes.

SVG optimization is mostly meant to use in interactive mode, when ReLaXed is watching file changes. To elect a SVG for optimization set its extension to .o.svg, e.g. myschema.o.svg. Every time the file changes, an optimized version myschema_optimized.svg is created. Use this file in your templates.

"Animated slides" with SVG

When writing a slideshow, you may want some graphic elements to appear progressively, so you can introduce your audience to different components, step by step.

For instance your might want to turn this complete slide:

Into a series of progressive slides:

In most slideshow systems, the only way to do so is to generate a series of images, one for each slide. This comes with the inconvenient that, if you want to change an element that is common to all slides, you must regenerate all of them

The relaxed-svg plugin provides a stepSVG plugin that makes it easy, from a single SVG, to create such progressive series of slides where different components can appear or disappear as you wish.

The Pug code will simply look like this:

each step in [0, 1, 2, 3, 4]
  .slide
    +stepSVG(step, 'earth-cutaway.svg')

With this system, any changes to the SVG file get instantly reflected in all the involved slides.

See this page for an example and tutorial on making animated slides with relaxed-svg.

See also these examples, which make extensive use of progressive SVGs (these PDF slideshows are best viewed in presentation mode):

Using SVG layers

Software like Inkscape allow to define "layers", which are simply SVG <g/> groups that can be masked and locked in the software. If a layer is masked it generally has a display: none attribute and won't be displayed in your ReLaXed PDF.

Important: To be able to use layers, your svg layers should have a layer attribute with value the name of the layer. This is not the case by default in Inkscape, you have to enter this attribute manually. A layer name cannot be all, this word is reserved.

To hide all layers except one, add the layer='layer_name' argument to stepSVG:

.slide
    +stepSVG(step, 'car_schema.svg', layer='engine_details')

To ensure all layers will be shown, including the ones that are marked as "invisible" layers in inkscape, use layer='all'