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

icanvas

v1.0.1

Published

iCanvas is wrapper over canvas.

Downloads

8

Readme

iCanvas

iCanvas is wrapper over canvas, Make working with canvas a little bit easier as we all know anyone who has worked with canvas , its quite a low level api its sometimes quite hard to maintain state of canvas, i was facing the same problem when i decided to make a mini game in canvas , so i first created a small library which woukd make working with canvas a breez.

Installation

<script src="iCanvas.js"></script>

or

npm install icanvas

Usage

Basic

       // create the iCanvas object
   	var canvas1 = new iCanvas();
   	// append to body 
   	canvas1.appendTo(document.body);
   	// draws function
   	canvas1.draw(function (ctx, canvas) {
   		ctx.fillStyle = "#000";
   		ctx.strokeStyle = "#000";
   	    ctx.fillRect(200,200,200,200);
   	    ctx.arc(100,100,20,0,Math.PI*2,false);
   	    ctx.stroke();
       });

Basic chaining

		var canvas1 = new iCanvas();
        canvas1.appendTo(document.body);
        canvas1.draw(function (ctx, canvas) {
            ctx.fillStyle = "#000";
            ctx.strokeStyle = "#000";
            ctx.fillRect(200,200,200,200);
        })
          .draw(function (ctx, canvas) {
                ctx.fillStyle = "#000";
                ctx.strokeStyle = "#000";
                ctx.arc(100,100,20,0,Math.PI*2,false);
                ctx.stroke();
            }).render();

callback handler

        var canvas1 = new iCanvas();
        canvas1.appendTo(document.body);
        canvas1.draw(handler1)
			   .draw(handler2)
			   .render();

        function handler1 (ctx, canvas) {
            ctx.fillStyle = "#000";
            ctx.strokeStyle = "#000";
            ctx.fillRect(200,200,200,200);
        }

        function handler2(ctx, canvas) {
            ctx.fillStyle = "#000";
            ctx.strokeStyle = "#000";
            ctx.arc(100,100,20,0,Math.PI*2,false);
            ctx.stroke();
        }

Animation or Game loop

       var pos = 0;
   	var canvas1 = new iCanvas();
   	canvas1.appendTo(document.body);
   	canvas1.background("#000").draw(function (ctx, canvas) {
   		ctx.fillStyle = "#fff";
   		ctx.strokeStyle = "#fff";
   		pos++;
   	    ctx.fillRect(100+pos,100,100,100);
       }).update();

Methods

       var canvas1 = new iCanvas();
   	canvas1.appendTo(document.body);
   	canvas1.draw(function (ctx, canvas) {
   		ctx.clearRect(0,0,canvas.width,canvas.height)
   	    ctx.fillStyle = "#000";
   		ctx.strokeStyle = "#000";
           this.strokeText("Hello",300,100);
           ctx.stroke();

   	    this.circle(100,100,20);
   	    this.line(100,100,400,400);
   	    this.rect(500,100,100,100)

   		ctx.stroke();
       }).render();

I am still working on the documentation, and fixing any bugs.