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

@leosac/cardrendering

v1.7.3

Published

Card Rendering engine for CR-80 cards and more

Downloads

11

Readme

JS-CardRendering Build Status

JS-CardRendering is a javascript library used to render card printing templates. For node.js and web browsers.

CardRendering Sample

Related projects using js-cardrendering:

Usage

const tpl = {
  background: {
    color: '#ff0000'
  },
  fields: [
    {
      type: 'label',
      autoSize: true,
      color: '#000000',
      value: 'My first card',
      width: 46,
      height: 18,
      x: 80,
      y: 50
    },
    {
      type: 'qrcode',
      value: 'https://www.leosac.com',
      width: 132,
      height: 132,
      x: 250,
      y: 100,
    }
  ]
};

Node

npm install @leosac/cardrendering --save

PIXI.js is required. It is a peer dependency because of the differents versions available depending of your targeted environment. Use npm install pixi.js --save or npm install @pixi/node --save.

import { createCanvas } from "canvas";
import { CardRenderer } from "@leosac/cardrendering";

const renderer = new CardRenderer({
  canvas: createCanvas(445, 280),
  grid: {
    ruler: true
  }
});
renderer.createCardStage({size: 'cr80', orientation: 'landscape'}, tpl);
renderer.animate();

Web Browser

<script type="text/javascript" src="cardrendering.js" />
<canvas id="card"></canvas>
const renderer = new cardrendering.CardRenderer({
  canvas: document.getElementById('card'),
  grid: {
    ruler: true
  }
});
renderer.createCardStage({size: 'cr80', orientation: 'landscape'}, tpl);
renderer.animate();

From source

git clone https://github.com/leosac/js-cardrendering.git
cd "js-cardrendering"
npm install

Build for redistribution

npm run build

Run tests

npm run test

Parameters

CardRenderer constructor

canvas

The canvas where to render the template.

grid

Grid/View settings

{
  ruler: false
}

interaction

Set to true to enable onCard* events.

onCardClickDown

Event triggered on card click down.

onCardClickUp

Event triggered on card click up.

onCardMouseMove

Event triggered on card mouse move.

onFieldDragStart

Event triggered on a field drag start.

onFieldDragEnd

Event triggered on a field drag end.

onFieldDragMove

Event triggered on a field drag move.

onSelectedSpriteCreated

Event triggered on selected sprite creation.

onFieldAdded

Event triggered on new field addition.

onSelectionChanged

Event triggered on field selection change.

onChange

Event triggered on template content change.

onError

Event triggered on error.

createCardStage method

layout.size

The card layout size.

  • cr80 : Standard CR-80 card size
  • cr79 : CR-79 card size
  • cr100 : CR-100 ID card size
  • res_4to3 : 4/3 visual
  • res_3to2 : 3/2 visual
  • res_8to5 : 8/5 visual
  • res_5to3 : 5/3 visual
  • res_16to9 : 16/9 visual
  • custom : Use custom size

layout.orientation

The layout orientation.

  • landscape
  • portrait

tpl

The template to render.

resize

Resize based on the parent container. If the layout size exceed the container size, then rulers are forced as disabled and the view scaled.

License

This project has been created by Leosac SAS. The source code of this library is released under LGPLv3 license.