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 🙏

© 2025 – Pkg Stats / Ryan Hefner

svg-cardio

v1.0.0

Published

A template based SVG playing card generator

Downloads

3

Readme

svg-card-i/o

A template based SVG playing card generator.

View on GitHub

This tool can generate playing card SVG images from a template and various parameters.

You can change the card width/height, the vertical/horizontal padding, the border width, border radius and inner frame width to receive different outputs like these:

7 of hearts, default 7 of hearts, large 7 of hearts, mini

The tool will place the suit symbols precisely in the points seen in this image:

diagram of calculated intersection points

Usage

If you just want to use the pre-generated cards, see svgs/.

To create your own, adjust the dimensions in generateCardDeckFromTemplate.mjs*, and run npm install. This will overwrite the contents of the svgs folder.

Or you can use the tool programmatically like this:

import { generateDeck } from 'svg-cardio';

// see generateAll.mjs for possible values
const templateName = 'emoji';

const template = await import(`svg-cardio/templates/template-${templateName}`);

let svgText = generateDeck({ template, debug: false });

This works in Node or in the browser. See demoPage-inline.html for a usage example.

*I know this is not ideal…

Included templates

This package comes with 2 card themes, Emoji and Fowler. Both are available with standard suit colors (black, red) or "international" colors (black, red, green, orange).

You will find the cards pre-generated in 60x90mm in the svgs/ folder along with HTML pages to view them.

Emoji card deck Fowler

This package also comes with various card back templates, each available in multiple colors.

See the svgs/ folder for the pre-generated versions in 60x90mm.

Red card back with circles pattern Blue card back with circles pattern Green card back with interconnected pattern Purple card back with fleur de lis pattern Red card back with cube pattern Black card back with lozenges pattern

See the demo pages [ 1, 2, 3, 4, 5, 6 ] for more colors.

Notice how the patterns align nicely with all edges. As you change the card or padding size, the pattern gets slightly stretched, so it always fits perfectly:

Blue circle pattern, stretched Blue circle pattern, stretched Blue circle pattern, stretched

Writing a template

The best way to get started is to duplicate an existing template from the templates folder.

A template file must export a text, a demoPage, a list of suits and a list of figures.

Inside the text you can use placeholders of the form {placeholder} that will be replaced with the corresponding values.

The complete list of available placeholders is borderWidth, cardValue, cornerRadius, debugMarkup, fontCSS, fontSize, frameBorderWidth, frameGapSize, halfSymbolWidth, horizontalPadding, illustration, innerHeight, innerMaxX, innerMaxY, innerWidth, isDebug, isPicture, suitName, suitSymbolPath, suitSymbolScalingFactor, suitSymbols, totalCardHeight, totalCardWidth, totalSVGHeight, totalSVGWidth, verticalPadding, verticalSymbolOffset, verticalTextOffset, verticalTextOffsetNumber, verticalTextOffsetPicture, viewBox.

Conditionals are available using {?isBoolean}conditionalContent{/isBoolean}.

Apart from placeholder replacement, the tool can also do basic math using the syntax {=1+2}. Other than the standard math operations, it also supports Math.round using the [] symbols. So {=[1.75]} results in the output 2. A sophisticated example from one of the predefined templates:

scale({= {innerWidth}/(11*[{innerWidth}/11]) }, {= {innerHeight}/( 22*[{innerHeight}/22]) })

This will calculate scaling factors that fill the available space with an integer count of background elements (which are of size 11x22).