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

node-sunwell

v0.1.1

Published

Canvas based renderer for Hearthstone cards.

Downloads

4

Readme

node-sunwell

Build Status Coverage Status npm version

An HTML5 canvas based renderer for hearthstone cards for node.js. Forked from HearthSim/sunwell.

Requirements

See HearthSim/sunwell for detailed information. Card artworks and fonts are not included. Set textureFolder to the folder where you put the card artworks when creating the sunwell object.

Installation

$ npm install --save node-sunwell

Usage

Set up sunwell with your own settings:

var Sunwell = require('node-sunwell');
var sunwell = new Sunwell({
	titleFont: 'Belwe',
	bodyFont: 'ITC Franklin Condensed',
	bodyFontSize: 24,
	bodyLineHeight: 55,
	bodyFontOffset: {x: 0, y: 0},
	textureFolder: __dirname + '/artworks/',
	smallTextureFolder: __dirname + '/smallArtworks/',
	debug: false
});

###Rendering a card To render a specific card, you can call the method createCard() of the sunwell object.

var cardObj = sunwell.createCard(cardData, width, function(err, buffer) {
	// buffer contains PNG data
});

The cardData parameter is an object containing information about the card to be rendered. width defines the width of the card to be rendered. Sunwell provides a "native" resolution up to 764x1100 pixels. While you can set a higher value than 764 for the desired render, it will only result in blurry results. The max supported resolution of sunwell is already by far greater than in the game itself.

The callback will be invoked with the rendered card buffer.

The object you pass as cardData can be obtained for example through HearthstoneJSON.

{
	"id":"CS2_087",
	"artist":"Zoltan Boros",
	"set":"CORE",
	"type":"SPELL",
	"rarity":"FREE",
	"cost":1,
	"name":"Blessing of Might",
	"flavor":"\"As in, you MIGHT want to get out of my way.\" - Toad Mackle, recently buffed.",
	"playRequirements":{"REQ_TARGET_TO_PLAY":0,"REQ_MINION_TARGET":0},
	"collectible":true,
	"playerClass":"PALADIN",
	"howToEarnGolden":"Unlocked at Level 45.",
	"howToEarn":"Unlocked at Level 1.",
	"text":"Give a minion +3 Attack.",
	"texture":"W16_a053_D"
}

Some properties are purely optional, since they are not used by sunwell, but these ones are required:

{
	"id":"CS2_087",
	"set":"CORE",
	"type":"SPELL",
	"rarity":"FREE",
	"cost":1,
	"name":"Blessing of Might",
	"playerClass":"PALADIN",
	"text":"Give a minion +3 Attack.",
	"texture":"W16_a053_D"
}

In case of a minion or weapon card, you also need to pass health (or durability, but health is fine for weapons, too) and/or attack.

The method will return an object that provides an interface to manipulate the card after its creation.

If you want to update certain properties on the original cardData, simply call cardObj.update() and pass an object with the properties you want to overwrite.

###Changing the number colors

If you want to make the numbers appear green/red, you can also pass in the following properties on your card object to both createCard() and/or cardObj.update():

{
	"costStyle": "0",
	"attackStyle": "+",
	"healthStyle": "-",
	"durabilityStyle": "-"
}

All the style default to "0". Setting the style to "+" makes the number appear green, setting it to "-" makes it appear red.

###Silence a minion To silence a minion, set silenced: true either when creating the card, or with the update function.

###Let a card cost health instead of mana Introduced by Cho'gall, cards may cost health instead of mana. You can switch any cards cost icon by setting costHealth: true either when creating the card, or through the update function.

Examples

See examples/.

Author

Original work by Christian Engel [email protected]

Node.js port by Matthias Klein [email protected]

License

Sunwell is licensed MIT. The full license text is available in the LICENSE file in the respective implementations' folder.