Create simple graph with css flexbox

When I first read about flexbox I was quite sceptical because I thought that this would be poorly executed and the developers would have to hack around several things.
But I was delighted to be wrong… flexbox seems quite promising and it actually makes creating a simple timeline graph a 5 minute procedure.

For those unfamiliar with the CSS Flexbox spec here are some cool resources:

https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Flexible_boxes

Now onward to our little project.

What we are trying to achieve here is to create a “timeline” based block-graph.

This is the end result:

See the Pen Flexbox graph by Michael Dobekidis (@netgfx) on CodePen

Continue reading

Facebooktwittergoogle_pluspinterestlinkedin
linkedin

All Available CSS Color Names

For a fun project I wrote a little javascript class/function that returns all the availabe CSS color-names like (“red”,”royalBlue”,etc) in many different ways (assosiative-array, indexed-array, object,etc) as well as the selected color shades.

You can find it on gitHub here -> ColorNames Fn

And some examples here -> Examples

[[code]]czowOlwiXCI7e1smKiZdfQ==[[/code]]<a href="http://codepen.io/netgfx/pen/hvsfB">Check out this Pen!</a>

The use is quite easy and it has no library dependencies

Engage the function:


var colorNames = new ColorNames({
"numOfShades":10 // optional
});

And then ask for the type of return object that you wish:


var _colorNames = colorNames.returnItems('all_names'); // returns only the names of the colors
var _colorValues = colorNames.returnItems('all_indexed_obj'); // returns an array of objects that contain both names and colors

Enjoy!

Facebooktwittergoogle_pluspinterestlinkedin
linkedin

Create grid patterns with canvas (blocks, diamonds, hex)

While making some experiments with a game, I felt the need to add a grid to the background, after much thinking I decided that canvas should be the “best” solutions for this.

However after creating a simple “square” grid I wanted also hexagons and diamond grids. And this is what I’m presenting here, how to create “blocks, diamonds and hexagon” grids with one convenient javascript class.

See the Pen Create grids by Michael Dobekidis (@netgfx) on CodePen.

Continue reading

Facebooktwittergoogle_pluspinterestlinkedin
linkedin

Quick Tip: Parse single object from unknown key-values JSON.

Sometimes we need to read data from JSON but we are not sure which value corresponds to a key or we need to parse a really large object. So here’s a tip about how to read key names and their corresponding values from a JSON object.

Let’s assume the following JSON structure:


var gameOps = {"tanks":[
{
  "type":"T1",
  "velocity":"800",
  "speed":"100",
  "bulletType":"t1Ammo",
  "damagePerHit":"0.25",
  "tankWidth":"74",
  "tankHeight":"128",
  "bulletWidth":"7",
  "bulletHeight":"15"
},
{
  "type":"T2",
  "velocity":"800",
  "speed":"100",
  "bulletType":"t1Ammo",
  "damagePerHit":"0.25"
},
{
  "type":"",
  "velocity":"",
  "speed":"",
  "bulletType":"",
  "damagePerHit":""
}

]};

In this object we notice how the first object has values that the others do not, if we tried to parse it based on the first object the code would halt on error because it would be unable to find the rest of the keys.

So what if we only wanted one of the objects but we did not know what properties it has?

Let’s consider the following snippet:


var myObj = getOptions(gameOps);

function getOptions(type, opts){
    var counter = 0;
    var obj = {};
      
    for(var i = 0; i<opts.tanks.length; i++){
      var temp = opts.tanks[counter];
      var keys = Object.keys( temp );
      
      if( temp.type == type){
        
        for(var j=0; j<keys.length; j++){
          
          obj[ keys[ j ] ] = temp[ keys[ j ] ];
        
                        }
               }
      
      counter += 1;
    }
    
    return obj;
  }

Here we check if the desired “type” is among the object properties, if it is we read the available “keys” that the object has, and then we construct another object with those keys and values.

Browser compatibility:
This solution is compatible with
Firefox (Gecko) – 4 (2.0)
Chrome – 5
Internet Explorer – 9
Opera – 12
Safari – 5

Because it uses: Object.keys(obj)

Read more here: https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/keys

Facebooktwittergoogle_pluspinterestlinkedin
linkedin

My game template on Codecanyon!

Finally I have had some free time and thought to try my luck with Codecanyon, which is a place were authors and coders get to monetize their works and for people to get some high-quality code/themes/templates/apps build-in and ready to go.

So I managed to “transform” my game of Easter-egg-hunting into a framework for gathering games (games where items drop and the player has to collect them) I added some code, removed much, and generalized the core to actually adapt and be manageable through a JS file that the user can alter to create his own game.

The template offers:

  • mobile and modern browser support
  • media-queries baked inside
  • responsive gameplay
  • auto pause when the player changes tab or browser loses focus
  • highly customizable options like: background, items, gathering image, score, etc…
  • High performace even on mobile devices, by using multiple canvases
  • And per frame collision detection
So check it out, and buy if you also want to create your own gathering game…

http://codecanyon.net/item/gathering-items-game-template-jquery-tweenmax/4525985

Note: The template uses jQuery, jQueryUI for dragging, and GSAP to manage animation and update functions per frame.

Facebooktwittergoogle_pluspinterestlinkedin
linkedin

Simple HTML5 Easter game [TweenMax as engine]

Logo Image

A happy HTML5 game for Easter, it was developed in under 8 hours with JQuery/UI, HTML5 canvas, and TweenMax from Greensock for the rendering and animation stuff.

Background is from April Wallpapers of Smashing Magazine!
Egg graphics are from MediaLoot freebie set of easter-eggs!

Font is Luckiest-Guy from Google web-fonts!

Tweet if you liked it, and feel free to comment here if you have any questions about the implementation or your high-scores!

EGG-HUNTER GAME!

As always… Enjoy!

Facebooktwittergoogle_pluspinterestlinkedin
linkedin

HTML5 Video on Canvas + pixel manipulation

One of my latest experiments was to create a fullscreen background with a video, for this I used HTML5 video tag and loaded it on a canvas element.
Although it worked it somehow felt incomplete because it was simply a video as background, it needed some edge add to it, for this I decided to use Pixelate library http://close-pixelate.desandro.com/ and extend it so it supported video as well as images.
Github extension can be found also here:

https://github.com/netgfx/close-pixelate

** Note This example is best viewed with latest Chrome or Webkit browser. **

DEMO

Continue reading

Facebooktwittergoogle_pluspinterestlinkedin
linkedin

Text animation JQuery plugin released

I have just released a beta version of a JQuery plugin that manages text animation, it is super easy to use and the results are pretty impressive.

There is still work to be done and whoever wants to contribute is welcome to fork on github here

You can view the plugin page here -> http://netgfx.github.com/SplitText/

View EXAMPLES here -> http://www.netgfx.com/trunk/splitText/examples/examples.html

Or check out under the hood with a previous tutorial that I wrote here -> http://nightlycoding.com/index.php/2013/02/text-effects-with-timelinemax/

If you like it, drop me a line below, also if you find a bug make sure to file it on github

Enjoy!

Facebooktwittergoogle_pluspinterestlinkedin
linkedin

Text Effects with TimelineMax

Text is one of the most important aspects of web-development, someone may have great pictures, effects, and complex animations but if there is no content in text, chances are that the viewer will start looking elsewhere. So since text is such a great aspect of the website or application why not try and make it a little more appealing and exciting, after all it’s not only what you say (write) but how you present it.

So I thought to create a series of effects and animations that modify and give text a “Wow factor”.

[[code]]czowOlwiXCI7e1smKiZdfQ==[[/code]]<a href="http://codepen.io/netgfx/pen/DpbIy">Check out this Pen!</a>

Continue reading

Facebooktwittergoogle_pluspinterestlinkedin
linkedin

ThreeJS camera control with TweenMax

Recently I started exploring the world of 3D, I mostly wanted to work in a familiar environment so I chose ThreeJS an excellent framework for 3D construction/animation with javascript. And of course I wanted to inject my favorite tool for javascript animation TweenMax.
So after a few examples and documentation reading I came up with a very simple example/tutorial of how to control various aspects of the camera in 3D space using TweenMax to animate properties and end-values.
For this example I also used the extremely helpful threejs boilerplate

You can view a DEMO here

Continue reading

Facebooktwittergoogle_pluspinterestlinkedin
linkedin