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

rune.save.js

v0.4.1

Published

Rune.js plugin for saving a Rune SVG Sketch as svg, png, jpg and WebP. It works also as a standalone script to save SVG elements as images

Downloads

103

Readme

rune.save.js

rune.save.js + svg.save.js
Export any SVG Element and save them as image (JPG, PNG, SVG and WebP). It works as standalone script and as Rune.js Plugin.

Installation

npm i rune.save.js

It's also available on unpkg :

  • Rune.js Plugin : https://unpkg.com/rune.save.js/dist/rune.save.js
  • Standalone Script : https://unpkg.com/rune.save.js/dist/svg.save.js

Usage

Include the .js file on your HTML document

<!-- Include the Rune.js Plugin using the path to your downloaded file or the unpkg CDN url -->
<script src="./path/rune.save.js"></script>
<script src="https://unpkg.com/rune.save.js/dist/rune.save.js"></script>

<!-- Or the Standalone Script from your file system or unpkg -->
<script src="./path/svg.save.js"></script>
<script src="https://unpkg.com/rune.save.js/dist/svg.save.js"></script>

Call the save() method passing the filename as parameter. ( i.e: 'sketch.png' to be saved as PNG. )

// As Rune.js Plugin
const r = new Rune({
    container: "body",
    width: 600,
    height: 600
});
// ...
// Use the extension of the desired filetype: svg, jpg, png (webp also on Chrome)
r.save('myImage.jpg');

// ---

// As standalone script, create a new exportable SVG Object (xSVG)
// passing the CSS selector string for the target SVG element as parameter.
// Then call the save method.
let drawing = new xSVG('#svgSketch');
    drawing.save();

Options

// The save method has three optional parameters : filename, scale & quality
// Example :

let sketch = new xSVG('#svgSketch');
    sketch.save('sketch.png', 3, .5);

// Image exported as PNG with filename 'sketch.png'
// with output file dimensions 3 times the SVG source size
// and a 0.5 over 1 image quality. (Options explained below)

API

save(file, scale, quality)

file

String indicating the filename including the extension that will be used as the image format (i.e: 'myImage.png').
Allowed image extensions are: svg, png, jpg, jpeg and webp (WebP only works on Chrome).
The default value is: 'image.jpg'

scale

Number that indicates the multiplier used to create the raster image image size dimensions output. In the case that we have a 400x400 SVG file, and a scale multiplier of 3, the output raster image will have a 1200x1200 size (x3).
The default value is 2

quality

Number between 0 and 1 indicating the image quality to use for image formats that use lossy compression such as image/jpeg and image/webp.
The default value is 0.92

License

MIT © Jorge Moreno