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

vara

v1.4.1

Published

Vara can create realistic text drawing animations using SVG and a JSON file that acts as font

Downloads

800

Readme

Vara

Paypal Donate

Vara is a javascript library that can create text drawing animations

The 1.x version of Vara will soon be replaced with v2 which uses canvas instead of SVG and might cause breaking changes

Website | Examples | Codepen 1 | Codepen 2

Installation and Basic usage

Using NPM

npm install vara --save

Or download and include the library as follows

<script src="./lib/vara.min.js" type="text/javascript"></script>
<!-- Or jsdelivr -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/vara.min.js" type="text/javascript"></script>
new Vara("#element","font.json",[{
	text:"Handwritten"
}],{
	fontSize:46
});

The first argument, #element is the container element for the SVG.

The font used is a specially created JSON file that contains the information needed to create the text. It is included by passing the URL of the font as the second argument. A few custom fonts are available in the Github repository, more will be added soon. Creation of custom fonts are explained here.

The third argument is an array of objects, where each object will represent a block of text to be drawn. The text to be drawn is passed as the text property.

The last argument is an object to provide the options like fontSize,color etc.

Options

// https://cdn.jsdelivr.net/npm/[email protected]/fonts/fontdir/fontname.json
new Vara("#container","font.json",[
{
	text:"Hello World", // String, text to be shown
	fontSize:24, // Number, size of the text
	strokeWidth:.5, // Width / Thickness of the stroke
	color:"black", // Color of the text
	id:"", // String or integer, for if animations are called manually or when using the get() method. Default is the index of the object.
	duration:2000, // Number, Duration of the animation in milliseconds
	textAlign:"left", // String, text align, accepted values are left,center,right
	x:0, // Number, x coordinate of the text
	y:0, // Number, y coordinate of the text
	fromCurrentPosition:{ // Whether the x or y coordinate should be from its calculated position, ie the position if x or y coordinates were not applied
		x:true, // Boolean
		y:true, // Boolean
	},
	autoAnimation:true, // Boolean, Whether to animate the text automatically
	queued:true, // Boolean, Whether the animation should be in a queue
    delay:0,     // Delay before the animation starts in milliseconds
    /* Letter spacing can be a number or an object, if number, the spacing will be applied to every character.
    If object, each letter can be assigned a different spacing as follows,
    letterSpacing: {
        a: 4,
        j: -6,
        global: -1
    }
    The global property is used to set spacing of all other characters
    */
	letterSpacing:0
}],{
	// The options given below will be applicable to every text created,
	// however they will not override the options set above.
	// They will work as secondary options.
	fontSize:24, // Number, size of the text
	strokeWidth:.5, // Width / Thickness of the stroke
	color:"black", // Color of the text
	duration:2000, // Number, Duration of the animation in milliseconds
	textAlign:"left", // String, text align, accepted values are left,center,right
	autoAnimation:true, // Boolean, Whether to animate the text automatically
	queued:true, // Boolean, Whether the animation should be in a queue
	letterSpacing:0
})

Methods

.ready(function)

Is used to execute a function when the font is loaded and the elements are created.

Any other method should be called inside this function.


.get(id)

Returns an object with properties characters and container.

characters is an array of svg g elements, each representing a letter and container is an svg g wrapping the text block. If an id was given to the text during creation, it should be given as the argument, otherwise use the index of the text block.


.draw(id)

Used to animate texts with autoAnimation:false.

If an id was given to the text during creation it should be given as the argument, otherwise use the index of the text block.


.animationEnd(function(i,o){})

Used to execute a function once animation ends, triggers every time a block of text is drawn. Has two arguments,

i - The id of the drawn text.

o - The object described in the get() method.


.playAll()

Introduced in v1.1.0

Is used to play the animation of every text block, obeying delay and queue

Sponsors

Browser testing provided by

Contact

If you find an issue or a bug or want to suggest a new feature, you can

If you would like to have a specific font created, you can mail me with the details and i will try to create it, if the font have a suitable license.