A node cli project file system walker example

So for todays node cli tool example I will be writing about a basic file system walker that I have put together for this series of posts. I have wrote a few posts on file system walkers such as klaw, and just simply walk, as well as the many native nodejs module methods that can be used to make a file system walker from the ground up. This is a post on making node cli tools so for todays post I will be making a file system walker using the node file system method like readdir, stat, and so forth.

Read More

A node cli project initialization tool

So I thought I would write a whole bunch of posts on node cli tool examples. This is of course one of the many reasons why one would want to get into nodejs development. Sure there is writing server side systems with nodejs, but I have started enjoying writing simple command line interface tools using node and javaScript. So in this post I will be starting out with a node cli tool that is a tool that initializes a project folder.

Read More

JavaScript Not Operator usage examples

The javaScript not operator can be used to negate a value and turn the value into a boolean value. In other words whatever the truth value is for a value the js not operator will return the opposite of that value as a boolean type rather than whatever type it might work out to before hand.

So then in many situations the javaScript not operator can come in handy when writing many expressions that might come up when working with conditional statements, and also often with feature testing in my experience thus far. In some code examples I see it being used to trim down the size of a boolean literal expression which is one little trick I will be getting to in this post, and I am sure that there are many other use examples for the js not logical operator that might be of interest when reading code out in the wild. So lets look at some basic examples, and then many some not so basic examples of the javaScript not operator.

Read More

Canvas alpha transparency global alpha property and transparent styles

In canvas alpha channel transparency can be achieved by way of the global alpha property, but also in a number of other ways. There is the global alpha property of the 2d drawing context, and then there is also using the RGBA notation to set a web color for fill or stroke styles. There are a number of other topics to canvas and alpha transparency also, such as using a png image with an alpha channel, and using the clear rect method and having a background behind the canvas element when it comes to getting into layering. So lets look at some examples that have to do with canvas alpha transparency in html 5 canvas and javaScript.

Read More

Canvas examples on animation basics and beyond

So this is another post on canvas examples using just canvas elements and vanilla javaScript by itself. For this canvas example post I will be writing about a basic example of canvas animation as I often end up doing so. There ar many ways of how to go about making animations, but I tend to like making them a certain way that involves the use of methods that are often very pure function like. What I mean by that is making a method where I pass a frame index value, and a total number of frames, and for every set of arguments I always be the same state to which I then render using the 2d canvas drawing context.

Making animations with canvas can be a fun, and rewarding experience and is definitely an example of the fun side of javaScript. In addition in some situations animations can also be helpful as well as a way to express data, or show how something works. There is of course the idea of visualizing a problem, and animation can be a good tool to help do just that. There are many canvas frameworks out there, but for now I will be sticking to just plain old native client side javaScript by itself here today.

Read More