Category Archives: HTML 5

JavaScript – Processing.js 2D library – part 001.

This is part 001 from tutorials series about Processing.js.
The javascript library Processing help us to create one good interface with our javascript.
This library come with many features to show into canvas data and infos and also to create 2D and 3D interfaces.
I used to show this features one online editor named studio sketchpad and can be found here
Using this online editor can help you but if you want to use all features then you need to put the library into your html file.
In this tutorial I just use the online editor and later will come with another tutorials about how to set the library.
Make one account of this online editor if you want to save your work.
The development is simple and has some rules.
The script will have two functions setup – for settings and draw – basically will draw the canvas.

This will fill with functions, statements and all the commands available to Processing.js.
Take a look at page references.
On the bottom of the script can also make classes.
This will be created like this:

As can we see classes comes without void and args ().
Let’s how it’s works classes by using two : Ball and MovingBall.
If you want to make one class and then you need to used then use this steps:
– create the class Ball;
– add two functions: update and display;
– add also the possition of the class by using two float variables x,y ;
– because any class need to have one instance then you need one,so put this instance into the class and named like the class Ball;
– this instance will need to take the possition and then to used so you need also two variables: _x and _y;
– if you want to show it then also you need a display function with some 2D/3D primitives;
Also the classes can be created not just to show you the 2D/3D primitives.
Let’s see the source code of this class named Ball.

Let’s make another class named MovingBall.
This class will be like the Ball class and will be extended by Ball class.
This means the all content of Ball class can be used or not by MovingBall.

This MovingBall has the MovingBall extends the Ball with _x,_y and also used super to reference the superclass of a subclass. Take a look where is put the variables x,y and _x,_y into the Ball and MovingBall.
The Ball will get _x,_y possitions and will give it to x,y, also the MovingBall will follow the same rules.
Now I will add one function to MovingBall named drawline, see:

This will set the sets the color used to draw lines and borders around shapes with stroke function and will make one line from x,y to 0,0.
When will run this function will have one line.
Let’s see the MovingBall class:

The first step when you want to using this library is to know how to set the canvas and how to change it.
The size of this canvas can be done with this function: size.
For example : size(400,400) means 400 pixels x 400 pixels.
The background can be change it with background() function and sets the color used for the background.
The smooth function will draw all geometry with smooth (anti-aliased) edges.
Because we want to draw something then you need to fill the setup and draw functions.
Also into setup function will put the new created classes and will used into draw function to draw.
Let’s see the final source code:

You can see my example here:

Posted in All, HTML 5, javascript, Programming. Tagged with , , , , , , .

JavaScript – Pixi.js 2D library – part 001.

Today I will show you how to deal with Pixi.js.
Also it’s Winter holidays and Christmas traditions in Romania like: the Bear dance, the Masked carolers and the Goat.
This make me happy and I will use one image with: the Bear dance.
The Pixi.js library provide a fast lightweight 2D renderer.
First you need to download the javascript pixi.js from pixi github project.
I used two image files: datini.jpg, bur_effect.jpg and one png mask file named mask.png.
The scrip is very simple:

The output is this:
In case you want to see it live the try this link.

Posted in All, HTML 5, javascript, Programming. Tagged with , , , , .

WebGL – sound test example with Three.js .

This is the result of my example : webgl test sound .

And this it’s the source code :

<!DOCTYPE html>
<html lang=”en”>
<title>three.js misc – sound</title>
<meta charset=”utf-8″>
<meta name=”viewport” content=”width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0″>
body {
background-color: #000000;
margin: 0px;
overflow: hidden;
font-weight: bold;
<div id=”container”></div>
<script src=”../js/three.min.js”></script>
<script src=”../js/controls/FirstPersonControls.js”></script>
<script src=”../js/Detector.js”></script>

if ( ! Detector.webgl ) Detector.addGetWebGLMessage();

var container;
var camera, controls, scene, renderer;
var light, pointLight;

var mesh;
var material_sphere1, material_sphere2;

var clock = new THREE.Clock();


function init() {

container = document.getElementById( ‘container’ );

camera = new THREE.PerspectiveCamera( 50, window.innerWidth / window.innerHeight, 1, 10000 );
camera.position.set( 0, 25, 0 );

var listener = new THREE.AudioListener();
camera.add( listener );

controls = new THREE.FirstPersonControls( camera );

controls.movementSpeed = 70;
controls.lookSpeed = 0.05;
controls.noFly = true;
controls.lookVertical = false;

scene = new THREE.Scene();
scene.fog = new THREE.FogExp2( 0x000000, 0.0035 );

light = new THREE.DirectionalLight( 0xffffff );
light.position.set( 0, 0.5, 1 ).normalize();
scene.add( light );

var sound1 = new THREE.Audio( listener );
sound1.load( ‘../sounds/sound.wav’ );
sound1.setRefDistance( 20 );
sound1.autoplay = true;
scene.add( sound1 );

var helper = new THREE.GridHelper( 500, 10 );
helper.color1.setHex( 0x444444 );
helper.color2.setHex( 0x444444 );
helper.position.y = 0.1
scene.add( helper );

renderer = new THREE.WebGLRenderer( { antialias: true } );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
container.innerHTML = “”;
container.appendChild( renderer.domElement );
window.addEventListener( ‘resize’, onWindowResize, false );


function onWindowResize() {

camera.aspect = window.innerWidth / window.innerHeight;
renderer.setSize( window.innerWidth, window.innerHeight );

function animate() {
requestAnimationFrame( animate );

function render() {

var delta = clock.getDelta(),
time = clock.getElapsedTime() * 5;
controls.update( delta );
renderer.render( scene, camera );

Posted in All, HTML 5, javascript, Programming, web, WebGL. Tagged with , , , , , , .

JSON IP and GeoIP REST API from telize website.

According to telize website :
This service offers a REST API allowing to get a visitor IP address and to query location information from any IP address. It outputs JSON-encoded IP geolocation data, and supports both JSON and JSONP.
There is no rate limit of any sort at the moment, and the service is free for everyone to use.

Today I test it with a simple json script.
This is the html file I used to get all infos.

Posted in All, HTML 5, Programming, web. Tagged with , , , , , .

Test your javascript online with many libs.

If you want to test some java script then use

This website allow you to script html, css, javascript with many libs.

This libs include JQuery, Bootstrap, Angular, Dojo, Enyo, CoffeeScript and more…

After you edit your script just press button Run with JS.

See the next image where I test if WebGL is supported by my browser.

javascript programming online

Posted in All, HTML 5, Programming, web, WebGL. Tagged with , , , , .