html5
Monitor progress of long running php scripts with html5 server sent events
Server sent events When running a long serverside task inside a web application it becomes very useful, if not necessary to report the progress of that task in realtime to the clientside, that is the browser. Earlier there was no easy way to do this and hacks had to be constructed to achieve such a realtime notification. Classical solutions include ajax polling, loading in a iframe with raw output, or even flash. But html5 brings [...]
Websockets with php – tutorial on basics
Websockets Websockets is a new feature available in browsers as a part of the Html5 specs that allows javascript clients to open bi directional socket connections to a server. Currently all major desktop browsers support the api. Websocket is not an independant socket protocol, but is based on the TCP protocol just like HTTP. Therefore websocket connections are basically tcp socket connections that following the websocket rules to communicate. The protocol is is documented at [...]
Make a rope using box2d in javascript
Rope In this experiment we shall make a rope like thing in box2d. There is no rope like structure that box2d supports directly. But if multiple small units are connected together at their edges using a revolutejoint, then it was act somewhat like a rope. Lets take a look Please upgrade your browser You can move any part of the rope using your mouse. Now in this rope, higher the number of parts in the [...]
Distance joint in box2d in javascript
Distance In the previous post on mouse joints we learned how to interact with box2d objects using the mouse. Now its time to take a look at another joint in box2d, the distance joint. Distance joint connects 2 bodies maintaining a fixed distance between them, its like metal wire connecting the 2 bodies, such that the wire would neither expand nor shrink, but allow the bodies to rotate about the point of joint. Lets take [...]
Playing with the mouse joint in box2d in javascript
Mouse Joint Out of the many joints that box2d has, one is mouse joint. It is not used in physics simulations, but helps to make the physics world interactive by making a body move towards a specific point, like the mouse coordinates for example. So objects can be picked up, dragged etc by the user. Lets take an example Please upgrade your browser Pickup an object by clicking it and drag it. It will follow [...]
Add custom functions to the html5 audio element for better functionality
Html5 Audio The html5 audio element provides a simple api to play sound files like mp3, ogg, wav etc. It can be created by putting an audio tag in the html or by creating an instance of the Audio object in javascript. Here is a quick example of using it from within javascript code. That much of code would load the file specified in the src path and play it. There are additional functions and [...]
Add a stop function to the html5 audio element
The Audio element of html5 does not yet have a stop function, but has a pause function. So here is a simple trick to add a stop function to your Audio elements by modifying the prototoype of the class. The function would first pause the audio element, then would set the seek position to 0.0 which is the beginning. Can be used comfortably like this The technique can be used to add more useful functions [...]
Enable webgl in google chrome on ubuntu
To enable webgl in Google Chrome launch it with the following flags –enable-webgl –ignore-gpu-blacklist $ google-chrome –enable-webgl –ignore-gpu-blacklist Now test webgl by opening the following url It should show a spinning cube if webgl is working correctly. Open the following url in chrome about:chrome or chrome://gpu/ It should show the following data Graphics Feature Status Canvas: Hardware accelerated Compositing: Hardware accelerated 3D CSS: Hardware accelerated CSS Animation: Accelerated WebGL: Hardware accelerated WebGL multisampling: Hardware accelerated [...]
Enable webgl in firefox on ubuntu
WebGL WebGL (Web Graphics Library) is a JavaScript API for rendering interactive 3D graphics and 2D graphics[2] within any compatible web browser without the use of plug-ins. Software based renderer Webgl might not work directly on your system if there is no supporting hardware or graphics card available. Even then webgl can be made available inside firefox through the mesa software based renderer. To enable it following steps below Install the Mesa off-screen rendering extension [...]
Using the html5 audio element from javascript
Sometime back I was making a browser based game in the html5 canvas tag which had some audio too. The html5 audio tag is an easy option to add sound/music to any webpage. It can play variety of formats like wav, ogg and mp3. However format support itself varies across browsers. The audio element can be directly added to html in the form of a tag The src attribute holds the path/url to the sound [...]