HearthSim/Sunwell

Name: Sunwell

Owner: HearthSim

Description: Canvas-based high quality Hearthstone card renderer

Created: 2016-04-05 00:11:01.0

Updated: 2018-05-10 13:12:58.0

Pushed: 2018-04-27 00:31:17.0

Homepage: https://hearthsim.info

Size: 51820

Language: TypeScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Sunwell

A high quality Hearthstone card renderer in TypeScript.

Download

The latest, minified version of Sunwell is available here:

https://sunwell.hearthsim.net/branches/master/sunwell.cdn.min.js

Requirements

The following dependencies are required to build Sunwell:

Run yarn install to install the dependencies. Then, run webpack to build the project into dist/sunwell.js.

If you run NODE_ENV=production webpack, it will instead build a minified version into dist/sunwell.min.js.

The assets in the assets/ folder can be copied as-is.

Sunwell currently has no runtime dependencies outside of Webpack.

Fonts

To create faithful renders, the Belwe and Franklin Gothic proprietary fonts are required. Make sure to obtain a license if you wish to distribute cards rendered with them.

Sunwell should work with any fallback font you give it.

Usage

Instanciate a new Sunwell object as such:

t Sunwell = require("Sunwell").Sunwell;
sunwell = new Sunwell(options);

The options object is defined further down.

To render a card, you can use Sunwell.createCard(card). Sunwell aims to be compatible with HearthstoneJSON. You can pass a card object from the HearthstoneJSON API as-is and get a usable card in return.

card = sunwell.createCard(card, width, target, callback);

width is the size of the render (height is determined automatically). The target argument should be a Canvas or Image object the render will be applied to.

Internally, Sunwell renders to a Canvas already. If you target an image, the conversion to PNG and compression will result in performance loss with frequent updates. Rendering to a Canvas is more direct, however will likely result in performance degradation with large amounts of cards on screen. Pick your poison.

The optional callback argument is a function called when the rendering finishes.

Sunwell options

The following options can be forwarded to the Sunwell instance:

Card properties

The following card properties are supported:

Enums are standard Hearthstone enums. They can be passed as an int (preferred) or as their string variant:

Finally, a texture property should be passed as well, for the card art. The texture may be a string, in which case it's treated as a URL, or it may be an Image. If null, an empty grey texture will be created in its place.

NOTE: Some properties only affect certain card types unless explicitly set on the card itself. For example, a spell or weapon will not render a race text even if given one.

Community

Sunwell is a HearthSim project. All development happens on our IRC channel #hearthsim on Freenode.

License

This project is licensed under the MIT license. The full license text is available in the LICENSE file.

The assets directory includes files that are copyright © Blizzard Entertainment.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.